Posts

Showing posts from January, 2012

rust - How to partition Vec in place in method that doesn't own `self`? -

so, there's struct looks this: struct foo { alpha: vec<t>, beta: vec<t>, } and method should move values matches condition alpha beta . question is: clean way without owning self ? the vec::partition() method can't used because moving of self.alpha causes cannot move out of dereference of &mut-pointer compile error. ps: t have file inside doesn't implement clone . do want drop beta ? sort of thing std::mem::replace for, allowing pull out: use std::mem; impl foo { fn munge(&mut self) { let alpha = mem::replace(&mut self.alpha, vec::new()); let (alpha, beta) = alpha.partition(…); self.alpha = alpha; self.beta = beta; } } note there is new vec created there briefly, doesn’t matter; doesn’t involve allocation , cheap. (the alternative leaving uninitialised memory there , replacing again, forgetting uninitialised memory, unsafe if partition can fail run destructor on uninit...

android - Check if Spell Checker is on? -

i using spell checker in android app. if is off in language , input settings app crashes. needs on app work properly. is there way before using can place check verify spell checker on or turn on directly code? you can check instance of spellcheckersession null , accordingly decide whether spellchecker turned on or not: code snippet: final textservicesmanager tsm = (textservicesmanager) getsystemservice(context.text_services_manager_service); scs = tsm.newspellcheckersession(null, null, this, true); if (scs != null) { scs.getsuggestions(new textinfo(text.gettext().tostring()), 3); } else { // show message user toast.maketext(this, "please turn on spell checker setting", toast.length_long).show(); // can open settings page user turn on componentname componenttolaunch = new componentname("com.android.settings", "com.android.settings.settings$spellcheckerssettingsactivity"); intent intent = new in...

java - Project Tango: Export ADF to sdcard -

i'm trying export adf project tango sdcard use code sample docs , failing me. i'm able export dialog pop-up proper export path. when hit export button, failure in log 12-16 00:48:12.203 192-603/? e/tango_service_library_context﹕ bool runtimeexportareadescription(const string&, const string&, const string&): internal error occured opening file: /storage/emulated/0/c5617dae-01b0-4825-8ee1-777c17693414 12-16 00:48:12.209 8246-8246/? e/androidruntime﹕ fatal exception: main process: com.projecttango.tango, pid: 8246 com.google.atap.tangoservice.tangoinvalidexception @ com.google.atap.tango.tangointernal.throwtangoexceptionifneeded(tangointernal.java:118) @ com.google.atap.tango.tangointernal.exportareadescriptionfile(tangointernal.java:104) @ com.google.atap.tango.requestimportexportactivity.onexportaccepted(requestimportexportactivity.java:83) @ com.google.atap.tango.requestimportexportdialog$1.onclick(requestimportexportdia...

Class with Spring @Conditional is not weaved with AspectJ -

i want load spring 4.0 resources conditionally, below code can job ( how achieve conditional resource import in spring xml context? ): @configuration @conditional(myconditionalconfiguration.condition) @importresource("/com/example/context-fragment.xml") public class myconditionalconfiguration { static class condition implements configurationcondition { @override public configurationphase getconfigurationphase() { return configurationphase.parse_configuration; } @override public boolean matches(conditioncontext context, annotatedtypemetadata metadata) { // load context-fragment.xml if system property defined return system.getproperty("com.example.context-fragment") != null; } } } how ever code can not weaved aspectj, problem supposed @conditional the trace is org.aspectj.weaver.bcexception @ org.aspectj.ajdt.internal.core.builder.ajstate.recordclassfile(a...

android - How to remove ems from TextView programatically? -

having textview in layout xml ems width 8, <textview android:id="@+id/more" android:ems="8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/popup_grey" android:drawableleft="@drawable/dot_small" android:text="@string/get_more" /> i need remove ems textview dynamically on condition. tried view.setems(0) , shrinks textview width 0 . is there piece of code remove it? thanks in advance. you can try this: view.setems(0) @ sametime put width of textview match_parent? way won't shrink textview hope helps gud luck

python - With Bottle, how could I just peek the head of http request instead of receiving whole http request? -

i don't know if possible bottle. website (powered bottle) allow users upload image files. limited size of 100k. use following code in web server that. uploadlimit = 100 # 100k uploadlimitinbyte = uploadlimit* 2**10 print("before call request.headers.get('content-length')") contentlen = request.headers.get('content-length') if contentlen: contentlen = int(contentlen) if contentlen > uploadlimitinbyte: return httpresponse('upload limit 100k') but when clicked upload button in web browser upload file size 2mb, seems server receiving whole 2mb http request. expect above code receive http headers instead of receiving whole http request. not prevent wasting time on receving unecessary bytes

Why the need of java unicode when decimal representation is there? -

package test; public class test { public static void main(string[] args) { char b=65; char b='\u0041'; //aren't these same? } } probably because native character set java programming language unicode , english not language in world. programs written using unicode character set. © jls §3.1 in compiled java program char b = 65 , char b = '\u0041' produce absolutely equivalent bytecode. unicode escape sequence (\uxxxx) can used anywhere in source code, not in string or character literal definition, while number representation not. short example: public class helloworld { public static void \u006d\u0061\u0069\u006e(string[] args) { system.out.println("hello, world!"); } } this absolutely correct "hello world" program main(string[] args) method. further reading: jls §3.2

Number of commits and offset in each partition of a kafka topic -

how find number of commits , current offset in each partition of known kafka topic. using kafka v0.8.1.1 it not clear question, kind of offset you're interested in. there 3 types of offsets: the offset of first available message in topic's partition. use -2 (earliest) --time parameter getoffsetshell tool the offset of last available message in topic's partition. use -1(latest) --time parameter. the last read/processed message offset maintained kafka consumer. high level consumer stores information in zookeeper (separately every consumer group) , takes care keeping date when call commit() or when auto-commit setting set true. simple consumer, code have take care managing offsets. in addition command line utility, offset information #1 , #2 available via simpleconsumer.earliestorlatestoffset(). if number of messages not large, can specify large --offsets parameter getoffsetshell , count number of lines returned tool. otherwise, can write simple loop...

java - How to close a server port after we are done using it? -

note: found similar question here: how close port after using server sockets but did not find satisfactory answer there. here code client program: package hf; import java.io.*; import java.net.*; public class dailyadviceclient { private static final int chatport = 4242; public static void main(string[] args) { dailyadviceclient client = new dailyadviceclient(); client.go(); } private void go() { try { socket socket = new socket("127.0.0.1",chatport); inputstreamreader inputstream = new inputstreamreader(socket.getinputstream()); bufferedreader bufferedreader = new bufferedreader(inputstream); string advice = bufferedreader.readline(); system.out.println("advice received client today "+advice); bufferedreader.close(); } catch(exception e) { system.out.println("failed connect server...

svn - Can't see the SCM blame infomation in Sonar -

i've installed scm activity plugin 1.8 in sonar 4.5 following installation procedure. subversion available on server sonar installed well. using ant target start sonar analysis. i want extract blame information svn , want show in soanrqube i.e., whenever new issue arises automatically assign culprit. however start jenkins 1.532 job run sonar metrics, i've got following output console: [sonar:sonar] 17:52:07.778 info - execute findbugs 2.0.3 done: 947 ms [sonar:sonar] 17:52:07.779 info - sensor findbugssensor done: 948 ms [sonar:sonar] 17:52:07.779 info - sensor initialopenissuessensor... [sonar:sonar] 17:52:08.426 info - sensor initialopenissuessensor done: 647 ms [sonar:sonar] 17:52:08.427 info - sensor projectlinkssensor... [sonar:sonar] 17:52:08.428 info - sensor projectlinkssensor done: 1 ms [sonar:sonar] 17:52:08.428 info - sensor versioneventssensor... [sonar:sonar] 17:52:08.431 info - sensor versioneventssensor done: 3 ms [sonar:sonar] 17:52:08.432 info...

How to put remember me (cookie) in PHP -

i making login page. can login page. in login page need put remember me checkbox , php. part in codes need put "remember me " codes ? please me. this login1.php <?php session_start(); //database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "lala"; // create connection $link = mysql_connect($servername,$username,$password) or die("could not connect"); $db= mysql_select_db("$dbname",$link) or die ("could not select database"); $login = $_post['login']; $password = md5($_post['password']); $rememberme = $_post['remember_me']; $result = mysql_query("select * admin working_id = '$login' , password = '$password'"); $count = mysql_num_rows($result); if($count==1) { //check remember me on or off //if off session login //else add cookie $_session['username'] = $lo...

android - get image of current live wallpaper -

i working on android app extracts dominant colours current wallpaper using wallpapermanager , new palette api. have problem because can't extract colours when using live wallpaper muzei example. how go on that? there must check use other wallpapermanager if live wallpaper set. or maybe there's possibility of grabbing screenshot of live wallpaper? thanks! solution: //reference package manager instance packagemanager pm = getapplicationcontext().getpackagemanager(); /* * wallpaper info not equal null, if live wallpaper * set, drawable image package * live wallpaper */ drawable wallpaperdrawable = null; if (wallpapermanager.getinstance(this).getwallpaperinfo() != null) { wallpaperdrawable = wallpapermanager.getinstance(this).getwallpaperinfo().loadthumbnail(pm); } /* * else, if static wallpapers set, directly * wallpaper image */ else { wallpaperdrawable = wallpapermanager.getinstance(this).getdrawable(); } //drawable ...

paypal - Cannot find Instant Payment Notification (IPN) simulator -

i following tutorial in: http://code.tutsplus.com/tutorials/how-to-setup-recurring-payments--net-30168 which nice far needed sandbox. just can't find is. you can't find sandbox inside paypal. sandbox test platform developers can simulate payments. if code works in sandbox work in production enviroment paypal. should register developer account , begin test. here can simulate ipn

android - Is it possible to tap on a marker (thumbnail) in google Maps api v2 and enlarge "zoom in" -

i have marker in essence thumbnail. know is possible tap on thumbnail , display larger thumbnail, sort of blowing or zooming thumbnail? sorry short question. don't have code @ moment, if can i'll post code go along. camera intent: intent getcameraimage = new intent(mediastore.action_image_capture); getapplicationcontext().getdir( getresources().getstring(r.string.app_name), mode_private); fileuri = uri.fromfile(new file((environment.getexternalstoragedirectory() + "/" +getresources().getstring(r.string.app_name)),new date().gettime() + ".jpg")); getcameraimage.putextra(mediastore.extra_output, fileuri); startactivityforresult(getcameraimage, take_picture); } onactivityresult try { getimagethumbnail getimagethumbnail = new getimagethumbnail(); bitmap = getimagethumbnail.getthumbnail(fileuri, this); } catch (...

c - How to integrate int variable in a string? -

#include<stdio.h> main() { int i=100; char temp[]="value of **** , can write int inside string"; printf("\n%s\n",temp); } i need print value of i inside string. output as: value of 100 , can write int inside string what should write @ place of **** or how should change code output above? don't want use printf print output. you can use sprintf 'print' string char array, printf prints screen: char temp[256]; sprintf(temp, "value of %d , can write int inside string", i); note need make sure buffer large enough! or use snprintf specify maximum string/text length, not write outside of buffer.

winforms - How to smoothly move image automatically? in c# -

i want implement code image flows in endless loop background. this. prepared 2 image object(picture box). i implement move-image-code below. ( cleaned inessential code in topic) private void initializecomponent() { this.p1.image = ((system.drawing.image)(resources.getobject("picture"))); this.p1.location = new system.drawing.point(0, -1000); // 0,0 // 0, -1000 this.p1.size = new system.drawing.size(1000, 1000); this.p2.image = ((system.drawing.image)(resources.getobject("picture"))); this.p2.location = new system.drawing.point(0, 1000); // 0,0 // 0, -1000 this.p2.size = new system.drawing.size(1000, 1000); t1 = new thread(new parameterizedthreadstart(loop)); t1.start(); } private void loop(object o) { ctmethod cttest = new ctmethod(movepicturebox); while (true) { try { this.invoke(cttest); thread.sleep(10); // updated.. } catch(exception e) { break; ...

python - Genetic cellular automata with PyCuda, how to efficiently pass a lot of data per cell to CUDA kernel? -

i'm developing genetic cellular automata using pycuda. each cell have lot of genome data, along cell parameters. i'm wondering efficient way 1) pass cells data cuda kernel, 2) process data. i began 1 particularly bad (imo), yet still working solution. passing each parameter in separate array, process them switch-case , lot of duplicate code. then, realized end pretty large number of parameters per kernel function, , decide rewrite it. second solution store bunch of cell's parameters in single array dimension. more elegant in code, surprisingly code runs 10x slower ! to make more clear, full list of data need stored per cell: (fc, mc, tc): 3x (int) - cell's current 'flavor', mass , temperature (rfc, rmc, rtc): 3x (int) - cell's current registers (fi, mi, ti) each neighbour: 8*3x (int) - incoming values (rfi, rmi, rti) each neighbour: 8*3x (int) - incoming values gate orientation: 1x (uchar) execution pointer: 1x (uchar) current micro-oper...

javascript - Profile specific animation CPU -

Image
the situation & problem have multiple animations (css , javascript/jquery) in site , makes site stutter. my question how can see how cpu specific animation (both css, javascript , jquery) uses in runtime , execution time i know how can see entire site cpu usage not specific animation. click f12, go profiles, click on start. reload page. wait untill page reloaded, , click stop. click on profile , see result (y)

android - draw image on canvas and save into sd card -

i tried use following codes to draw on canvas save canvas on image problem - when try save image, shows error permission denied.my error log below. code draw on canvas: public mydrawview(context c, attributeset attrs) { super(c, attrs); mpath = new path(); mbitmappaint = new paint(paint.dither_flag); mpaint = new paint(); mpaint.setantialias(true); mpaint.setdither(true); mpaint.setcolor(0xff000000); mpaint.setstyle(paint.style.stroke); mpaint.setstrokejoin(paint.join.round); mpaint.setstrokecap(paint.cap.round); mpaint.setstrokewidth(9); } @override protected void onsizechanged(int w, int h, int oldw, int oldh) { super.onsizechanged(w, h, oldw, oldh); mbitmap = bitmap.createbitmap(w, h, bitmap.config.argb_8888); mcanvas = new canvas(mbitmap); } @override protected void ondraw(canvas canvas) { canvas.drawbitmap(mbitmap, 0, 0, m...

android - ndk can't get executable file -

just build simple "helloworld" using android ndk , got shard object supposed executable file. , after pushed file arm emulator, got segmentation fault, real device ok. what's problem? here os version: darwin avator 13.4.0 darwin kernel version 13.4.0: sun aug 17 19:50:11 pdt 2014; root:xnu-2422.115.4~1/release_x86_64 x86_64 i386 macbookpro11,1 darwin here android.mk : local_path := $(call my-dir) include $(clear_vars) local_module := test-libstl local_src_files := test-libstl.cpp include $(build_executable) and after ndk-build ,i got file: $file ../libs/arm64-v8a/test-libstl ../libs/arm64-v8a/test-libstl: elf 64-bit lsb shared object, version 1 (sysv), dynamically linked (uses shared libs), stripped this not error in - it's file utility interprets position independent executable (pie) shared object - executable has been built fine. only android 4.1 , newer supports pie executables, , on 5.0, non-pie executables aren't allowed longer - ma...

c# - Self hosted wcf service on azure vm windows server -

i have wcf service udp binding (new in wcf 4.5) , i'm trying host on windows server 2012 on azure. i did endpoint mapping on azure port need (39901; works http:80, can see iis website) , allowed traffic in firewall port. still can't wsdl in web browser. here app.config console app: <configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> </startup> <system.servicemodel> <behaviors> <servicebehaviors> <behavior> <servicemetadata httpgetenabled="true" httpsgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> <servicethrottling maxconcurrentcalls="12" maxconcurrentinstances="56" maxconcurrentsessions="12" /> <userequestheadersformetadataaddress></userequestheadersforme...

jquery - Create mutidimentional Associative array in javascript -

i need create multidimensional array in javascript my code follows console error "uncaught typeerror: cannot set property 'time' of undefined" var timelogdetails = {}; $('.time_input').each(function(i, obj) { timelogdetails[i]['time'] = $( ).val(); timelogdetails[i]['timelog'] = $( ).attr('timelog'); }); you need first create array timelogdetails , , push in data it. for example: var timelogdetails = [ ]; $('.time_input').each(function(i, obj) { timelogdetails.push( { 'time': $(this).val(), 'timelog': $(this).attr('timelog') } ); }); now, may access information using: timelogdetails[0]['time'] or timelogdetails[0].time

php - Traverse a big table in PostgreSQL with Propel -

i had task iterate on big table (~40kk records) in postgresql using propel , encountered performance issues, both memory limit , execution speed. script had been running 22(!) hours. the task retrieve records based on criteria (not active last 6 months) , archive them (move table) , related entities other tables. the primary table, script working on, has several columns: id , device_id , application_id , last_activity_date , others, don’t have significant meaning here. table contains information applications installed on device , last activity dates. there may several records same device_id , different application_id . here sample table: id | device_id | application_id | last_init_date ----------+-----------+----------------+--------------------- 1 | 1 | 1 | 2013-09-24 17:09:01 2 | 1 | 2 | 2013-09-19 20:36:23 3 | 1 | 3 | 2014-02-11 00:00:00 4 | 2 | ...

scatter - scatter3 of an image shows me a complete white plot -

i want scatter plot rgb image show correlation between colours. this code i = imread('testimage_small.png'); [h, w, ~] = size(i); b = (i(:,:,3)); g = (i(:,:,2)); r = (i(:,:,1)); rgb = [reshape(r,1,h*w); reshape(g,1,h*w); reshape(b,1,h*w)]; figure; scatter3(r(:),g(:),b(:),[], (rgb'),'filled'); view(40,35) it draws image plot , without colour , white! any please ! thanks,

php - jQuery Tablesorter - initial sort rows from array -

i'm trying inital sort table it's row-numbers array/variable $list: row0=id2;row1=id0;row2=id1... <table> <tr id="0">...</tr> <tr id="1">...</tr> <tr id="2">...</tr> </table> how can handle tablesorter rows sorted in $list? thanks tipp or workaround :) this possible duplicate of: how sort dom elements while selecting in jquery? $('#myt tr').sort(function(a, b) { if (parseint(a.id) > parseint(b.id)) return 1; else return -1; }).each(function() { $('#myt').append($(this)); }); td { border: 1px solid grey; padding: 10px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table id='myt'> <tr id="8"> <td>8</td> </tr> <tr id="1"> <td>1</td> </tr> <tr id="21"...

sql - The object name contains more than the maximum number of prefixes. The maximum is 2 -

i facing similar issue many others error message "the object name contains more maximum number of prefixes. maximum 2." my scenario is, create procedure dbo.[usp_procedure] begin declare @loadtime datetme2(7) set @loadtime = (select loadtime [linkedservername].[databasename].[schemaname].[tablename] tablename = 'xxxxxx') insert [currentserver].[schemaname].[tablename] select column1, column2, .... tablename join tablename1 on .... ... ... end the table containing loadtime present in linked server/database , important value utilized further in clause of procedure via @loadtime . query select loadtime .... works fine when try on present server individually. when run part of procedure, procedure fails above mentioned error. linked server connection set , working fine. , procedure needs run on present server, removes scope of creating procedure on linked server. hope scenario articulate. replies welcome. in advance. the line : insert [currentser...

Using arrays in a shell script -

i trying initialise array in shell script below declare -a testarr=( 'a' 'b' ) also below testarr=( 'a' 'b' ) but in both cases, following error shell1.sh: 1: shell1.sh: syntax error: "(" unexpected can please tell me reason above error? since want use posix shell , posix shell not support arrays, can "emulate" array in way: set -- 'a' 'b' then have "array" available in posix shell ("$@") contains ($1) , b ($2). and can pass array function, such as: test() { echo "$2" } set -- 'a' 'b c' test "$@" if need save array can use following function: arrsave() { local i; printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" done echo " " } and use in following way: set -- 'a' 'b c' # save array arr=$(arrsave "$@") ...

Android studio given error when opened -

hey wanted work on lollipop 5.0. downloaded android studio android developers giving error: the environment variable java_home (with value c:\program files\java\jdk1.8.0_25\;) not point valid jdk installation. can please help..... if java home c:\program files\java\jdk1.8.0_25\; remove semicolon end of it; that's not valid windows path.

ios - UICollectionView UIImageView images not appearing -

i'm having trouble getting images appear in uicollectionview. can see cells being created, , if set image manually through storyboard image appears, can't happen in code the collection view uses custom cell, below class cardslistcell: uicollectionviewcell { @iboutlet weak var image: uiimageview! override func awakefromnib() { super.awakefromnib() } }] the image connected in storyboard , cell has correct class set the code displaying image override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> cardslistcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) cardslistcell // configure cell var card : card = self.fetchedresultscontroller.objectatindexpath(indexpath) card var img = uiimage(named: card.image) var imageview = uiimageview(image: img) cell.image = imageview ...

c# - suppress column and remove blank space in crystal report -

i'm working on microsoft visual studio 2003. i'm searching way suppress column if empty , replace blank space left other columns. i'm searching everywhere can't find compatible way version 2003. does exist simple way? appreciate help. crystal reports doesn't have automatic (or easy) way dynamically move columns. you might consider multiple header , details sections approximate this--simply suppress sections contain fields null values.

javascript - How to pass and use URL in jQuery function and how to resolve the issue in closing the Bootstrap modal upon clicking close icon on modal? -

i'm using bootstrap v3.3.0 framework website: i'm having following html : <a href="#" align="center" type="button" class="btn btn-danger" data-toggle="modal" data-target="#mymodal" onclick="showreceipt('http://localhost/images/j12345_6946.jpg');">view receipt</a> want show following modal dialog box when user clicks on above hyperlink. while doing want pass image url modal dialog , show image in modal dialog. following modal dialog: <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"...

ios - SCNNode static body with .dae causing issues -

i have built landscape model in blender, exported .dae , added xcode project. i have loaded scene attached child (landscape grid mesh) landscapenode, loads perfectly. however when attach static physics body landscspenode heronode seems crash invisible wall when attempting fly above land. the functionality looking obvious collision land have modelled heronode cannot fly through land , forced move around it. note: did not converting of y axis in blender nor xcode rotated node 90degrees -x axis. edit: code i've attempted add physics shape landscapenode.physicsbody = [scnphysicsbody bodywithtype:scnphysicsbodytypestatic shape:[scnphysicsshape shapewithnode: [landscapescene.rootnode childnodewithname:@"grid" recursively:no] options:@{scnphysicsshapetypekey:scnphysicsshapetypeconcavepolyhedron}]]; landscapenode.physicsbody = [scnphysicsbody bodywithtype:scnphysicsbodytypestatic shape:[scnphysicsshape shapewithnode: landscapenode options:@{scnphysicsshapetypekey...

c# - ASP.Net TableHeaderRow controller produces tr not th -

this code <asp:table runat="server" id="table" cssclass="table"> <asp:tableheaderrow> <asp:tablecell>date</asp:tablecell> <asp:tablecell>totalinboundcalls</asp:tablecell> <asp:tablecell>ghostcalls</asp:tablecell> <asp:tablecell>anserdcalls</asp:tablecell> <asp:tablecell>avgdurationtime</asp:tablecell> <asp:tablecell>avgtakingtime</asp:tablecell> <asp:tablecell>avgwaitingtime</asp:tablecell> <asp:tablecell>avgringingtime</asp:tablecell> <asp:tablecell>avgholdtime</asp:tablecell> </asp:tableheaderrow> </asp:table> the generated html tr not th , wrong did please? well tr correct, tablecell produce td, th need use <asp:tableheadercell...

iphone - I have integrated google plus in my IOS App , Now how can i get profile detail of logged in user? -

i have integrated google plus in ios app ,i able access token.i have used authentication flow integrate google plus.so after getting access token how can user profile details username, email id, profile pic etc? code access token below: -(ibaction)btngoogleplusclicked:(uibutton *)sender { ibwebview.hidden = false; nsstring *url = [nsstring stringwithformat:@"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=%@&redirect_uri=%@&scope=%@&data-requestvisibleactions=%@",google_plus_client_id,google_plus_call_back_url,google_plus_scope,google_plus_visible_actions]; [ibwebview loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:url]]]; } - (bool)webview:(uiwebview*)webview shouldstartloadwithrequest:(nsurlrequest*)request navigationtype:(uiwebviewnavigationtype)navigationtype { // [indicator startanimating]; if ([[[request url] host] isequaltostring:@"localhost"]) { // extract oauth_v...

cryptography - Feistel Cipher in c# -

i'm trying implement feistel cipher, have following code: public static byte[] encode(byte[] bytes) { byte[] s = (byte[])bytes.clone(); int half = s.length / 2; if (s.length % 2 != 0) throw new exception("unbalanced code"); byte[] left = new byte[half]; byte[] right = new byte[half]; array.copy(s, left, half); array.copy(s, half, right, 0, half); (var k = 0; k < rounds; k++) { left = xor(left,f(right)); var temp = left; left = right; right = temp; } byte[] toreturn = new byte[s.length]; array.copy(left, 0, toreturn, half, half); array.copy(right, 0, toreturn, 0, half); return toreturn; } in sample, rounds 21 , f function rearranges bytes in array of bytes. unfortunately, while bytes should equal encode(encode(bytes)), it's not. , have no idea i'm doing wrong. any advice? edit: code f() public stati...

sitecore - Connect using web proxy to allow OAuth to work -

i'm running sitecore.net 7.0 (rev. 140120) social connected 2.0 (for cms 7.0). however - unfortunately our corporate environment requires connect via proxy server, dev environment not work. i reflected code in sitecore.social.facebook.dll , can see code in sitecore.social.facebook.connector.managers.webrequestmanager.getresponse() makes http requests facebook.com, , not appear reference proxy. i have confirmed on network without proxy requirements setup works well. is there way specify proxy such requests? can write own replacement allow proxy configured - if how plug in? the solution ended being pretty simple. added following web.config: <system.net> <defaultproxy enabled="true" usedefaultcredentials="true"> </defaultproxy> </system.net> you can specify other proxy configuration using method affect whole web application. msdn reference

angularjs - Any easy way to add build version info to coverage test results -

i using karma-coverage measure unit test coverage in project , works in regard fine. use html reporter default directory. however, need "stamp" coverage report build version information have available using grunt-git-describe, used in angularjs app footer loads resulting version.json file. didn't find direct way use version.json file in html reports karma-coverage. if has idea how it, appreciate lot. thanks in advance! i did manage implement sort-of work around. use text-replace module in grunt after running karma this. if 1 has better solution, please share bit of hack, works ok. karma-coverage's html reports in environment goes projects' root /coverage/ folder, made recursive text replace every .html file there looking default footer , adding version info there... first, installed grunt-text-replace $ npm install grunt-text-replace --save-dev then made following replace function in gruntfile.js: grunt.initconfig({ replace: { ...

c++ - Why can't new template parameters be introduced in full specializations? -

in where in c++11 standard prohibit 'template <typename t> class {...}; template <typename t> class a<int> {...};' (if anywhere)? , it's been confirmed following syntax disallowed in c++11 standard: /* invalid c++ */ template <typename t> class { public: t t; }; // phony "full specialization" mistakenly attempts // introduce *new* template parameter template <typename t> class a<int> { public: int i; t t; }; with full understanding above syntax not represent valid c++, nonetheless imagine syntactically unambiguous use of above code snippet, follows: a<float> a1; a<int><double> a2; a1.t = 2.0f; a2.i = 2; a2.t = 2.0; it seem syntactically , semantically unambiguous c++ support syntax above. (if intended semantics not clear anybody, please post comment , explain.) i describe syntax "introducing new template parameter in full specialization". in imagined scenario o...

mysql - I m not be able to get correct number of order_status -

i m trying count of order_registration.status using in join table select dstr_operator_master.*, count(order_registration.status like'%enquiry%') order_status, count(order_registration.pname) destilist dstr_operator_master left join order_registration on find_in_set( order_registration.user_id , dstr_operator_master.u_id) dstr_operator_master.status = '1' , dstr_operator_master.type ='distributor' group dstr_operator_master.auto_id try this: select d.*, sum(case when o.status '%enquiry%' 1 else 0 end) order_status, count(o.pname) destilist dstr_operator_master d left join order_registration o on find_in_set(o.user_id, d.u_id) d.status = '1' , d.type = 'distributor' group d.auto_id;

serial port - Printing Hexadecimals as Hexadecimals in C#? -

i need send array of bytes hardware (sdz16 matrix) using serial port. trick in fact that hardware expects strings of hexadecimal , ascii characters. when assigning values array of bytes, if set bytes explicit hexadecimal value ( bytes[0] = 0xf2 , instance), print equivalent decimal value (242 instead of f2). i suspicious problem in console.writeline(); when printing each byte sets them default integers(?) how c# keep track there hexadecimal value inside int? if assign bytes[0] = 0xf2; hardware understand in hexadecimal if console.writeline(); shows differently testing? if want string representation in hex format can using corresponding numeric format string : byte value = 0xf2; string hexstring = string.format("{0:x2}", value); note console.writeline has overload takes format string , parameter list: console.writeline("{0:x2}", value); update: had glimpse @ documentation here , , seems need send commands providing corresponding ascii ...

node.js - Send a parameter along with sendfile -

i using nodejs i have code var someparameter ="teststst"; var filelocation = path.resolve(__dirname + '/../public/resetpassword.html'); console.log(filelocation); res.sendfile(filelocation); i want send someparameter in resetpassword.html can tell me how ? thanks you can't. (not without engine) passing parameters html won't have effect (and isnt possible) can use template engine such jade (or ejs if want stay html) defined as: app.engine('.html', require('ejs').__express); app.set('views', __dirname + '/views'); app.set('view engine', 'html'); and can 'render' view parameters: app.get('/', function(req, res){ res.render('index', { users: users, title: "ejs example", header: "some users" }); }); usaful info: ejs templates use ejs template node application

javascript - Error calling wcf service by ajax -

iwent run simple wcf method using ajax in html page test doesn't run @ , idont know whats problem ![error message][1] icustomerservice page [operationcontract] [webinvoke(method = "post", responseformat = webmessageformat.json)] string gettest(); service.svc page [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class service1 : icustomerservice { public string gettest() { return "okkkkkkkk"; } here html page > > <title></title> > <script type="text/javascript"></script> > <script type="text/javascript"src="scripts/jquery-2.1.1.min.js"></script> > <script type="text/javascript" src="scripts/jquery-2.1.1.intellisense.js"></script> > <script type="...