Posts

Showing posts from May, 2010

assembly - How do I allocate data to memory in MIPS? -

i beginner in mips assembly language programming , learning work pointers lw , sw instructions. in order practice want set data in memory , write instructions offset base address see how works. on how set .s file great! cheers, samuel welker

python - IDLE shell not able to find image for cx_Oracle (Reason: image not found) -

hi - i've installed cx_oracle on mac os x yosemite 10.10 , able query oracle database through mac terminal using python 2.7.11 in terminal. the problem idle shell application cannot import cx_oracle , displays following error: python 2.7.11 (v2.7.11:6d1b6a68f775, dec 5 2015, 12:54:16) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "copyright", "credits" or "license()" more information. >>> import cx_oracle traceback (most recent call last): file "<pyshell#0>", line 1, in <module> import cx_oracle importerror: dlopen(/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/cx_oracle.so, 2): library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 referenced from: /library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/cx_oracle.so reason: image not found below seeing in mac terminal (i can proceed query database): python 2.7.

hibernate - Injection in custom ConnectionProvider with CDI and Hibernate4 -

in java ee 7 project need custom connectionprovider, call db-function logged userid, , set db-session variables. my problem, can't inject logged user in myconnectionprovider, in other beans - without problem. this connectionprovider: @sessionscoped @named public class myconnectionprovider implements connectionprovider, configurable, serializable { @inject private logger log; @inject @loggedin private user currentuser = null; here class login currentuser initialized: @sessionscoped @named public class login implements serializable { @inject private credentials credentials; @persistencecontext private entitymanager userdatabase; private user currentuser; //..................................... @produces @loggedin @named @sessionscoped public user getcurrentuser() { return currentuser; } and interface loggedin: @retention(retentionpolicy.runtime) @target({type, parameter, method, field}) @qualifier public @interface loggedin {} may has same problems ?

toolbar - Android set menu action visibility -

i have activity , fragment android.support.v7.widget.toolbar can show menu item "action" after creating menu in oncreateoptionsmenu() making visible or ? (after clicking custom button example) can show menu item "action" after creating menu in oncreateoptionsmenu() making visible or ? yes overriding onprepareoptionsmenu method : prepare screen's standard options menu displayed. called right before menu shown, every time shown. can use method efficiently enable/disable items or otherwise dynamically modify contents. make action item visible or gone below(just sample code). @override public boolean onprepareoptionsmenu(menu menu) { menuitem menuitemvadd = menu.finditem(r.id.action_vadd); if (isshowvisualadd1) { menuitemvadd.setvisible(true); } else { menuitemvadd.setvisible(false); } return super.onprepareoptionsmenu(menu); }

reporting services - Broken SSRS Linechart -

Image
i creating line chart in ssrs. problem is: need display date range set horizontal axis scalar. however, line chart not able connect each data point in sequential order. anybody had similar issues? you try sort data beforehand in dateset or try sorting via sorting tab in properties respective grouping.

android - Device goes black and Launch timeout expires -

since new android programming, not sure how write code efficiently hence reason question. creating app. basic app in app generates 10 random math questions , evaluates left right (ignoring orders of operations). e.g. 3+5/2 should equal 4 instead of 5.5. i getting error launch timeout has expired. have researched , found out because main thread doing work. how overcome this? app first alot randomizing integers, case? this code. pretty long. p.s. in display method, hrdcoded display first elements see if display. public void initanswers(string[] questiontobelooped){ for(int =0; < questiontobelooped.length; i++){ if(mathoperations.length == 2){ runningtotal = evaluateanswertwooperations(mathoperations[0], mathnumbersinintformat.get(0), mathnumbersinintformat.get(1)); }else{ int operationscounter =0; int numberscounter =1; runningtotal = mathnumbersinintformat.get(0); while(mathoperations[opera

java - Eclipse Luna -PyDev plugin- deleting it's own exe file repeatedly -

eclipse version- eclipse-java-luna-sr1a-win32-x86_64 java jdk/jre version- 1.8.0_31 python version- 2.7 i use eclipse python programming, using pydev eclipse plugin , have been close 2 years, no updates java, python or eclipseyesterday no reason eclipse crashed first time in 1-2 years. attempted restart eclipse via task bar shortcut. i received error "the item eclipse.exe shortcut refers has been changed or removed, shortcut no longer work properly. want remove shortcut?" ??? upon further inspection realized error correct, eclipse.exe in fact removed eclipse install location. "ok...", thought, computer automatically backs important data each week , last backup yesterday. restored last version of eclipse , attempted start up, time using actual .exe rather shortcut. nope, exe started, chose work space, crashed , deleted .exe... going on. i thought maybe java version might corrupted (no exit code thrown eclipse not likely) restored last version of java,

python - Django - get results of query based on many to many relationship -

given following models , array of strings via uri get, how can efficiently execute filter operation , return trail matches? class trail(models.model): ''' main model application. contains information particular trail ''' trail_name = models.charfield(max_length=150) active = models.booleanfield(default=true) date_uploaded = models.datetimefield(default=now()) owner = models.foreignkey(account, default=1) class surface(models.model): ''' many many join table map surface type many trails. trail can have many surface types. ''' type = models.charfield(max_length=50, db_column='surface_type', unique=true) trails = models.manytomanyfield(trail) class meta: ordering = ('type', ) naively, can trail models , iterate through them matches, more efficient way. i've attempted this: from django.models.db import q #list of strings result of url queryst

java - Need to show "Insufficient Funds" for negative amounts -

i need throw exception "insufficient funds" when user withdrawals more amount in initialaccountbalance (which equals 500.00). however, unsure put exception. public static void main(string[] args) { scanner in = new scanner(system.in); double initialaccountbalance = 500.00; system.out.print("enter transaction type (balance, deposit, or withdrawal): "); string transactiontype = in.nextline(); if (transactiontype.equalsignorecase("balance")){ system.out.println("balance " +initialaccountbalance); system.out.println(); } else if (transactiontype.equalsignorecase("deposit")){ system.out.println("enter deposit: "); int deposit = in.nextint(); double balance = initialaccountbalance + deposit; system.out.printf("account balance: %8.2f", balance); } else if(transactiontype.equalsignorecase("withdrawal")){ system.out.prin

c# - How can I assign a Dictionary to a combobox's Items (Display and Value Members)? -

i know how assign values query listbox's display , value members: using (sqlconnection con = new sqlconnection(reportrunnerconstsandutils.cpsconnstr)) { using (sqlcommand cmd = new sqlcommand(reportrunnerconstsandutils.selectunitsquery, con)) { cmd.commandtype = commandtype.text; using (sqldataadapter sda = new sqldataadapter(cmd)) { datatable dt = new datatable(); sda.fill(dt); ((listbox)checkedlistboxunits).datasource = dt; ((listbox)checkedlistboxunits).displaymember = "unit"; ((listbox)checkedlistboxunits).valuemember = "unit"; } } } ...and how assign single value combobox so: list<string> schedulableweeks = platypusutils.getweekbeginnings(weeks_count).tolist(); bindingsource bs = new bindingsource(); bs.datasource = schedulableweeks; comboboxweektoschedule.datasource = bs; ...but how can assign dictionary combo box, string value of dicti

nginx - what's the difference PHP-FPM , Opcache and APC -

i use nginx fast cgi cache settings , it's working great read around internet opcache , apc . don't understand difference between them , fpm , why people use them when cache fpm easier adding few sentences nginx conf . use these setting reference fastcgi_cache microcache; fastcgi_cache_key $scheme$host$request_uri$request_method; fastcgi_cache_valid 200 302 1d; fastcgi_cache_valid 400 500 504 404 1m; if can explain in details differences .

recursion - Utility to encapsulate tail-call optimisation in JavaScript? -

i've been reading recursive functions , tail call optimisation (tco) in javascript. goal overcome stack overflow in recursive function: function factorial(n) { function recur(n, acc) { if (n === 0) { return acc; } else { return recur(n - 1, n * acc); } } return recur(n, 1); } factorial(5); // 120 console.log(factorial(4585759)); // maximum call stack size exceeded i have found how use thunk , trampoline overcome stack overflow in recursive function: let thunk = function (fn) { return function() { let args = array.prototype.slice.apply(arguments); return function() { return fn.apply(this, args); }; }; }; function trampoline(f) { while (f && f instanceof function) { f = f(); } return f; } function factorial(n) { let recur = function(x, n) { if (n === 0) { return x; } else { return thunk(recur)(n * x, n - 1);

Generate a dummy json by reading a json file in Python -

i trying generate dummy json reading json file in python. there library in python this. similar https://www.npmjs.com/package/dummy-json . you can take @ faker library python. https://github.com/deepthawtz/faker you can generate usernames, emails, names, numbers , lot more.

typeahead.js - Can't return typeahead values from meteor server method back to client -

trying implement sergey-t's typeahead package on form in meteor app. the issue is, can't seem return typeahead results server client. typeahead works if make test array on client side , return via helper. also, query results logging in server console. issue cant seem them client. my js client console not showing errors, seems strange. any appreciated. html <template name="typeaheadtemplate"> <!-- <input id="entry-field" class="typeahead input-lg form-control" type="text" name="text" placeholder="paste or enter id" autocomplete="off" spellcheck="off" data-source="search"/> --> <input class="form-control typeahead" name="textentry" type="text" placeholder="paste or enter id ..." autocomplete="off" spellcheck="off" data-source="search"/> </template> js client-side code

if statement - Simple If program in Python syntax error -

num = int(input("enter number: ") if num%2 == 0: print("the number even") else: print("the number odd")enter code here i'm getting syntax error on if statement line, have searched everywhere reason why happens, can't find it, help? i'm using visual studio 2015 ide if that's help. num = int(input("enter number: ")) if num%2 == 0: print("the number even") else: print("the number odd")enter code here missing ) on line before. lots of times when syntax errors on line happens @ line or line or few lines before that, in case it's looking matching paren.

python - Expand Tkinter Frame -

i have basic application using tkinter python (3.5). want application run in full screen, , have multiple windows switch through. far have. import tkinter tk class window(tk.tk): def __init__(self): tk.tk.__init__(self) self.title("movie kiosk") self.attributes("-fullscreen", true) self.resizable(width=false, height=false) container = tk.frame(self) container.pack(side="top", fill="both", expand=1) self.frames = {} f in (startpage, pageone): frame = f(container, self) self.frames[f] = frame frame.grid(row=0, column=0, sticky="nsew") self.show_frame(startpage) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class startpage(tk.frame): def __init__(self, parent, controller): tk.frame.__init__(self, parent) label = tk.label(self, text="main page", font=("verdana",48)) label.place(relx=0.5, y=0, anchor=tk.

java - How to get BufferedInputStream from Multipart? -

Image
i'm trying bufferedinputstream uploaded cvs file. i'm working multipart derived cvs file. when first multipart, it's bufferedinputstream, buffer null. but if deeper down, there's buffer in coyoteinputstream , has data. how can @ second buffer? code below. and of course it's throwing null exception when gets while ((multipartdatapos = stream.read(buffer)) >= 0) what doing wrong? mistaken coyoteinputstream data want? public byte[] handleuploadedfile(multipart multipart) throws eofexception { multipart multipartdata = null; bufferedinputstream stream = null; int basicbuffersize = 0x2000; byte[] buffer = new byte[basicbuffersize]; int bufferpos = 0; try { while (multipart.hasnext()) { int multipartdatapos = bufferpos; multipartdata = (multipart) multipart.next(); stream = new bufferedinputstream(multipartdata.getinputstream()); while ((multipartdatap

opengl - How to use glm::project to get the coordinates of a point in world space? -

i have point (1, 2) in 2d space expressed vector: glm::vec3 pt = glm::vec3(1, 2, 0) (here set third component 0 - not sure if that's correct?) i have model-view matrix apply translation point: glm::mat4 modelview = glm::mat4(1.0f); modelview = glm::translate(modelview, glm::vec3(3.0f, 3.0f, 0.0f)); now want find actual coordinate of point in world space. did research , glm::project() seems can use this. takes in 4 parameters: detail::tvec3<t> glm::gtc::matrix_transform::project(detail::tvec3<t> const & obj, detail::tmat4x4<t> const & model, detail::tmat4x4<t> const & proj, detail::tvec4<u> const & viewport ) the first 2 parameters point , model view matrix have. should use 3rd , 4th parameters (the projection matrix , viewport vector)? how can create/get them?

ios - Swift - Return value from locationManager function in class extension -

i'm trying directions users current location destination using google maps. want done when showdirection button pressed, can't figure how return or pass users location ibaction function func locationmanager(... didupdatelocation) ibaction doesn't use parameters in can pass locvalue to. here showdirection button function: @ibaction func showdirection(sender: anyobject) { print("running showdirection") let instanceone = parseviewcontroller() // create parseviewcontroller instance operate on print("created parseview instance") let coord = instanceone.returnparse() let latitude = (coord.lat nsstring) let longitude = (coord.long nsstring) var urlstring = "http://maps.google.com/maps?" urlstring += "saddr= // users location didupdatelocation" urlstring += "&daddr= \(latitude string), \(longitude string)" print(urlstring) if let url = nsurl(string: urlstring.stringbyaddingper

Character comparison in C? -

when pass in 1 of characters specified, returns 2 if incorrect character? comparing these incorrectly? int valid_character(char character) { if (character == '*' || character == '%' || character == '#') { return 1; } else { return 2; } } edit: the problem calling function: if (selection == 1) { printf("enter character, width , length: "); scanf("%c %d %d", &c, &width, &length); putchar(c); int response = valid_character(c); if (response == 1) { draw_rectangle(width, length, c); } else { printf("%d", response); printf("invalid data provided."); } } when call putchar(c); prints out 1 though passing in % why this? you did not post whole function! had scanf before code fragment left pending \n in input stream. as found out yourself, can skip \n , other white space reading character with: scanf(" %c

apache - Magento site returns large 404 page for missing images in src elements -

in .htaccess , have this: rewriteengine on ############################################ ## can put here magento root folder ## path relative web root rewritebase / ############################################ ## workaround http authorization ## in cgi environment rewriterule .* - [e=http_authorization:%{http:authorization}] ############################################ ## send 404 on missing files in these folders rewritecond %{request_uri} !^/(media|skin|js)/ ############################################ ## never rewrite existing files, directories , links rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_filename} !-l ############################################ ## rewrite else index.php rewriterule .* index.php [l] if navigate non existent image on site, putting url browser's address bar, example www.example.com/media/catalog/non_existent_image.jpg , nice full 404 page part of site&#

php - WooCommerce Admin -> Orders | add checkbox on each product -

wasted more 12 hours getting work, without luck. found other threads here, similar questions without response. // need? i need checkbox on woocommerce admin orders view each product, if checked value yes : no should stored order_item_meta . customer can check, if ordered items shipped or not. hook in, action woocommerce_after_order_itemmeta looks correct position. // why not add meta item?? yeah right, works - wouldn't nice have checkbox this? :) // have done far?? reading lot of postings in here, 1 -> woocommerce-admin-order-details-show-custom-data-on-order-details-page . i have no clue, , how start - ended peace of code in functions.php.. <?php add_action( 'woocommerce_after_order_itemmeta', 'item_shipped', 10, 3 ); function item_shipped() { ?> <input type="checkbox" name="custom-meta-box[]" value="yes" <?php if(isset($_post['is-shipped-meta']['is_shipped'])) echo 'checked=&qu

rust - Disambiguate associated type in struct -

i trying run this use std::collections::btreeset; pub struct intoiter<t> { iter: btreeset<t>::intoiter, } fn main() {} playground this fails with error[e0223]: ambiguous associated type --> src/main.rs:4:11 | 4 | iter: btreeset<t>::intoiter, | ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type | why associated type ambiguous? "ambiguous" seems bit of misleading wording here. example produces same error message: struct foo; pub struct bar { iter: foo::baz, } fn main() {} i'm not certain, i'd find unlikely there associated type named baz in standard library, less there 2 make ambiguous! what's more syntax not specific enough. it's plausible there could be multiple traits have baz associated type. because of that, have specify trait want use associated type from: struct foo; pub struct bar { iter: <vec<u8> intoiterator>::intoiter, } fn main() {}

java - Finding .class file in Eclipse -

i need turn in .class file of class eclipse. managed turn in .java version of file clicking , dragging browser, i'm not sure find .class file. i've read can find in "bin" have no idea is. thanks help! generally, eclipse projects have following file system: proj/ .classpath .project src/ foo.java bin/ foo.class so, navigate project folder, go bin , , classes should right there. if on mac: if in project in command line (you have done cd project ) can cd bin open . and class files should show in place can drag them browser. i don't understand why need submit .class files, generated when code compiled.

java - How to move up lines in a .txt file with BufferedReader? -

making "assembler" program cs course enrolled in. has functions add, set, inc (increment), , jig. now, inputing .txt file following layout (as example): keep note: , b integer's store value throughout program, , print out value once reaches end of text file. inc (increments 1) set b 5 (set's b's value 5) inc b add 3 (add's 3 a's current value) jig b -4 (move's backward 4 lines, inc a) so confused how move bufferedreader 4 lines? there method in bufferedreader lets move index/position? otherwise, how else can accomplish this? the simplest thing store lines in array or list. list<string> lines = files.readalllines(paths.get("myfile.txt")); this allow progress line @ random. to line can use lines.get(n) example can do int pointer = 0; for(boolean running = true; running && pointer < lines.size(); ) { string line = lines.get(pointer); string[] parts = line.split(" +"); switch(p

javascript - Why Success or Error callback function not executing properly for $http.post in angularjs -

i'm trying communicate server using following code. $scope.save = function () { $scope.loading = true; if ($scope.rolesetupmodel.roleid === "") { // save //$scope.loading = true; $http.post('/securitymodule/rolesetup/addrole', json.stringify($scope.rolesetupmodel)) .success(function (response) { $scope.loading = false; $('#addmodal').modal('hide'); $scope.binddatatogrid(); alert("success"); toastr.success(response.message); }) .error(function (response) { $scope.loading = false; alert("fail"); toastr.error(response.message); }); } else { $http.post('/securitymodule/rolesetup/editrole', json.st

vbscript - Operation is not allowed when the object is closed (Object is not closed) -

the following code, generating error. set getlist = server.createobject("adodb.command") getlist.activeconnection=ev_wikiconn getlist.prepared = true getlist.commandtext= "declare @lookup table(id int identity(1, 1) , songtitle nvarchar(512) ) insert @lookup(songtitle)select * ( values ('deuce')) x(a) select a.albumname, s.songtitle , s.writers , s.vocals , s.sid , s.thetime albums inner join songs s on a.aid = s.aid inner join @lookup l on l.songtitle = s.songtitle order l.id" set rslist = getlist.execute while not rslist.eof ' error on line here. i added code here set getlist = server.createobject("adodb.command") getlist.activeconnection=ev_wikiconn getlist.prepared = true getlist.commandtext= "declare @lookup table(id int identity(1, 1) , songtitle nvarchar(512) ) insert @lookup(songtitle)select * ( values ('deuce'),('strutter'),('parasite')) x(a) select a.albumname, s.songtitle , s.writers , s.vo

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

typescript - Angular 2 - How does the directive give data to the host? -

i have think should pretty problem solve in angular 2, can't find right syntax. my goal directive following: accepts arbitrary data value. e.g., [my-data]="[1,2,3,4,5]" processes on change. e.g. onchange() { return this.data.length = 55; } . sends data host, , binds host property. i'm fine on 1), little lost on 2) , 3). far have like: @directive({ selector: ['ap-data'], host: { '(change)': 'onchange()' } }) export class datadirective { @input('ap-data') data: any; @hostbinding('attr.ap-data') dataset() { return processdata(this.data); } ... } @component({ selector: 'mycomponent', directive: [datadirective], template: ` <div [ap-data]="[1,2,3,4,5]"></div> ` }) export class mycomponent { public data: any[]; public dataset: processeddatatype; ... } for directive host binding use eventemitter : @output('ap-data-change') a

angularjs - Angular js dir-paginate with animations -

i using dir-paginate filtering , ordering.i want implement animations better ui , cant seem find reference. i aware of http://www.nganimate.org/angularjs/ng-repeat/yo-yo-css3-keyframes-animation seems work ng-repeat not dir-paginate. missing. i not using bootstrap, instead materializecss.

java - Writing your own Iterator for a LinkedList -

i have written iterator arraylist, need write 1 linkedlist. suggestions on how make code more efficient?? public class mylinkedlistiterator<t> implements iterator<t> { //the list on iterating private mylinkedlist<t> list; private int curpos; public mylinkedlistiterator(mylinkedlist<t> list) { this.list = list; curpos = 0; } @override public boolean hasnext() { return curpos < list.size(); } @override public t next() { t element = list.get(curpos); curpos++; return element; } } incase helpful, here listnode class keeps track of pointers on linkedlist public class listnode<t> { private t value; private listnode<t> next; public listnode(t value, listnode<t> next) { this.value = value; this.next = null; } public listnode(t value) { this(value, null); } public t getvalue() { return value; } public listnode<t> getnext() { return next; } public void setnext(listnod

ios - Swift 1.2: fatal error: unexpectedly found nil while unwrapping an Optional value -

i wanted click picture , display on uiimageview. i had defined needed outlets , actions , here code. but shows error. class viewcontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var camera: uibutton! @iboutlet weak var gallery: uibutton! @iboutlet weak var viewimage: uiimageview! @ibaction func photogalleryaction(sender: uibutton) { let picker = uiimagepickercontroller() picker.delegate = self picker.sourcetype = .photolibrary presentviewcontroller(picker, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { viewimage.image = info[uiimagepickercontrolleroriginalimage] as? uiimage dismissviewcontrolleranimated(true, completion: nil) } } here error: fatal error: unexpectedly found nil while unwrapping optional value

ios - NSUserActivity : indexing multiple NSUserActivities using loop -

i want index multiple nsuseractivities of same type. code same given below: -(void)createactivityforeachcity:(nsnotification *)notification { nsarray *namelist = @[@"name1",@"name2",@"name3",@"name4"]; if (namelist) { (nsstring *name in namelist) { [self createindexactivityforname:name]; } } } -(void)createindexactivityforname:(nsstring*)name { nsuseractivity *activity = [[nsuseractivity alloc]initwithactivitytype:@"spotlightsearchactivity"]; nsdictionary *activityuserinfo = @{@"name":name}; activity.userinfo = activityuserinfo; activity.title = [nsstring stringwithformat:@"you searched %@",name]; activity.eligibleforhandoff = no; activity.eligibleforsearch = yes; activity.eligibleforpublicindexing = yes; self.useractivity = activity; [activity becomecurrent]; } from above code, nsuseractivities name1, name2, name3 , nam

android - testing an unsigned apk that eventually will be signed with a system signature -

i'm developing non google play application, delivered unsigned release assembly apk device manufacturers sign own private system key signature. the system signature essential, because app uses permissions protection level signatureorsystem . since app not going installed system privileged app, must signed system's signature. since i'm not going have access final signed apk (or signing key itself) don't know how can test product i'm delivering (on real device , not emulator) since functionality depends on been signed system signature. so far, reference found is old thread discussing how sign system signature, understand - not work anymore. i understand recommended work-flow how test app behavior signed system signature on real device. with larger companies, company manufacturing device provide version of os app developer flash device has different set of recognized signing keys test with. how expect app developers able test apps if running

How to parse String as Binary and convert it to UTF-8 equivalent in Java? -

i need parse string content binary sequence , convert them utf-8 equivalent string. for example, utf-8 binary equivalents of b , a , r follows: b = 01000010 a = 01000001 r = 01010010 now, need convert string "010000100100000101010010" string "bar" i.e. above case input string 24 characters divided 3 equal parts(8 character in each part) , translated utf-8 equivalent string value. sample code: public static void main(string args[]) { string b = "01000010"; string = "01000001"; string r = "01010010"; string bar = "010000100100000101010010"; string utfequiv = toutf8(bar);//expecting "bar" system.out.println(utfequiv); } private static string toutf8(string str) { // todo return ""; } what should implementation of method toutf8(string str){} you should separate 2 problems: converting string byte array parsing binary values convertin

javascript - Converting json object to a string -

i'm generating json object follows, need iterate , fetch value inside in javascript. [object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object] and if stringify it, i'll following values, [[{"k":"43800001","d":"resident demand deposit"},{"k":"43800099","d":"not applicable"}, {"k":"43800014","d":"cash"}, {"k":"43800012","d":"income , expenditure"}, {"k":"43800011","d":"other liabilities"}, {"k":"43800010","d":"other assets"}, {"k":"43800009","d":"bankers"}, {"k":"43800008","d":"bar"}, {"

Array object to php using ajax -

how can send data php using ajax ["{"title":"mr","fname":"john","lname":"annah","oname":"clement","staffid":"123"}"] try json_encode more refer - http://php.net/manual/en/function.json-encode.php

c# - Sending a List or Array to Web Api -

i creating api method add result textfile.. app reads data text file , populate generic list of c# structure call resultlines. when testing app when inspecting request results line added boby parameters , request using restsharp comsume api.. when put breakpoint on api can see 23 lines has been recieve values null expanding model marked bold here code consume api public heatresultresponse addheatwithlist(list<resultfileline> rec,string heatnum, string webapiurl) { restclient client = new restclient(); client.baseurl = new uri(webapiurl); var request = new restrequest("controller/insertnewheatlist", method.post); request.addheader("accept", "application/form-urlencoded"); //client.addhandler("application/json", new jsondeserializer()); request.addheader("content-type", "application/json"); request.requestformat = dataformat.json; request.addpa

java - Volatile Keyword is of no use When using synchronized? -

i trying understand use of volatile keyword in java. understand write data in main memory not in thread cache. but useful. using multi threading , shouldn't using synchronized cause don't want dirty reads other threads. @ exact situation volatile can useful , important use? please give example. synchronized more expensive plain volatile . volatile useful when need read/write single variable , don't care atomicity of complex structures. synchronized useful when need perform complex operations, update several variables or set 1 variable when compared 1 , ensure atomicity of such operation. used when doing higher level synchronization such conditions, i.e. synchronized / wait / notify in java. lock / condition can used too.

python - How to nicely handle [:-0] slicing? -

in implementing autocorrelation function have term like for k in range(start,n): c[k] = np.sum(f[:-k] * f[k:])/(n-k) now works fine if start = 1 i'd handle nicely start @ 0 case without conditional. obviously doesn't work because f[:-0] == f[:0] , returns empty array, while i'd want full array in case. don't use negative indices in case f[:len(f)-k] for k == 0 returns whole array. other positive k it's equivalent f[:-k]

rx java - Converting RxJava to RxScala -

is there way use both rxjava , rxscala in 1 project? import rx.lang.scala.{observable => scalaobservable} import rx.{observable => javaobservable} we have module written in java using javaobservable ( rxjava ). , have scala module supposed use java module written in scala. are there convenient methods transform these other? yes, possible using conversion functions such tojavaobservable , toscalaobservable , etc in rx.lang.scala.javaconversions . you can either write conversion explicitly (eg tojavaobservable(myscalaobservable) , or if enable implicit conversions , import rx.lang.scala.javaconversions._ , inserted automatically compiler whenever java observable expected, scala observable found, , vice versa.

signalr - Setting up Signal R in Android: Crash/Hung Issue -

i followed this tutorial set .net backend android app implement signal r. set signalr self-hosted backend. here's backend code in console project: namespace signalrselfhost { class program { static void main(string[] args) { // *only* bind localhost, if want bind addresses // use http://*:8080 bind addresses. // see http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx // more information. string url = "http://localhost:8080"; using (webapp.start(url)) { console.writeline("server running on {0}", url); console.readline(); } } } class startup { public void configuration(iappbuilder app) { app.usecors(corsoptions.allowall); app.mapsignalr(); } } public class messagehub : hub { public static event action

javascript - How can I use defined key in another key/value pair -

i have javascript object: return { accdocs: { query: function() { ... }, deleteandquery: function() { ... accdocs.query(); //error: accdocs not defined } } } but, returns error says accdocs not defined . how can achieve this? variables , properties on objects different things. cannot access property of object without specifying object mean. you can probably access using this keyword: this.query(); keeping in mind value of this vary depending on how function called (when a.b.c.d.accdocs.deleteandquery() called, this inside deleteandquery accdocs first object left of last . , if first copy query variable , call query() , pass settimeout , or if use call or apply value of this change). for more robustness (but less flexibility, since being able change context can useful) can store object in variable can access name. var accdocs = { query: function() { ... }, deleteandqu

python - Is Google Encrypted BigQuery capable of querying encrypted data using LIKE operator? -

i have been doing research on implement operator onto query encrypted data. wondering if google's encrypted bigquery has functionality implemented? tl;dr yes, after fashion (or, no, if want 'full power' of like). you cannot straight query on arbitrarily encrypted string, because there's no way of running comparisons on arbitrarily encrypted strings. you'd need have decryption ran server side, applied. like: ... decrypt(field, key) '%search%' which in case can't done since encryption run in connector, need retrieve all rows, decrypt them all, , run check. in cases possible use on encrypted, if use special (weaker) encryption maps symbols in deterministic way, e.g. "a" converted "f" (or other calculable-at-runtime value) whatever position. means encrypted search key, minus modifier (e.g. %), present in encrypted field. if holds, instead of searching 'attack' in field that, unencrypted, 'attack @ daw

wordpress - PHP include only on homepage URL -

i need include external php file on homepage of website. but, since pages on site use same page template (homepage template), cant filter them based on wondering there way include php file on homepage url (which www.domain.com/folder) , not show on other page (for example www.domain.com/folder/lorem). i tried using snippet in header.php file: <?php if ($_server['php_self'] = '/') include('some-file.php'); ?> and file gets included on other pages well. i php newbie sorry if stupid question :) update: did changed <?php if ($_server['php_self'] == '/') include('some-file.php'); ?> and still isnt showing up. you can use wordpress's is_front_page() function check. thus, code should be: <?php // if code not work, adding next line should make work <?php wp_reset_query(); ?> if ( is_front_page() ) { include('some-file.php'); } ?> source: https:/

android - Get storage type of local path -

if have paths following: /storage/emulated/0/... /storage/usbdrivea/... /sdcard/... i have following questions: how find out storage located on? (usb stick, external storage, internal storage) how find out type are? (primary storage (i have direct r/w access), secondary storage (on android >=4.4, don't have direct w access , need acquire right through storage access framework if need it)) how find out root path is? results want this is: internal storage, primary storage, root path /storage/emulated/0/ this is: usb stick, secondary storage, root path /storage/usbdrivea/ this is: external storage, secondary storage, root path /sdcard/ i know paths may vary phone phone, how find out path located on storage , permissions have on paths? know can guess names of path, i'm interested in reliable way works on (or @ least on most) phones... you need check access every primary , secondary storage through environment class. should this: boolean ca

html - Cell padding affected by contained ASP NET image -

Image
i have asp net image contained within html table cell, reason there seems padding @ bottom of cell. i have tried number of things, no luck: removing css padding. removing right hand "logged in" cell check isn't influencing other cell. adjusting size of source image. padding stays 3px high. <td style="width:200px; vertical-align:top;"> <table class="customtable" style="width:100%; table-layout: fixed"> <tr style=" padding:0px;"> <td style="width:48px; padding:0px;"> <asp:image id="imguser" runat="server" imageurl="~/media/user_anon.png" cssclass="userimage" /> </td> <td class="customcell"> <asp:label id="lbluser" runat="server" text="label">logged in</asp:label>

Could anyone recommend some practices to debug webpack productivity? -

i fill i'm doing wrong webpack, because takes time make build. i'll not ask review whole webpack config , find problem place me, if recommend some practices test productivity nice. only 1 thing found on net half-finished article build-performance upd : how optimize webpack's build time using prefetchplugin & analyse tool? (credits @daniel-protopopov)

tfsbuild - TFS 2015 Build vNext recursive variable substitution -

is possible variable substitution not recursive? example1: variable value sqlinstance (localdb)\mssqllocaldb dbcatalogname foodb connstr data source=$(sqlinstance);initial catalog=$(dbcatalogname)$(build.buildid); during build connection string substituted to: data source=(localdb)\mssqllocaldb;initial catalog=foodb3211; this configuration works perfectly. if move buildid parameter dbcatalogname variable won't substituted. example2: variable value sqlinstance (localdb)\mssqllocaldb dbcatalogname foodb$(build.buildid) connstr data source=$(sqlinstance);initial catalog=$(dbcatalogname); with configuration connection string substituted to: data source=(localdb)\mssqllocaldb;initial catalog=foodb$(build.buildid); so how can chain variables vnext? if want "dbcatalogname" variable contain buildid value, recommend add additional power-shell build step set value of "dbcatalogname".

linux - Weblogic: limit access to certain resources (URIs) by IP -

community. is possible limit access uris (say /myapp/admin/*) based on requester ip on weblogic server? i'd allow access trusted machines in local network , deny others regarding specific uris. other application locations should accessible everyone. the question is, whether achievable without development of separate filter class? i found in apache "location" directive, sadly no similar stuff in weblogic. thanks.

asp.net - Compiling 32bit app on 64bit machine -

Image
i want convert 32bit application 64bit compile , keep working on on 64bit machine. how can done? to compile @ 64bit: inside visual studio go build > configuration manager then can specify cpu selecting platform column , choosing between x86 , x64. then can explicitly compile @ 64bit. that said any cpu should enough keep working on it. carry around 64bit, buildserver can output projects either 32bit or 64bit depenedent on release template. also dependent on visual studio version, there prefer 32bit flag may of use dependent on exact requirements.

node.js - node express order routes -

i have routes setup that: app.use('/', index); app.use('/auth', auth); app.use(requesthandlers.authorize); app.post('/users', users); // catch 404 , forward error handler app.use(requesthandlers.notfound); my handlers: export function authorize(req: request, res: response, next: function) { // check header or url parameters or post parameters token var token = req.body.token || req.query.token || req.headers['x-access-token']; //token logic }; export function notfound(req: request, res: response, next: function) { var err: = new error('not found'); err.status = 404; next(err); } so have no problems handle defined routes when accessing not existed routes requesthandlers.authorize getting executed first. if route not existed want fire app.use(requesthandlers.notfound); how can that? best approach without putting custom logic on routes? may there way check if route defined? when app.use(f

java - What's the proper way to create a DB with MapDB? -

i have use mapdb java project im familiar mysql. im litte confused creation of db. db should contain user information , posts user , comments on posts , other similarities. how should create db make work mysql db? here documentation. use dbmaker factory: http://www.mapdb.org/doc/getting-started.html#hello-world http://www.mapdb.org/doc/db-and-dbmaker.html

android - java.lang.RuntimeException: An error occured while executing doInBackground() in Popmovie app -

i beginner in android development . trying make movies app got error . here code public class moviefragment extends fragment { public moviefragment() { } // arrayadapter<string> movieadapter; movieadapter movieadapter; gridview gridview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //add line in order fragment handle menu events. sethasoptionsmenu(true); } @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { // inflate menu; adds items action bar if present. inflater.inflate(r.menu.moviefragment, menu); } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection sim