Posts

Showing posts from February, 2010

angularjs - Get contents of child_added while watching firebaseArray -

i have simple private chat, different type of messages, when send server json structure pass message type too. $scope.messages = firechat.firebasearray; $scope.addmessage = function(e) { //add firebase $scope.messages.$add({ uid: $scope.authdata.uid, text: $scope.msg, timestamp: firebase.servervalue.timestamp, type: 'msg' }); $scope.msg = ""; //reset message }; as can see there property 'type'. now i'd watch new messages. in documentation there watch api function, returns id of record/message. i'd contents of message , check type there , according run other js functions. $scope.messages.$watch(function (data) { console.log("angularfire watch"); console.log(data); console.log(data.event); console.log(data.key); console.log(data.prevchild); }); above return child_added -jp6kzwlydtdetz8agpr , -jp6kzwlydtdetz8ospr . see, no body under key there possibility k

excel - How would I translate this to RegEx? -

i'm having trouble translate regex: actual file format (for excel spreadsheet): [demo-_file.xls]'sheet_name'!ca [sample file 2.xls]'demo sheet'!d inside bracket , single quote: accept characters z (regardless of case) accepts special characters -_. , space. after exclamation mark, should accept 4 capital characters. here suggestion: \[[\w\s&.-]*\]'[\w\s&.-]+'![a-z]{1,4} in js: var re = /\[[\w\s&.-]*\]'[\w\s&.-]+'![a-z]{1,4}/gi; [\w\s&.-]* match alphanumeric characters , _ spaces, & , . , - . [a-z]{1,4} match 1 4 uppercase english letters. i option make matching case-insensitive. if want allow digits in last part, revert them [a-z0-9]{1,4} . see demo

c# - Certificate don't work without CSP software -

i have problem oces employee certificates (pkcs12). issued danish certificate administrator "nets". if don't have nets' csp software installed on machine , call x509certificate2 (c#) unhandled error! if have csp software installed x509certificate2 works - when use certificate afterwards in code, csp software prompts new password?!? now - if import , export certificate in , out of firefox , use exported certificate, works fine! is. don't have have csp software installed , don't popup! alright - that's fine, have around 3000 certificates in db , don't want import/export these in firefox hand!! does know how make "firefox-trick" programmatically? by way: firefox can trick - not ie or chrome, nor bouncy castle! certificates must have proprietary information issuer, , information disappears when i'm exporting in firefox. could provide me information following things in order help. do these certificates have private key

loops - Making ArrayList Size equal to other Array Lists Available in Java -

i have 2 arraylists of varying sizes. example - array1.size() = 10 array2.size() = 5 want @ times these arrays have same size. thus, have class ensure this. obviously, isn't working me. please help! below class code - for (int = array2.size(); == array1.size(); i++) { array2.add(i, "test"); } the above loop doesn't add 'test' array2 matches size of array1. ideas guys? please help! since never equal array1.size(), loop never adds anything for (int = array2.size(); == array1.size(); i++) { array2.add(i, "test"); }

symfony - Send a post parameter with path -

i have list of demands, can remove some, have created path every demand that: <a href="{{ path('etudiant_suprimer_demande',{'id':demande.id} )}} and have controller that: class edudiantcontroller extends controller { //codes public function suprimerdemandeaction($id){ // echo $id; $em = $this->getdoctrine() ->getentitymanager(); $demande = $em->getrepository('acmeestmsitebundle:demande') ->find($id); if ($demande == null) { throw $this->createnotfoundexception('demande[id='.$id.']inexistant'); } if ($this->get('request')->getmethod() == 'post') { $this->get('session')->getflashbag()->add('info', 'demande bien supprimée'); return $this->redirect( $this->generateurl('acme_estm_site_espace_etudiant')); } //return $this->render('sdzblogbundle:blog:supprimer.html.twig&

jquery - Spring Security Ajax Custom Filter -

below sample code handling ajaxtimeoutredirectfilter. using spring-security spring framework correctly. private int customsessionexpirederrorcode = 901; if(authenticationtrustresolver.isanonymous(securitycontextholder.getcontext().getauthentication())) { logger.info("user session expired or not logged in yet"); string ajaxheader = ((httpservletrequest) request).getheader("x-requested-with"); if ("xmlhttprequest".equals(ajaxheader)) { logger.info("ajax call detected, send {} error code"); httpservletresponse resp = (httpservletresponse) response; resp.senderror(this.customsessionexpirederrorcode); } else { logger.info("redirect login page"); throw ase; } } else { throw ase; } at ui level, trying capture 901 error code on header.jsp globally. $.ajax({ statuscode: { 400: function() { alert('400 status code! user

How should I write a unit test forJavaScript frontend service that uses promise with Karma, Mocha and Sinon -

trying test services i'm writing interact 3rd party api , wondering how test efficiently. i have next method: function getmemberprofile(memberid) { //make sure memberid defined , number if (!isnan(memberid)) { return client.authorizedapirequest('/members/' + memberid).get(); } return promise.reject(new error('proper memberid not supplied')); } when client.authorizedapirequest('/members/' + memberid).get() calls 3rd party api , returns promise resolves object (i.e. {id:12,name:'john doe'}). so, how should test getmemberprofile function? thinking mocking out client.authorizedapirequest("some params").get() sinon can't working. thanks ok, got working. first you'll need install chai . then, in spec file: beforeeach(function () { fakemember = { member: { id: 10002, first_name: 'john', last_name: 'doe&#

objective c - NSTimer? - Check Connection iOS -

i using following method check if app has connection. it's simple , works great needs. + (void)checkinternet:(connection)block { nsurl *url = [nsurl urlwithstring:@"http://www.google.com/"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url]; request.httpmethod = @"head"; request.cachepolicy = nsurlrequestreloadignoringlocalandremotecachedata; request.timeoutinterval = 10.0; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler: ^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { block([(nshttpurlresponse *)response statuscode] == 200); }]; } however, i'd if status doesn't return 200, i'd check again, @ least couple of times. what's best way 1 second intervals? below how i'm calling above method. [self checkinternet:^(bool internet)

Reading PDF document with iTextSharp creates string with repeating first page -

i use itextsharp read in pdf files , parse them using string receive. have encountered strange behavior pdf files. when getting string of example 4 page pdf, string filled pages in following order: 1 2 1 3 1 4 my code reading files follows: using (pdfreader reader = new pdfreader(filestream)) { stringbuilder sb = new stringbuilder(); itextextractionstrategy strategy = new simpletextextractionstrategy(); (int page = 0; page < reader.numberofpages; page++) { string text = pdftextextractor.gettextfrompage(reader, page + 1, strategy); if (!string.isnullorwhitespace(text)) sb.append(encoding.utf8.getstring(encoding.convert(encoding.default, encoding.utf8, encoding.default.getbytes(text)))); } debug.writeline(sb.tostring()); } here link file behaviour occurs: https://onedrive.live.com/redir?resid=d9feff3bf45e05fd!1536&authkey=!aflrlskavlg89yy&ithint=file%2cpdf hope guys can me out! thanks chris

Scan for Kontakt.io iBeacons in background Objective-C -

i'm trying find how scan ibeacons in background far understood can check when user enters region, tried enable background modes nslog 2 methods should work in background: - (void)locationmanager:(ktklocationmanager *)locationmanager didenterregion:(ktkregion *)region { nslog(@"enter region %@", region.uuid); } - (void)locationmanager:(ktklocationmanager *)locationmanager didexitregion:(ktkregion *)region { nslog(@"exit region %@", region.uuid); } but devices doesn't seem scan while in background, missing? it's simple achieve kontakt.io sdk :) check link http://docs.kontakt.io/ios-sdk/quickstart/#ios-8-compatibility . believe didn't add plist. when have added in app after allowing access location app, methods: - (void)locationmanager:(ktklocationmanager *)locationmanager didenterregion:(ktkregion *)region; - (void)locationmanager:(ktklocationmanager *)locationmanager didexitregion:(ktkregion

Ascii UnicodeEncodeError with raw sql query via execute() using SQLAlchemy + mysql-connector-python and Python 3.4 -

given following (run interactive shell): from sqlalchemy import create_engine sqlalchemy.orm import scoped_session e = create_engine("mysql+mysqlconnector://{dbuser}:{dbpass}@{dbhost}/{schema}", encoding="utf8") row in e.execute("select * some_table t join some_join j on t.link_id = j.link_id"): print(dict(row)) i'm receiving following error: traceback (most recent call last): file "<stdin>", line 2, in <module> unicodeencodeerror: 'ascii' codec can't encode character '\xe1' in position 195: ordinal not in range(128) the database content has lot of non-ascii characters in text fields , tables 'utf8_general_ci' collated. i've tried multiple combinations of connection string/create_engine parameters (use_unicode, encoding etc.) , far nothing has affected outcome. by would've cheated , iterated on attributes on 'row' , encoded them individually necessary, 'row'

ios - Xcode UIScrollView zoom same as MKMapView zoom (no effect on subview) -

i want add zoom effect on uiscrollview . have achieved uiscrollview delegate methods. (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview . now want add effect mkmapview having in it, if zoom-in or zoom-out mkmapview place marker of map remains @ same place , same size. how can can achieve same effect uiscrollview zoom effect. my initial guess cgaffinetransform . question when , how? thanks, jay stepin. if understand correctly, want able zoom scroll view in , out while visual objects on remain "anchored" locations. i'd suggest use uiscrollview 's zoomscale property tells multiplier should apply scroll view's content positions. say, have object ( uiimage , example) it's center @ x = 100.0 , y = 100.0 , zoomscale = 1.0 . define couple of constants/variables store coordinates somewhere (let's call them initialx , initialy , example). track zoomscale value in uiscrollviewdelegate protocol's - scrollviewdidzo

c++ - Is it safe to use operator [] for std::string -

i'm fighting old c-style-interface. have function signature this: /// if return_value == null length returned void f( char * return_value, size_t * size_only_known_at_runtime); my question is, following code safe? std::size required; f( null, &required ); std::string s; s.resize(required); f( &s[0], &required ); is there better way data string? yes, it's safe, @ least explicitly c++11. [string.require], emphasis mine: the char-like objects in basic_string object shall stored contiguously . is, basic_string object s, identity &*(s.begin() + n) == &*s.begin() + n shall hold values of n such 0 <= n < s.size() . this resolution of dr 530 . before c++11, not explicit in standard, although done in practice anyway. in c++14, requirement got moved [basic.string]: a basic_string contiguous container (23.2.1). where [container.requirements.general]: a contiguous container container supports random access iter

javascript - Object: Deep omit -

is there way use _.omit on nested object properties? i want happen: schema = { firstname: { type: string }, secret: { type: string, optional: true, private: true } }; schema = _.nestedomit(schema, 'private'); console.log(schema); // should log // { // firstname: { // type: string // }, // secret: { // type: string, // optional: true // } // } _.nestedomit doesn't exist , _.omit doesn't affect nested properties, should clear i'm looking for. it doesn't have underscore, in experience makes things shorter , clearer. you create nestedomit mixin traverse object remove unwanted key. like _.mixin({ nestedomit: function(obj, iteratee, context) { // basic _.omit on current object var r = _.omit(obj, iteratee, context); //transform children objects _.each(r, function(val, key) { if (typeof(val) === "object") r[key] = _.nestedo

What should be the correct XML xpath? -

here's xml document. <?xml version="1.0" encoding="utf-8"?> <env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mtc="otc_matching_11-0" xmlns:rm="otc_rm_11-0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="otc_rm_11-0 /xmls/otc/otc_rm_11-0.xsd otc_matching_11-0 /xmls/otc/otc_matching_11-0.xsd http://schemas.xmlsoap.org/soap/envelope/ /xmls/otc/soap-envelope.xsd "> <env:header> <otc_rm xmlns="otc_rm_11-0"> <manifest> <trademsg> <activity>new</activity> <status>submit</status> </trademsg> </manifest> </otc_rm> </env:header> </env:envelope> shouldn't xpath activity be: /env:envelope/env:header/rm:otc_rm/rm:manifest/rm:trademsg/rm:activity i doesn't work. tried here wh

angularjs - dynamically choosing models for data binding (using a jQuery plugin via a directive) -

i got spectrum jquery plugin , two-way data binding work, see plnkr . below code of directive, makes me paste in... app.directive('picker', function () { return { restrict: 'e', require: 'ngmodel', link: function (scope, el, atts, ngmodel) { el.spectrum({ color: '#ffffff', flat: true, move: function (newcolor) { scope.$apply(function () { ngmodel.$setviewvalue(newcolor.tohexstring()); }); }, showbuttons: false }); ngmodel.$render = function () { if (document.getelementbyid('firstcolor').value !== "") { el.spectrum("set", ngmodel.$viewvalue); } }; } }; }); what have: can choose color using spectrum's color picker , it's in sync input field. can type color input , gets synced color picker. what want: thing want choose multiple colors using same color picker. ideally user clicks "choose 2nd color" button , sync between color picker , s

c++11 - Move CComBSTR to std::vector? -

is there way move ccombstr object std::vector without copying underlying string? seems following code doesn't work. ccombstr str(l"somestr"); std::vector<ccombstr> vstr; vstr.push_back((ccombstr)str.detach()); your code doesn't work because detach gives bstr , not ccombstr . have used std::vector<bstr> vstr , long realise bstr points first character of string, there's length prefix before memory points (see, e.g. bstr (automation) ), you'd need careful managing it. alternatively, have used ccombstr str(l"somestr"); std::vector<ccombstr> vstr; vstr.push_back(str); which make copy of string. the msdn page on ccombstr not indicate has move-semantics, might have been added code without documentation being updated. don't think though, in case std::move solution in answer same second example: simple copy.

Understanding Java Arrays -

please @ following code : public static void main(string[] args) { random random = new random(); int[] array = new int[10]; arrays.setall(array, operand -> random.nextint(10)); system.out.println(arrays.tostring(array)); swap(array, 0, 9); system.out.println(arrays.tostring(array)); } static void swap(int[] array, int i, int j) { int temp = array[i]; // pass value ?? array[i] = array[j]; // value of temp doesn't change, why? array[j] = temp; // temp == array[i] } what happens in method swap ? i need full explanation , low level. edit : ok, let me show example : public class stringholder { private string value; public stringholder(string value) { this.value = value; } public string getvalue() { return value; } public void setvalue(string value) { this.value = value; } @override public string tostring() { return getvalue(); } } main method : public

c# - silverlight map mousemove finished event -

i developing on silverlight. want raise event when move event of mouse finished. radmap.mousemove += (s, e) => { var position = e.getposition(s radmap); var location = telerik.windows.controls.map.location.getcoordinates(radmap, position); currentmouselocation = string.format("{0}, {1}", location.latitude.tostring("f6"), location.longitude.tostring("f6")); }; above mouse move event. when event finished, want raise event. did not find way perform it. can please me can done so. thank you you want detect when movement over. mouseevents can't tell whether user stopped moving further. have decide upon timespan used detect "movement stopped". on every mousemove have reset timer , when timer fires can raise own mousemovementstopped event.

python - Using json.dumps(string) to dump a string -

i want put string json.dumps() string = "{data}" print json.dumps(string) and get: "{data}" instead of: {data} how can string without quotes? method replace : json.dumps(string.replace('"', '') or strip : json.dumps(string.strip('"') does not work. you don't dump a string to a string. d = {"foo": "bar"} j = json.dumps(d) print(j) output: {"foo": "bar"} it makes no sense use string argument of json.dumps expecting dictionary or list/tuple argument. serialize obj json formatted str using conversion table.

javascript - Kendo UI JS grid editing cells won't work and gives no error -

Image
when press of cells cell focused can't type in field. no console errors whatsoever. here code: $(document).ready(function () { datasource = new kendo.data.datasource({ transport: { read: { url: '/discountpromotion/get', datatype: "json", }, update: { url: '/discountpromotion/update', datatype: "json", type: "post", contenttype: "application/json" }, destroy: { url: '/discountpromotion/delete', datatype: "json", type: "post", contenttype: "application/json" }, create: { url: '/discountpromotion/add', datatype: "json", type: "post", contenttype: "application/json" }, parametermap: function(options, operat

javascript - IF statement doenst work -

i've got function dont know if "switch" better? (function ($) { var doc = $.urlparam('doc'); if (doc) { if (doc = 'new') { alert(doc); } if (doc = 'new2') { alert(doc); } if (doc = 'new3') { alert(doc); } } })(jquery); the alert should show if parameter in url right, in if statement. the complete code can found here: https://jsfiddle.net/yc5f9ct7/4/ as pointed out, using assignment = instead of comparison == or exact comparison === . that aside, if testing 1 variable multiple values, , intend have different code on each, switch more logical: var doc = $.urlparam('doc'); switch (doc){ case 'new': alert(doc); break; case 'new2': alert(doc); break; case 'new3': alert(doc); break; } also note: looks code wants wrap last part in dom

ios - Delay between setNeedsDisplay() and call of redraw() function -

i writing app fetches steps data healthkit , displays statistics on screen. have viewcontoller delegate protocol function: func uservalueforhistogramview(sender: histogramview) -> cgfloat? { return uservalue } where uservalue is: var uservalue : cgfloat = 1000 { didset{ println("didset") histogramview.setneedsdisplay() } } the drawrect function on histogramview looks this: override func drawrect(rect: cgrect) { var value = datasource?.uservalueforhistogramview(self) println("\(value)") } i initiate update of uservalue through function: func startrefreshbygettinguservalue() when function simply: func startrefreshbygettinguservalue(){ uservalue = 1500; } i instantaneous log message "didset" followed value of uservalue redrawrect(). now, when change function : func startrefreshbygettinguservalue(){ let calendar = nscalendar.currentcalendar() let toda

delphi - How to translate (internationalize, localize) application? -

i need translate application on delphi. strings in interface on russian. tools fast find, parcing pas'es string constants? how people translate large applications? gettext should able do, search "extract" @ http://dxgettext.po.dk/documentation/how-to if need translate gui , maybe resourcestring in sources, , inline string constants in pascal sources not needed translation, can try delphi built-in method. forums ite buggy. @ least official delphi way. http://edn.embarcadero.com/article/32974 http://docwiki.embarcadero.com/radstudio/en/creating_resource_dlls to translate sources itm manual preparation needed shown in source sheets @ http://www.gunsmoker.ru/2010/06/delphi-ite-integrated-translation.html i remember tranlsated polaris texts jedivcl team - did extraction. think extracted characters > #127 text file - there no structure, there constants , comments, together. still, there component, though doubt can used way need: http://wiki

Cakephp send email in different user selected language -

i want sent email on specific language regarding of web language. for example when user register has possibility select language example english - en , italian - it , german - de , french - fr . the website multilingual, wanna when user fills form example contact form, , after submits form e-mail sent him. so lets assume has selected italian language of website, when registered had selected english. e-mail should sent on english though site in italian. emails translated through __() function of cakephp using .pot files. email template this: contact_us_user <h2 style="color: #ee2424;"> <?php echo __('sitename'); ?> </h2> <?php echo "<h2 style='text-align: left;'>"; if (isset($firstname) && isset($lastname) && isset($title)) { echo __('hello <span style="color: #ee2424;"> %s %s</span>.', $firstname, $lastname); } else {

java - best way to seperate common methods -

i have common methods 2 classes , maybe others in future. therefore not want copy same methods in classes. thought create utility class , put these methods inside , send necessary data parameter. read using utility class violate oop. as second, thinking apply strategy pattern not need change behaviour of method in runtime, work same both classes therefore looks not suit problem. do have idea best approach situation or design pattern applied? it's not bad violate oop utility class. almost frameworks (spring, hibernate you_name_it) extend. furthermore, if later plan support code, composition easier refactor / support maintain inheritance in classes.

objective c - iOS use parsed Json and put into TableView -

i'm new both obj-c , json, i'm creating first ios project using tableviewcontroller. json got wcf looks this: { fri = ( "\u8fc7\u7a0b\u63a7\u5236\u7cfb\u7edf\u4e0e\u4eea\u8868;\u5468\u4e94\u7b2c1,2\u8282{\u7b2c7-16\u5468};\u9ad8\u5b8f\u4f1f;xx-226", "matlab\u5e94\u7528;\u5468\u4e94\u7b2c3,4\u8282{\u7b2c9-16\u5468};\u8d75\u5ef6\u4e1c;xx-128;;\u8ba1\u7b97\u673a\u8fc7\u7a0b\u63a7\u5236\u6280\u672f;\u5468\u4e94\u7b2c3,4\u8282{\u7b2c1-8\u5468};\u9ad8\u5b8f\u4f1f;xx-226", "\u7f51\u7edc\u5316\u6d4b\u63a7\u7cfb\u7edf;\u5468\u4e94\u7b2c5,6\u8282{\u7b2c1-12\u5468};\u80e1\u745e/\u9648\u4eae;xx-228", "\u5de5\u63a7\u7ec4\u6001\u8f6f\u4ef6\u53ca\u5e94\u7528;\u5468\u4e94\u7b2c7,8\u8282{\u7b2c1-8\u5468};\u9a6c\u666f\u5bcc;xx-228;;\u81ea\u52a8\u63a7\u5236\u539f\u7406\uff08\u63d0\u9ad8\uff09;\u5468\u4e94\u7b2c7,8\u8282{\u7b2c9-16\u5468};\u5218\u6d77\u8273;xx-229", "<null>", "<null>" ); mon =

python - Python3 gi: GtkTextBuffer core dump -

using python3 gi.repository.gtk , i'm trying display multiple text lines inside gtktextview via gtktextbuffer . basically, i'm dynamically adding lines using _addline method, updates text buffer way ( self._lines array , self._textbuffer gtktextbuffer ): def _addline(self, text): if len(self._lines) == self._maxlines: self._lines = self._lines[1:] self._lines.append(text) content = '\n'.join(self._lines) print("tic: %d" % len(content)) self._textbuffer.set_text(content) print("tac") unfortunately, @ random values of i (either lower or bigger self._maxlines ), randomly core dump between "tic" , "tac", when try set content of buffer. this method called threading, himself called constructor (after gui elements initialized): def _startupdatethread(self): thread = threading.thread(target=lambda: self._updateloop()) thread.daemon = true thread.start() def _updateloop(self):

java - How do i add Toolbar to this layout? -

layout xml: <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" /> </relativelayout> <listview android:id="@+id/drawer" android:layout_width="120dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#80000000" a

csv - Removing space in Java error -

basically, program convert data .csv format. but, faced error such when open file in excel, displays data when in notepad, becomes characters ㈬㥙〳㈬㥙ㄳ㌬かㄹ㌬か㌹㌬ㅋㄳ㌬ㅋ㈳㌬ㅋ㌳㌬ㅋ㐳 here's line of code string resultstring = stringwriter.tostring(); ( string cheese: pie.keyset() ) { resultstring += system.getproperty("line.separator") + cheese + "," + pie.get(cheese).tostring(); resultstring = resultstring.replaceall(",$" , "").replaceall(" ", ""); } this.writetofile(resultstring); i have multiple file method remove space file has error. i've tried multiple methods such removing before first resultstring , @ of pie.get(cheese).tostring() . also tried .replace(" ", ""); , replaceall("\\s","") the data contains special characters. these characters not rendered default encoding. when writing/creating text/csv file, set character encoding utf-8. can in java prog

c++ - What is the difference between .o .a and .so files? -

i know .o object files, .a static libraries , .so dynamic libraries? physical significance? when can use , when not? .a "archive". although archive can contain type of file, in context of gnu toolchain, library of object files (other toolchains on windows use .lib same purpose, format of these not typically general purpose archive, , specific toolchain). possible extract individual object files archive linker when uses library. .o object file. code compiled machine code not (typically) linked - may have unresolved references symbols defined in other object files (in library or individually) generated separate compilation. object files contain meta-data support linking other modules, , optionally source-level symbolic debugging (in gdb example). other toolchains, again typically on windows, use extension .obj rather .o . .so shared object library (or shared library). dynamically linked executable when program launched rather statically linked @ bui

c# - Connection string without error page? -

i have gridview , sqldatasource this: <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:dbconnectionstring %>" providername="<%$ connectionstrings:dbconnectionstring.providername %>" selectcommand="select * [string]"> </asp:sqldatasource> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" datakeynames="id" datasourceid="sqldatasource1"> <columns> <asp:boundfield datafield="id" headertext="id" insertvisible="false" readonly="true" sortexpression="id" /> <asp:boundfield datafield="hostname" headertext="hostname" sortexpression="hostname" /> <asp:boundfield datafield="date" headertext="date" sortexp

javascript - Scrape/Retrieve Data from Data Grid - DOM to CSV console output -

i want scrape cell widgets -> data grid on page: http://samples.gwtproject.org/samples/showcase/showcase.html#!cwdatagrid ideally looking csv style string output (first line , last line example) ;corey;jenkins;63;coworkers;438 techwood st; .... (many rows here) ;yvonne;morris;55;family; 483 third pkwy; (i working firefox) not sure whether trying build site scraper on gwt website. in above example each of row has identifying attribute across each of grid rows represented tr tags. first tr tag have __gwt_row="0" __gwt_subrow="0" . you have cell attributes of type __gwt_cell="cell-gwt-uid-29" the above 2 attributes on row , cell should allow xpath lookup , iteration scrape page , output csv file.

linux kernel - Which usb driver is called in order to transfer data? -

i change behaviour of 1 of usb flash drive editing driver, can't find driver called. i searched , found drivers/usb/storage/transport.c responsible exchanges beetween host , device (configuration), want find driver sends urb whith data. is there way find that? thank you luis i searched , found it's function usb_stor_bulk_transfer_sglist in transport.c perform data transfer usb flash drive in fact, uses urb sglist of address

c++ - OpenGL – Severe distortions even with correct matrices -

Image
my simple opengl program displaying severely distorted shape. i'm using glm matrix math. compared modelview matrix , projection matrix values program displaying values correctly. yet, still distorted. cause? here matrix code: modelviewmatrix = glm::lookat(glm::vec3(3.0f, 5.0f, 7.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); projectionmatrix = glm::perspective(glm::radians(45.0f), (float)height/(float)width, 0.01f, 100.0f); and here vertex shader code: #version 300 es in mediump vec3 vertexposition; uniform mediump mat4 modelviewmatrix; uniform mediump mat4 projectionmatrix; out vec3 finalposition; void main(void) { gl_position = projectionmatrix * modelviewmatrix * vec4(vertexposition, 1.0); } here screenshots of (unlit) cuboid: note correct image black one. both using exact same shader , same model view , projection matrix numbers. why happening? i believe aspect ratio being calculated incorrectly - should width / height. you hav

How to lock levels in Android app -

i developing quiz application in android. in application i'm having categories , added levels in each category. need lock categories except first one. user able unlock categories after he/she completes specific goal of level. don't know how lock categories in android. categories in form of buttons. using following i'm populating list , passing of 3 categories, i.e. hollywood, bollywood , music. hollywood = (button) findviewbyid(r.id.main_hollywood); typeface tf = typeface.createfromasset(getcontext().getassets(), "font/game_font.ttf"); hollywood.settypeface(tf); onclicklistener listener = new onclicklistener() { @override public void onclick(view v) { settings.edit().putboolean("check", false).commit(); intent intent = new intent(getcontext(), sceneactivity.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); finish();

Ubuntu - change tmux 1.8 to tmux-next 1.9 -

after tried install few plugins tmux found tmux version 1.8. following steps answer install tmux 2.1: ugrade tmux 1.8 1.9 on ubuntu 14.04 (i didn't found tmux=1.9a-1~ppa1~t , instead install tmux-next , substitute link in usr bin sudo ln -sf $(which tmux-next) /usr/bin/tmux tmux works nicely, didn't load config. tried tmux source, should tmux source every time use tmux. and after errors: unknown option: mode-mouse unknown option: mode-mouse unknown option: mouse-select-pane unknown option: mouse-resize-pane unknown option: mouse-select-window unknown option: mode-mouse unknown option: mode-mouse is tmux-next same tmux? , should load .tmux.conf automatically? just have installed tmux 2.1 on ubuntu server , faced same problem. solution me delete unknown options , add lines instead: set -g mouse-utf8 on set -g mouse on now in tmux 2.1 can choose pane, window , resize mouse in tmux 1.8 mouse support section of 'man tmux' : "the defa

python - Why is my line clipping in matplotlib? -

Image
i trying draw series of lines. lines same length, , randomly switch colors random length (blue orange). drawing lines in blue , overlaying orange on top. can see picture there clipped parts of lines grey. cannot figure out why happening. related believe labels not moving left alignment should. appreciated. import numpy np import matplotlib.pyplot plt import matplotlib.lines mlines import random plt.close('all') fig, ax = plt.subplots(figsize=(15,11)) def label(xy, text): y = xy[1] - 2 ax.text(xy[0], y, text, ha="left", family='sans-serif', size=14) def draw_chromosome(start, stop, y, color): x = np.array([start, stop]) y = np.array([y, y]) line = mlines.line2d(x , y, lw=10., color=color) ax.add_line(line) x = 50 y = 100 chr = 1 in range(22): draw_chromosome(x, 120, y, "#1c2f4d") j = 0 while j < 120: print j length = 1 if random.randint(1, 100) > 90: l

Jquery URL Parameter -

i've got function: $.urlparam = function(name){ var results = new regexp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); if (results==null){ return null; } else{ return results[1] || 0; } }; fiddle i put ?param1 behind url nothing showing up, firebug console doesn't anything. can guys me?

c# - SSRS: Dynamic Size of Subreports -

we have set of subreports, can parametrized , shown on list of reports. problem is, these reports don't have pre-defined margin, there more space content , less. but couldn't make work tell subreport resize dynamically in width. if put in rectangle or grid, subreport has size has on sub-report itself, , not 1 tell him have via mainreport-designer. is there possibility make subreport resize in width dynamically? ssrs reports have specific width. includes sub-reports. answer question no, unfortunately.

html - Passing a file input to next code line in php -

i trying image user using file input method. getting image user. want input passed next line of code. any appreciated. <input type='file' name='image'> $two=createfrompng("here want input passed"); you can use $_files global variable. example : var_dump($_files['image']); http://php.net/manual/en/reserved.variables.files.php

php - I want to replace all dots with br except that dots between digits and after shortcut words -

i want replace dots br except dots between digits , after shortcut words. for example: this number 1.4 hi dr. david, name ayman. how you. converted to this number 1.4 hi dr. david, name ayman <br /> how <br /> you can play bit negative lookbehind/lookahead expressions. example (?<!dr|mr|mrs|miss)\.(?!\d)

javascript - Large strings with Papa parse cause Chrome and Opera to crash -

papa parse appears causing chrome , opera crash (windows 7) if attempt parse "large" csv strings of 1 million rows 20 columns. same page loads in firefox. chrome , opera crash before calling parse if have large csv string defined , include <script> tag papaparse.js library. if don't include <script> tag papaparse.js there no problems creating large csv strings can't parse them. in actual use case, not generating large csv strings in javascript rather pulling them out of zip archive. doesn't appear make difference if use step or chunk functions. can run test case here; test case problem code; <!doctype html> <html> <script src="http://papaparse.com/resources/js/papaparse.js"></script> <body> <script> function my_createmockcsv(rows) { var my_csv="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v\r\n"; (var i=1; i<rows; i++) { my_csv+= i+","+ i+","+ i+",&qu

python - Properly watch websites for updates -

i wrote script i'm using push updates pushbullet channels whenever new nexus factory image released. separate channel exists each of first 11 devices on page, , i'm using rather convoluted script watch updates. full setup here (specifically this script ), i'll briefly summarize script below. my question this: not correct way doing this, it's susceptible multiple points of failure. better method of doing this? prefer stick python, i'm open other languages if simpler/better. (this question prompted fact updated apache 2.4 config tonight , apparently triggered slight change in output of local files watched urlwatch , 11 channels got erroneous update pushed them.) basic script functionality (some nonessential parts not included): create dictionary of each device codename associated full model name get existing nexus factory images page using requests make bs4 object source code for each of 11 devices in dictionary (loop), following: open/create page

mongodb - Node.js:Typeerror cannot read property 'find' of undefined -

i've been doing research within these couple of days got stuck while trying test codes got web. var mongoclient = require('mongodb').mongoclient, format = require('util').format; mongoclient.connect('mongodb://127.0.0.1:27017/test', function(err, db) { if (err) { throw err; } else { console.log("successfully connected database"); db.collection('chat', function(err, collection) { collection.find({}, { tailable: true, awaitdata: true, numberofretries: -1 }) .sort({ $natural: 1 }) .each(function(err, doc) { console.log(doc); }) }); } db.close(); }); and error is: c:\project\node_modules\mongodb\lib\mongo_client.js:406 throw err ^ missing external library/reference because error says " cannot read property 'find' of undefined ".

css - aligning tables left and right for responsive html emails - Outlook 2010 Issue -

im having issue 'nav' area of email im coding. works fine in browsers , works responsively, ( http://imgur.com/3ivr3pu ) when opened in outlook. the code block below. any ideas how can make sit next left element? <layout label='nav'> <table border="0" cellpadding="0" cellspacing="0" align="center" width="580" class="devicewidth" style="mso-table-lspace:0;mso-table-rspace:0;"> <tr> <td> <table border="0" cellpadding="0" cellspacing="0" align="left" width="50%" class="devicewidth" style="mso-table-lspace:0;mso-table-rspace:0; border-collapse:collapse;"> <tr bgcolor="#9cacbc"><td class="borderbottom" width="50%" style="font-size: 13px; color: #ffffff !important; font-weight: normal; text-align: center; font-family: arial, helvetica, sans-s

wpf - Width of a letter or an alphabet in a font -

i want know width(units) of particular letter or alphabet in particular font. for example if type in arial 10 pnts how space take in panel or text box or notepad. i tend not worry widths, instead leaving wpf format text nicely in whatever control i'm using. however, think can create formattedtext object using typeface , string "a" (amongst other things), , use minwidth property width in units of 1 / 96th of inch. this code started: formattedtext ft = new formattedtext( "a", cultureinfo.getcultureinfo("en-us"), flowdirection.lefttoright, new typeface("arial"), 32, brushes.black); double width = ft.minwidth; on system, sets width 21.343 . if put em-dash — in a is, (as expected) 32.0 , size specified em in fifth argument formattedtext constructor.

ruby - How to allow special IP or host access /admin page with Rails? -

if django, can use allowed_hosts = [] in settings.py file. how rails? i think can try def local_allow_ip_ranges %w{ 127.0.0.1 12.123.1.123 192.168.1.0/255.255.255.0 } end now below method checks if given ip in above list def is_local(ip) require 'ipaddr' ip = ipaddr.new(ip) local_allow_ip_ranges.any? {|range| ipaddr.new(range).include?(ip) } end

browser - Debugging binary websockets frames -

Image
packet analyzers wireshark , , fiddler allows low-level packet dump, , appears recommended way debug binary websocket frames. major problems of approach includes secure websocket layers, complexity, friction in development process, amongst others. other wireshark, browser native, or extension tools available see @ least hex dump of binary frames exchanged via websockets? edit: of chrome 56.0, frames of textual websocket connections can watched (by going debug console (f12) -> network -> selecting websocket connection (to identify: has 101 http status code) -> frames panel); binary packets still show "binary frame (opcode 2) in firefox use web socket monitor extension hex dump binary packets.

php - Edit button is undefined id of table -

i have code edit button: <form method="post" action="pengiriman-input.php"> <input type="hidden" name="id" value="<?php echo $row['id_transaksi']; ?>" /> <input type="submit" value="kirim" /> </form> and in pengiriman-input.php <?php session_start(); $_session['id_transaksi'] = $_post['idtransaksi']; ?> but result is: undefined index: idtransaksi in > c:\xampp\htdocs\delivery\pengiriman-input.php how call value of $row['idtransaksi'] pengiriman-input.php ? $row['idtransaksi'] mysql query. typo within post name within name attribute name='id' , not idtransaksi $_session['id_transaksi'] = $_post['idtransaksi']; ^^^^^^^^^^^ it should $_session['id_transaksi'] = $_post['id']; ^^^

html - side effects of always using word-wrap: break-word -

it seems word-wrap: break-word (and other browser specific versions) commonly used user generated comment may run long. seems me doing word-wrap: break-word on entire webpage convenient , relatively easy safety net without having specifying everywhere. did quick sanity check , can't think of how may break things. there side effects watch out before doing * {word-wrap: break-word} ? there shouldn't side-effects if goal break long words , display them on next line... mean: abcdefghijklmnopqrstuvwxyz will become abcde fghij klmno pqrst uvwxy z or depending on width of page, i.e, word breaks.

html5 - Object definition in the canvas -

i'm making final project in last year of college called "data flow diagram drawing tool" website based. having difficulties on how make warning when diagram in canvas wrong. example, terminator meets data flow meets process correct. when terminator meets data flow , meets storage wrong. how can make warning when mistake occurred? need kind of object definition each shape in canvas. how do that? need :( here's quick outline of how create , validate data-flow steps: create javascript objects hold information related each step in data-flow diagram. save step-objects in array easy processing iterate through steps array , validate each step. example code: // create javascript objects representing data-flow steps // , put steps objects in array easy processing var steps=[]; steps.push({type:'external',label:'customer'}); steps.push({type:'flow',label:'place order',isbidirectional:true}); steps.push({type:'process