Posts

Showing posts from July, 2010

asp.net - Google plus API get the Activities List in C#.net librarry -

i'm using .net google plus api , want list of activities of specified profile(page/user..). i have code online var provider = new nativeapplicationclient(googleauthenticationserver.description); provider.clientidentifier = googleidentifier; provider.clientsecret = googlesecret; activitiesresource.collection collection = new activitiesresource.collection(); var service = new plusservice(); service.key = googlekey; activitiesresource.listrequest list = service.activities.list(profileid, collection); activityfeed activityfeed = list.fetch(); int count = activityfeed.items.count; on line: activityfeed activityfeed = list.fetch(); i following error: an item same key has been added. the requested keys invalid. put right clientsecret & clientidentifier.

php - Error on $.post of Form -

i trying submit form using jquery php page. following error when try run script chrome: uncaught syntaxerror: unexpected token ; jquery-latest.js;614 line 614 part of globaleval function. globaleval: function( data ) { if ( data && rnotwhite.test( data ) ) { // use execscript on internet explorer // use anonymous function context window // rather jquery in firefox ( window.execscript || function( data ) { window[ "eval" ].call( window, data ); // **** uncaught syntaxerror: unexpected token ; **** // } )( data ); } }, this code form , jquery submit. <div class="container create-event"> <form name="new-event" method="post" id="new-event"> name of event: <input type="text" name="event-name"></br> date of event: <input type="date" name="date"></br> location of event: <input type="text" name="location"></br> description:...

jquery function not working in Safari? -

i have following functions not working in safari pc or mac: var $j = jquery.noconflict(); $j(document).ready(function(){ $j(".wpp_search_button.submit:eq(0)").click(function(){ _gaq.push(['_trackevent', 'search', 'header search', '', 1]); }); }); $j(document).ready(function(){ $j(".wpp_search_button.submit:eq(1)").click(function(){ _gaq.push(['_trackevent', 'search', 'body search', '', 1]); }); }); it supposed track onclick searches in site, doen't. suggestion? my suggestion try , bind mousedown see if fixes issue: $j(".wpp_search_button.submit:eq(0)").mousedown(function(){ _gaq.push(['_trackevent', 'search', 'header search', '', 1]); }); $j(".wpp_search_button.submit:eq(0)").mousedown(function(){ _gaq.push(['_trackevent', 'search', 'header search', '', 1]); });

c++ - Is it possible to use lower_bound() to binary search a plain array of structs? -

i have in memory array of 16 byte wide entries. each entry consists of 2 64 bit integer fields. entries in sorted order based upon numerical value of first 64 bit integer of each entry. possible binary search stl without first loading data std::vector? i have seen can use stl lower_bound() method on plain arrays, need ignore second 64 bit field of eachy entry. possible? you don't need use std::vector<> , easiest if data proper data type first: #include <cstdint> struct mystruct { std::int64_t first, second; }; your question unclear way you're storing data now, i'm assuming it's above. then can either overload operator< data type: #include <algorithm> bool operator <(mystruct const& ms, std::int64_t const i) { return ms.first < i; } int main() { mystruct mss[10] = { /*populate somehow*/ }; std::int64_t search_for = /*value*/; mystruct* found = std::lower_bound(mss, mss + 10, search_for); } or can define custom comparator , pass ...

Encoding url in php to prevent direct access -

there 3 steps user registration on site , right urls similar to: http://www.example.com/register.php http://www.example.com/registerstep2.php http://www.example.com/registerstep3.php i wondering easy way encode like: http://www.example.com/w^3434sd343f232gihmsdsdwre232 the reason trying this, trying ensure users follow steps , don't try 'trick' system directly going registration link 3 example. this bad bad bad idea . instead of trying hide url through simple obfuscation, check @ top of script see if can proceed. in other words, each time go page, check see if submitted previous page's info. if haven't, send them back . example: if ( !functionthatchecksandreturnsbool() ) { header("location http://www.example.com/register.php"); exit; }

c++ - Is this too specific to refactor with loops? -

is code in function specific refactor loops? there's no algorithm can think of accurately reproduce required result. bool mouse::createdefaultimage() { if(_defaultimage != nullptr) return false; const int depth = 32; const int width = 11; const int height = 19; _defaultimage = create_bitmap_ex(depth, width, height); if(_defaultimage == nullptr) return false; const int black = 0x000000; const int white = 0xffffff; const int pink = 0xff00ff; //color bitmap transparent clear_to_color(_defaultimage, pink); //only color areas not transparent. //each block row of pixels. /************************************************************************ * should produce result * = black; 0 = white; - = pink * * *---------- * * **--------- * * *0*-------- * * *00*------- * * *000*------ * * *0000*----- * * *00000*---- * * *000000*--- * * *0000000*-- * * *00000000*- * * *00000***** * * *00*00*---- * * *0*-*00*--- * * **--*00*--- * * *----*00*-- * * -----*00*-- * * ------*00*- * * ------*00*- * * -...

javascript - jquery appendTo multiple items to one container -

i'm having issues getting work. when @ html in firebug shows there 2 objects inside container 1 img shows! i have simple code: var img1 = $("<img />", {src : "myimg.png" }); var img2 = $("<img />", {src : "myimg2.png" }); img1.appendto("#div"); img2.appendto("#div"); <div id="div"></div> but first image show, if comment out first appendto second image show, or if reverse order 2nd show , not first. this isn't related appendto #div , images sizes. strange.

multithreading - android, error when create a thread in onCreate() -

i want long operation (like copying/loading file) when application created. created thread so, thread not update ui. got error saying cannot create handler in thread without calling looper.prepare(). what's wrong code? public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); threadfilemanager = new thread ( new runnable() { public void run() { filemanager fm = new filemanager(); fm.copyfilefromassettostorage(); } }); threadfilemanager.start(); } edit:the error lied in filemanager class, when subclass of activity. changing service worked. the application class wrong place this. if want, it's acceptable use application 's oncreate() method start service . should implement background thread in service , purpose of service things in background. application class should seldom used. it's last resort maintaining minimal amounts of global state. once move code service , looper.prepare() have been called a...

Best way to monitor rails mailer activity -

i have mailer(triggered rake task) sends deals users based on few different factors (gender, location, age ect). everything working great need way monitor , report how many emails sent out report our customers. whats best way monitor email activity in rails app? thanks you should use observer. the answer how use here: how create mailer observer

version control - How would I maintain a large amount of code used in two different programs (using git)? -

let's have lot of javascript code deployed inside desktop application , used web application (deployed server). the method obvious me have desktop application pull source code when builds. is there better way handle this? take @ git submodules. treat js shared library , include submodule in both web , desktop applications. http://git-scm.com/book/en/git-tools-submodules

Error in libSVM Python interface -

i called model = svm_model(svm_problem(prob_y, prob_x), svm_param) but error: traceback (most recent call last): file "./multiprob.py", line 267, in <module> main() file "./multiprob.py", line 226, in main train_x, train_y, test_x, test_y, param, outfile) file "./multiprob.py", line 89, in testing model[i,j]=base_train(cls_x[i], cls_x[j], param) file "/data/svm/svmprob-1.2/svmplatt.py", line 15, in svmplatttrain model = svm_model(svm_problem(prob_y, prob_x), svm_param) typeerror: __init__() takes 1 argument (3 given) i view code in /usr/lib64/python2.6/site-packages/libsvm/svm.py class svm_model(structure): >---_names = ['param', 'nr_class', 'l', 'sv', 'sv_coef', 'rho', >--->--->---'proba', 'probb', 'label', 'nsv', 'free_sv'] >---_types = [svm_parameter, c_int, c_int, pointer(pointer(svm_node)), >--->--->---pointer(pointer(...

Export a Local Html form data to CSV using Javascript or VBscript -

i have created html form used local computer , want form data saved in csv file. each time form submitted, should add line in csv file. this needs run locally cannot use php or jsp. any or idea appreciated. i assume ie-only question (vbscript). if so, can use activexobject called filesystemobject. javascript: csv=[]; // collect form values array. function savefile(csv){ var fso,ostream; fso=new activexobject('scripting.filesystemobject'); ostream=fso.opentextfile('absolute_file_path',8,true); ostream.writeline(csv.join(',')); ostream.close(); return; } function readfile(path){ var fso,istream,n,csv=[]; fso=new activexobject('scripting.filesystemobject'); istream=fso.opentextfile(path,1,true); for(n=0;!istream.atendofstream;n++){ csv[n]=istream.readline().split(','); } istream.close(); return csv; } you can read more filesystemobject in msdn .

c# - Fetching time entries from Freckle API -

i want time entries of freckle using api specific dates, either 404 - not found , when change formation of url generates 406 - not acceptable. and when want access them without using date filter works fine . uri sending date filter is: string dfilter = @"\ -data'search[from]=2012-07-05'"; string uri = @"https://apitest.letsfreckle.com/api/entries.xml"+dfilter; webrequest = (httpwebrequest)webrequest.create(uri); webrequest.headers.add("x-freckletoken:lx3gi6pxdjtjn57afp8c2bv1me7g89j"); webrequest.method = "get"; webresponse webresponse = webrequest.getresponse(); streamreader sr = new streamreader(webresponse.getresponsestream()); responsexml = sr.readtoend(); can tell me how use date filter correctly? documentation of api can found at: documentation thanks in advance. i think problem you're including filter in url using space , command line options part of curl command. the documentation shows things like: curl -g -h ...

php - Simple_XML Class: Getting attribute and information on the info node -

i pulling out information using ann api. used simplexml class information. function explodetest() { $result = $this->_restgenerator($this->ann, '6236'); //print_r($result); foreach ($result->anime $data) { print_r($data->info); } } _restgenerator function: function _restgenerator($url,$q) { $url = $url . strtolower($q); if(strlen($q) > 0) { $q = file_get_contents($url); //$q = simplexml_load_file($url) return simplexml_load_string($q); } } constants: $this->ann = 'http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime='; when run function, : simplexmlelement object ( [@attributes] => array ( [gid] => 3506750509 [type] => picture [src] => http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/a6236-259.jpg ) ) but actual xml tag displayed this: <anime id="6236" gid="1601610894" type="tv" name="gintama" precision="tv" generated-on="2012-07-07t04:58:39z"> <...

iphone - pan gesture cause crash in subview? -

i create project single view application initial viewcontroller; add subviewcontroller project. uiimageview pan gesture added in both of view controllers. works in viewcontroller.m, when added subviewcontroller , subview added subview view controller, program crash "exc_bad_access".. anyone has solution? here code: viewcontroller.m #import "viewcontroller.h" #import "subviewcontroller.h" //#define sub @interface viewcontroller () @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; #ifdef sub subviewcontroller *sb = [[subviewcontroller alloc] init]; [self.view addsubview:sb.view]; #else uiimageview* img_ = [[uiimageview alloc]initwithimage:[uiimage imagenamed:@"monkey_1.png"]]; img_.userinteractionenabled = yes; uipangesturerecognizer *stamppangesture = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlepan:)]; [stamppangesture setminimumnumberoftouches:1]; [stamppangesture setmaximumnumbero...

Django-nonrel: Syntax to Reset an App -

to reset app, ran this: ./manage.py reset node it giving me error output: warning:root:the rdbms api not available because mysqldb library not loaded. traceback (most recent call last): file "./manage.py", line 11, in <module> execute_manager(settings) file "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 438, in execute_manager utility.execute() file "/home/a/mywebsites/django/seperolinux/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) file "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) file "/home/a/mywebsites/django/seperolinux/django/core/management/base.py", line 286, in handle app_output = ...

java - Eclipse-generated method parameters having unreasonable names -

i running in problem when use eclipse function add/generate methods of interface want implement parameter names of these methods "too generic". so, if string parameter named paramstring, if int called paramint , forth - instead of being called expresses parameters' semantics. for instance, implementing javax.portlet.portletsession interface (part of jsr 286 spec.; need custom implementation). methods carry parameters these: public void setattribute(string paramstring, object paramobject) public void setattribute(string paramstring, object paramobject, int paramint) what have sth this: public void setattribute(string key, object value) public void setattribute(string key, object value, int scope) sometimes generation of methods works way want, sometimes, time, doesn't. assume has way import library holding interface want implement, maybe can explain behavior in bit more detail? maybe can give explaination along concrete example: how have import jsr 286 spec, h...

c# - Drop Down List unexpected behaviour -

i have unexpected behaviour asp.net web forms dropdownlist. adding listitems drop down list, , looks well. except value in ddl (which in case id) never set, replaced text listitem. <asp:dropdownlist id="ddl1" runat="server"> </asp:dropdownlist> private void populate() { list<listitem> list = new list<listitem>(); foreach (var item in getitems()) { list.add(new listitem(item.name, item.id.tostring())); //in drop down list listitem.value being replaced //by listitem.text when added ddl } ddl1.datasource = list; ddl1.databind(); ddl1.items.add(new listitem("make selection")); } private list<stuff> getitems() { list<stuff> list = new list<stuff>(); list.add(new stuff{ name = "bill", id = 1}); list.add(new stuff{ name = "james", id = 2}); return list; } private struct stuff { public string name; public int id; } any ideas if meant happen? , if how store both name , id in ddl? in populate metho...

swing - Java GUI - displaying text in a new window from another method -

i have following interface structure: frame in can browse , choose files (in class file), when press button reads files (in separate class file) , sends them processing (in class file, 3rd). processing irrelevant question. when press processing button mentioned before, new window (frame) launches. in window have textarea in want display console output while processing takes place, , text. the method draws second frame located in 3rd class file, processing one, following: public static void drawscenario(){ final jpanel mainpanel2 = new jpanel(); jpanel firstline = new jpanel(); jpanel secline = new jpanel(); mainpanel2.setlayout(new boxlayout(mainpanel2, boxlayout.y_axis)); mainpanel2.setborder(new emptyborder(new insets(5, 5, 5, 5))); mainpanel2.add(box.createverticalglue()); firstline.setlayout(new boxlayout(firstline, boxlayout.x_axis)); firstline.setborder(new emptyborder(new insets(5, 5, 5, 5))); firstline.add(box.createverticalglue()); secline.setlayout(new boxlayout(secline, ...

compiler construction - Why old android phone cannot run new api app? -

it silly question, don't understand why. code compiled bytecode , should able ran in dalvik vm. while api changes, bytecode dalvik vm understands should more or less same. because app not bundle android framework. framework code resides on device. that's why use newer api in older android versions, you'll have include support library in apk. the android.jar file included in build path code compile not exported apk. if exported, every app on device have bundle android framework, lead unnecessary bloat, nothing security implications.

Facebook Graph API FQL returning less results than expected -

i'm trying pages friends using fql multiquery: { "query1": "select uid2 friend uid1 = me()", "query2": "select uid, page_id, type page_fan uid in (select uid2 #query1)", "query3": "select page_id, name, categories, type, page_url, pic_big page page_id in (select page_id #query2)" }​ the query works fine , returns results. however, returns around 2940 pages 260 people, way less sum of actual count people queried. i considered permission problem , asked 1 of people on list remove "access likes, interests..." permissions friends' applications. on next run, pages , likes weren't on json returned, page count increased 10 or 20 records. am doing wrong here? i'm using multiquery performance reasons. this occurs both using graph api explorer , php sdk: $fql = urlencode($fqlquery); $response = $facebook->api("/fql?q={$fql}"); any thoughts on problem? thanks in advance :) there addit...

C# Join 2 Numbers (INT) into 1 longer INT -

it might quite funny didn't know how search find answer one. i use when want join strings "string = "something" + "somethingelse" " but how int? :) random r = new random(); int lvfirst = r.next(485924948); int lvsecond = r.next(39); int lvdone = lvfirst + lvsecond; globals.globalint = lvdone; i tried doing 1 long int doesn't seem work says long if can me how join 2 random numbers 1? need 1 random number max "48592494839" thanks lot! there 2 problems code: "sticking together" 2 outputs of next not give random value in target range. math not work strings. instead of returning result stores in global variable. if want value in range specify, use var result = (long) (r.nextdouble() * 48592494839); this still not work any target range, comfortably meet specific requirements.

audio - Android - Playing multiple sounds sequencially -

i need run many small sounds while activity running. files plays every fixed time interval (ex. 5 seconds) files played in sequence when 1 finishes next starts (ex. sound1, sound2, sound3) when screen touched. total sounds around 35 short mp3 files (max 3 seconds). what best way implement this? thanks soundpool commonly used play multiple short sounds. load sounds in oncreate(), storing positions in hashmap. creating soundpool public static final int sound_1 = 1; public static final int sound_2 = 2; soundpool msoundpool; hashmap<integer, integer> mhashmap; @override public void oncreate(bundle savedinstancestate){ msoundpool = new soundpool(2, audiomanager.stream_music, 100); msoundmap = new hashmap<integer, integer>(); if(msoundpool != null){ msoundmap.put(sound_1, msoundpool.load(this, r.raw.sound1, 1)); msoundmap.put(sound_2, msoundpool.load(this, r.raw.sound2, 1)); } } then when need play sound, simple call playsound() constant value of sound. /* *call func...

c# - How to Resize Image and save in folder? -

i tried this: string str = system.io.path.getfilename(txtimage.text); string pth = system.io.directory.getcurrentdirectory() + "\\subject"; string fullpath = pth + "\\" + str; image newimage = clsimage.resizeimage(fullpath, 130, 140, true); newimage.save(fullpath, imageformat.jpeg); public static image resizeimage(string file, int width, int height, bool onlyresizeifwider) { if (file.exists(file) == false) return null; try { using (image image = image.fromfile(file)) { // prevent using images internal thumbnail image.rotateflip(rotatefliptype.rotate180flipnone); image.rotateflip(rotatefliptype.rotate180flipnone); if (onlyresizeifwider == true) { if (image.width <= width) { width = image.width; } } int newheight = image.height * width / image.width; if (newheight > height) { // resize height instead width = image.width * height / image.height; newheight = height; } image newimage = image.getthumbnailimage(width, newheight, null, intptr.zero); return newimag...

How to prefix http to multiple columns' url input from users in Rails? -

this question has answered question single column how do multiple columns? i've got 3 columns (website, fb, twitter) want prefix http in case users don't input them in form. i tried doesn't work: before_save :sanitize_links private def sanitize_links website = self.website facebook = self.facebook twitter = self.twitter links = [website, facebook, twitter] links.each |link| unless link.include?("http://") || link.include?("https://") link = "http://" + link end end end update i've tried suggestion kl-7 unfortunately hit little snag. how use output of array before_save ? i've tried code below doesn't work. before_save :sanitize_links private def sanitize_links links = ["website", "facebook", "twitter"] links.map! { |link| self.link =~ %r{\ahttps?://} ? self.link : "http://" + self.link } end update 2 i gave up. i'll repeat 3 times: before_save :sanitize_links private def sanitiz...