Posts

c# - Return json without binding it to object using web client -

i want return jsonresult in c# online api service (itunes). wanting go out data in json format , return exact data in same json format can play in javascript. here have: public jsonresult index() { using (var client = new webclient()) { var json = client.downloadstring("https://itunes.apple.com/lookup?id=909253"); return json; } } i noticing can't return json because string. don't want bind model!!! want return json object how got it. change method signature return string instead of jsonresult object… public string index() { using (var client = new webclient()) { return client.downloadstring("https://itunes.apple.com/lookup?id=909253"); } }

python - Error while calculating math.sqrt -

this question has answer here: list of lists changes reflected across sublists unexpectedly 13 answers i faced strange error, , wasted 2 hours on it, couldn't come explanation import math ipd={1:[2,3],2:[1],3:[1],4:[5,6,7],5:[4,6],6:[4,5],7:[4]} gkeys = [k k in ipd.iterkeys()] key_map = {} x in range(len(gkeys)): key_map[x] = gkeys[x] val = len(gkeys) #adj matrix... w = [[0.0]*val]*val print w in range(len(gkeys)): j in range(len(gkeys)): #if , j has edge... if key_map[j] in ipd[key_map[i]]: deg1 = len(ipd[key_map[j]]) deg2 = len(ipd[key_map[i]]) v = 1.0/math.sqrt(deg1*deg2) w[i][j] = v print i,j,deg1,deg2,w[i][j], w[j][i] here whole problem for i=3 , j=5 first w[i][j] 0.4248.. i=5, , j...

recursion - Is this a bug? (recursive constructors in Java) -

i've been playing recursive constructors in java. following class accepted compiler 2 examples of recursive constructors in java. crashes stackoverflowerror @ runtime using java 1.7.0_25 , eclipse juno (version: juno service release 2 build id: 20130225-0426). class mylist<x> { public x hd; public mylist<x> tl; public mylist(){ this.hd = null; this.tl = new mylist<x>(); } } the error message makes sense, i'm wondering if compiler should catch it. counterexample might list of integers constructor takes int argument , sets this.tl null if argument less zero. seems reasonable allow in same way recursive methods allowed, on other hand think constructors ought terminate. should constructor allowed call itself? so i'm asking higher authority before submitting java bug report. edit: i'm advocating simple check, prohibiting constructor calling or whatever java developers did address https://bugs.openjdk.java.net/br...

php - How to process bulk actions out of WP_List_Table class in Wordpress -

i'm extending wp_list_table in wordpress in plugin. i'm using example here: http://wordpress.org/plugins/custom-list-table-example/ base i'm doing. now, in example documentation says can process bulk actions wherever want, haven't found example shows how that. specifically want process them in admin_action{$action} hook, , redirect table page. is smart thing do? important, how can it? can provide example? bulk action can implemented overwriting method get_bulk_actions() , returning associated array: function get_bulk_actions() { $actions = array( 'delete' => 'delete' ); return $actions; } you can find full details step step guide here edited to process bulk action, yes can use admin_action{$action} hook. if using simple action name(like edit, delete) thing need make sure is, put request verification code determine if request or not. way prevent interference name action prefixed plugin name (my_aswam_plugin_edi...

jquery - Scroll Background Relative to Page -

this first time on stack overflow, apologize if question bit verbose. have bit of quandary: i want create parallax-scrolling effect background image (the height of larger of window) scrolls in direct relationship progress on page. for example, when you've scrolled 25% of way down page, background image should have scrolled 25%. , when you've scrolled bottom of page (100%), background image should have scrolled bottom (100%). with parallax effect, background image still scroll, wouldn't tile or need stretched. however, current code (show below), background does scroll @ slower rate content on page; reaches bottom of background , starts tiling. i feel i'm missing mathematically. ideas? here's jquery i'm using: note: background image has height of 1200px $(window).scroll(function() { var x = $(this).scrolltop(); /* scroll position */ var y = $('html').height(); /* height of page */ var z = x / y; /* progress of current positi...

ios - How to add a < Back button to a navigation bar? -

i have simple app push views navigation. however, on 1 of screens push tab controller 2 tabs. when navigation goes away when reach tab controller screen. on navigation of tab screens know how < back button. basically, want know how manually create < back button on top left try this: uibarbuttonitem *backbarbutton = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"icon_back.png"] style:uibarbuttonitemstyleplain target:self action:@selector(goback:)]; self.navigationitem.leftbarbuttonitem = backbarbutton; then write goback method: - (void)goback:(id)sender { [self.navigationcontroller popviewcontrolleranimated:yes]; } note: there other initializer uibarbuttonitem. choose 1 need. hope helps.. :)

java - Eclipse: Getting error when adding external class / jar files to build path: "XYZ Cannot be resolved to a type" -

Image
i working java , eclipse, both bit out of comfort zone (yup , assignment...). i have 2 class files need use in project. far have tried: attempt #1 i tried adding external class folder : in project folder have added classes\legacy folder. in properties > java build path > libraries clicked on add external class folder in window opened selected classes folder created in step 1. in code have added import legacy.*; result: can use classes in class files getting following errors: (seems occur when classes attempting use 1 another) the project not built since build path incomplete. cannot find class file ishkesher. fix build path try building project the type ishkesher cannot resolved. indirectly referenced required .class files note: tried class folder - same results. attempt #2 someone suggested using jar files should easier, gave try: created jar file containing class files: jar cvf classes.jar contactslist.class ishkesher.c...