Posts

Showing posts from 2010

Draw multiple line in jqplot using json Data -

iam trying draw multiple line in jqplot using json data have doubt on jqplot, using json data plot chart in jqplot.i have 2 sets of json data this var jsondata1 = {"priceticks": [{"price":5.5,"tickdate":"jan"}, {"price":6.8,"tickdate":"mar"}, {"price":1.9,"tickdate":"june"}, {"price":7.1,"tickdate":"dec"}]}; var jsondata2 = {"priceticks": [{"price":1.5,"tickdate":"jan"}, {"price":2.8,"tickdate":"feb"}, {"price":3.9,"tickdate":"apr"}, {"price":9.1,"tickdate":"dec"}]}; suppose have javas...

oracle - Creat view with a avg column -

i need create view view uos_vu_student_average, 1 of column requries average grade, sql: create view uos_vu_student_average select student.first_name, student.last_name, student_module.grade student, student_module student_id<120000001 how avg grade in sql? you have use "group by" mathematical function avg ( [ | distinct ] expression ) for example .. select id, avg(salary) tablename group filedname

jdbc error java class trying to connect to linux mysql server -

my error! dbconnection2.java:38: unreported exception java.lang.instantiationexception; must caught or declared thrown class.forname("com.mysql.jdbc.driver").newinstance(); problem: .newinstance(); my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.lang.*; import java.util.*; import java.sql.*; import java.util.stringtokenizer; public class dbconnection2 { string url = "jdbc:mysql://<myserver>/<mydatabase>"; java.sql.connection con = null; string query1; statement stmt; public dbconnection2() { try { //***error here***** class.forname("com.mysql.jdbc.driver").newinstance(); //***error here***** } catch(java.lang.classnotfoundexception e) { system.err.println(e.getmessage()); } try { ...

c# - I have php client and i want to pass encrypted email string from PHP client to wcf service , which encryption technique is best? -

i have php client , want pass encrypted email string php client wcf service , encryption technique best ? what best way encrypt/decrypt data in uniform way ? *there other client in future instead of sending home-brewn encryption on plain http , should use standards exist, namely https .

python - Is there a way to manage authentication for web services with Flask? -

i trying use flask in order provide http based web-services android application. have found flask-login easiest way manage authentication seems oriented template based web application. is there solution web-service based authentication? flask-login solution. can add next decorator views: def login_required(): def wrapper(fn): @wraps(fn) def decorated_view(*args, **kwargs): if not current_user.is_authenticated(): abort(401) # return jsonify(status='logged_off') return fn(*args, **kwargs) return decorated_view return wrapper so if user don't authorized view login_required decorator return 401 unauthorized response (or valid response custom message if want).

How do I get a random number to stay fixed with slick? -

i'm beginner in java slick tools. want make game has different coloured cubes randomly placed within area of window. i use 2 for-loops , call random number in render. cubes placed want, problems flicker in colours. guess has how call random number , gets updated fps?! please me!! public void render(gamecontainer gc, statebasedgame sdg, graphics g) throws slickexception { //set background image background = (new image("res/background.png")).getscaledcopy(800, 500); g.drawimage(background, 0, 0); //set gamescape blue = (new image("res/blue.png")).getscaledcopy(20,20); green = (new image("res/green.png")).getscaledcopy(20,20); red = (new image("res/red.png")).getscaledcopy(20,20); int xvalue = 300; int yvalue = 400; (int = 1; < 20; a++) { (int = 1; < 10; i++) { r = rand.nextint(3); if(r==0){g.drawimage(blue,xvalue,yvalue);} else if(...

button - Declare Global Variable inside a Button1_Click -

i tried google abit could'nt find useful. in form1_load have variable dim myvariable string then in button click want myvariable = "hello" problem code tells me myvariable in button_click not declared is. thanks help. move variable field or property in form class. here example code: public class form1 private myvariable private sub form1_load(sender system.object, e system.eventargs) handles mybase.load myvariable = "hello" end sub private sub button1_click(sender system.object, e system.eventargs) handles button1.click messagebox.show(myvariable) end sub end class

c++ - Reference of a function return value -

suppose have this class handleinterface { gluint handle_; protected: void sethandle( gluint ) { handle_ = i; } public: gluint gethandle() const { return handle_; } virtual ~handleinterface() {} }; buw need reference of handle_. // need &handle_ glgenbuffers( 1,&handle_ ); do need write getter handle_ ? or how reference of handle_ getter method? also glgenbuffers somehow violates sethandle method because should set handle_ though sethandle method , not though reference. ideas how can avoid this? if want keep handle_ encapsulated, pass local variable glgenbuffers : gluint handle; glgenbuffers(1, &handle); sethandle(handle);

FTP guaranteed file delivery for Android -

i'm using apache commons net library ftp in android app. , when using interrupted network or 2g network doesn't send/download file expected. i know have check boolean result of storefile function in order resend file again , again...and sometime sends corrupted files. is there library uses apache commons net library guarantees file sync process (including resuming, checking if delivered file has same size 1 in client/server). there sync library take care of these checks me. sync process doesn't have immediately. 100% guaranteed file delivery. this issue not happen when using wifi.

html - Bootstrap Well Padding Issue -

i have problem when try wrap around several grid elements. i'm not sure if works out of box or if i'm not sure place class. http://jsfiddle.net/adamfollett/9xs8y/1/ <div class="container"> <div class="row"> <div class="span6"> <div class="well"> <div class="row"> <div class="span3"> 55 fake street<br /> st. johns<br/> a1e3a2<br/> </div> <div class="span3"> more info<br /> blah blah<br/> blah<br/> <input type="button" class="btn btn-primary" value="use location" /> </div> ...

jquery ui - Rails getting ActionController::RoutingError (No route matches [GET] "/assets/images/ui-bg_flat_75_ffffff_40x100.png") -

i'm getting following error in rails app (doing request image doesn't exist:): actioncontroller::routingerror (no route matches [get] "/assets/images/ui-bg_flat_75_ffffff_40x100.png"): actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' ... it looks known error in jquery-ui.css these sites talk it: jquery-ui.css images fixed jquery ui css , image location work minified assets and bug report i have jquery-ui.css in stylesheets folder. version: /*! jquery ui - v1.9.2 - 2012-11-23 line 246 has: url(images/ui-bg_flat_75_ffffff_40x100.png) but, don't know how fix it. any appreciated! i believe can resolve viewing jquery-ui.css and/or jquery-ui.theme.css , finding line pointing , removing images @ start therefore this. url(ui-bg_flat_75_ffffff_40x100.png) instead of: url(images/ui-bg_flat_75_ffffff_40x1...

javascript - HTTP request is getting cancelled -

i trying upload file remote server. request not hitting there correctly , see status (canceled) in network. dont see datas passing in network. pfb abstract code xhr = new xmlhttprequest(); if (xhr) { xhr.open("post", url); xhr.onreadystatechange = function() { if (xhr.readystate === 4) { ///do blah blah } }; } var form = new formdata(); form.append("tpifiles", filedata); form.append("cookie", 'cookie=' + $.cookie('cookie')); xhr.send(form); all helps appreciated. thanks

android - publish story on facebook via my app publishes to "only me" using Facebook sdk 3.0 -

while sharing app via facebook, works fine on post says "only me". want post should seen friends. below code snippet using: private static final list<string> permissions = arrays.aslist("publish_actions"); in on create method: com.facebook.settings.addloggingbehavior(loggingbehavior.include_access_tokens); com.facebook.session session = com.facebook.session.getactivesession(); if (session == null) { if (savedinstancestate != null) { session = com.facebook.session.restoresession(this, null, statuscallback, savedinstancestate); } if (session == null) { session = new com.facebook.session(this); } com.facebook.session.setactivesession(session); if (session.getstate().equals(sessionstate.created_token_loaded)) { session.openforread(new com.facebook.session.openrequest(this).setcallback(statuscallback)); s...

Is it possible to store 8 characters (1-byte each) in a variable of type double (8-bytes) in c/c++? -

i migrating legacy fortran77 code c/c++. in fortran77 code, if 8 characters read in file, can stored in variable of type real*8 without problem. is possible similar thing in c or c++? if so, how it? haven't been able find solutions on internet. need read in 8 characters using c/c++ , store them in variable of type double, passed fortran , corresponds original real*8 variable. many in advance help. edit: in response @sixlettervariables, i'll clarify use-case bit more. issue have suggestion know format of each line (i.e. fields strings, numbers) @ runtime, , hence can't know members struct should have statically. fields need occupy contiguous block of memory in order read in. concretely, in 1 run of program format of each line might be: f1:string, f2:number, f3:number, f4:string , in f1:string, f2:string, f3:string, f4:number, f5:number . first case i'd need: struct { char[8] f1; double f2; double f3; char[8] f4} for second i'd need: struct { char[...

php - Insert values from database into select option -

i want put fields database select options. therefore made function, nl showprojects. want show these options form isn't showing values. don't know mistake is... public function showprojects() { $db = new db(); $select = "select project_title tblprojects order project_title asc"; $result = $db -> conn -> query($select); $option =""; while ($row = mysql_fetch_assoc($result)) { $option .= '<option value = "' . $row['project_title'] . '">' . $row['project_title'] . '</option>'; } return $option; } i want show in way: <div class="control-group"> <label class="control-label" for="bug_project">project</label> <div class="controls"> <select name="bug_project" class="span5" > <?php if(isset($bug)) $bug->showprojects(); ?> ...

c# - Find the referring URL and parse it -

okay problem there 2 websites 2 different servers. i'm trying write of buttons website 1, on page on server (website 2). so approach is user clicks on button website 1. user redirected website 2. i need know page came know product looking at. done getting referrer url. i need parse url's productid's number. example url: website1.com/productdetails/?referrerpage=1&productid=#######&tab=tile i know need use piece of code store referrer url in string: myreferrer = request.urlreferrer.tostring(); i don't know place tho. i'm guessing in .cs file button is? protected void btnestimate_click(object sender, eventargs e) { connection strings { stuff { stuff } so question how referring url, , parse out item id? thanks in advance. if unclear please ask... first time asking question may unclear. thanks! this should give want: making sense of asp.net paths note qualified url including quer...

sqlite - Populating sqlite3 database in Python loop -

i have constructed database when loop through data populate it, following error: operationalerror: no such column: tmp1 code: with con: cur = con.cursor() cur.execute("create table testtable(x real, y real)") in xrange(0,5): tmp1 = array[i,0] tmp2 = array[i,1] con: cur.execute("""insert testtable values(tmp1,tmp2)""") basically have big array want transfer database. isn't efficient way of going it. suggestions? if want insert values row, need pass values along sql parameters .execute() call: with con: in xrange(0,5): tmp1 = array[i, 0] tmp2 = array[i, 1] cur.execute("""insert testtable values(?, ?)""", (tmp1, tmp2)) the ? characters parameters, , filled, in order, values takes second argument .execute() , tuple. above code insert numbers 0 through 4 pairs database. names in sql code have no correlation names define in python, va...

c# - panel1.DrawToBitmap doesn't draw lines from DrawLine -

i have panel on i'm drawing lines using: point previouspoint = new point (0,0); point newpoint = new point (10,10); pen mypen = new pen(color.black, 2); graphics mygraphics = panel1.creategraphics(); mygraphics.drawline(mypen, previouspoint, newpoint); this works fine. change points draw more lines, doesn't matter question. want export panel jpg file. i'm using code: bitmap bmp = new bitmap(panel1.width, panel1.height); panel1.drawtobitmap(bmp, new rectangle(0, 0, panel1.width, panel1.height)); bmp.save("c:\\panel.jpg", system.drawing.imaging.imageformat.jpeg); this outputs blank jpg. background of panel gray, , background of jpg same gray, know it's exporting panel. also, added button panel see if saved, , did. reason jpg isn't saving lines being drawn. so made workaround solves core problem. made array of points plotted draw lines, did this: // make sure drew if (mylines.length > 0) { /...

ember.js - Iterating over records of a model without knowing the model -

hi try create gui (ember-data) models used in application. thats router: app.router.map(function () { this.resource('config', function() { this.resource('configmodel', {path: ':configmodel'}); }); in config want list defined models. by: app.configroute = ember.route.extend({ setupcontroller: function(controller) { var model = []; for(var property in app) { if(app[property] && app[property].superclass && app[property].superclass === ds.model) { model.push({name: property, model: app[property].find()}); } } controller.set('content', model); } }); the config template looks this: <div> <ul> {{#each controller}} <li>{{#linkto configmodel model}}{{name}}{{/linkto}}</li> {{/each}} </ul> </div> <div> {{outlet}} </div> up here works , list of models, link...

image - I'm developing a wordpress theme and using custom fields. I've got the following code: -

<img src="<?php echo get_post_meta($post->id, 'thumbnail', true);?>" alt="post pic" width="615" height="275" /></a> that code giving this: <img src="" alt="post pic" width="615" height="275"> any ideas why image not displaying correctly? the proper way display featured image post the_post_thumbnail() echo <img> tag page or get_the_post_thumbnail() return result string. should not using custom/meta fields directly.

mysql - Database schema of video (item) having multiple categories -

i have designed schema web application stores videos , each video comes under categories.single video can have multiple categories.i create following relations.. relation1: video_detail(v_id,v_name,v_details); relation2: video_category(cat_id,cat_name); now want relate each video in video_details video_category .. have following option:- create relation each category cat_entertainment(v_id) , on... is efficient way doing work...or there way same without redundancy, thank ..?? assuming 1 video can have many categories , category can set number of videos, need bridge table called video_detail_category contain: video_detail_category(v_id, cat_id, primary key (v_id, cat_id))

ios - Apple Game Center Web API -

this question has answer here: is there web api apple's game center? [closed] 1 answer i not trying integrate game center application, instead trying pull leaderboards , achievements web page. is there api or rss feed game center? is there web api apple's game center? . change in policy? policy limits success/visibility of game center. nope. a quick search on google revealed no relevant content. if there was api/rss feed this, expect come in search.

Regex For Log Parsing -

i trying find of exceptions in log not of type invalidargumentexception. our log writes out lines following: class: invalidargumentexception the regex trying use is: /class:.*(!invalidargument)exception/ essentially, start word class: , allow characters after class not equal invalidargument, , include word exception thank help. one possibility negative behind: /^class:.*?(?<!invalidargument)exception/ test grep -p : kent$ echo "class: foo invalidargumentexception class: bar nullpointerexception"|grep -p '^class:.*?(?<!invalidargument)exception' class: bar nullpointerexception

c++ - Use boost to convert degrees minutes seconds radians boost_1_48_0 -

i have got code work: typedef model::point<double, 2, cs::spherical_equatorial<degree> > degree_point; degree_point flindersse(-37.0, 144.0); and this: quantity<plane_angle> flinders = 0.375 * radians; //this works 0.375 radians but degrees minutes , seconds & convert radians again. i have spent day trying understand how boost system works - examples bit thin on ground, wondering if show quick example? thanks in advance 8+) edit //quantity<degree_base_unit> flinderssdeg2.value(-37.0); //quantity< angle::arcminute_base_unit> flinderssmin = 57.0; //quantity< angle::arcsecond_base_unit> flindersssec = 3.72030; i guess need better understanding of how declaration works. :) edit2: thanks - maybe spent whole looking ways boost & facility wasn't there ! thought might have been because found obsolete code here http://www.boost.org/doc/libs/1_47_0/libs/geometry/doc/doxy/doxygen_input/sourcecode/doxygen_1.cpp void exam...

HTML XPath Searching by class and text -

i want find elements in xpath class , text. have tried not work. // [contains(@class, 'myclass')]// [text() = 'qwerty'] i trying find elements have class of 'myclass' , text 'qwert' (these span elements) //span[contains(@class, 'myclass') , text() = 'qwerty'] or //span[contains(@class, 'myclass') , normalize-space(text()) = 'qwerty']

eclipse - Get the minimum number out of a file and print. Python -

i have run problem python program. trying list file , print lowest number. eg. showfile = open("company.txt", 'r') line in showfile: tokens = line.split(',') minvalue = min(tokens[:2]) print("the lowest is", minvalue) and outputs- the lowest 33 lowest 18.5 lowest 22 here company.txt - 'huggies', 33, 84 'snugglers', 18.5, 72 'baby love', 22, 96 i quite nooby, awesome. right now, you're finding lowest number separately in each line. sort of. if want lowest single number in file, should collect numbers or minimum number each line single list, , call min() on list outside loop. another problem, though, way you're checking numbers tokens[:2] . stick print tokens statement after , you'll find you're cutting off second number of each line. if goal cut off company name, you'd use [1:]. problem other answers retain tokens[:2] line. appear wo...

python - How to use SWIG to wrap a C++ operator[] in a template class inside a namespace? -

i'm using swig wrap existing c++ library using header files. library uses namespace , template class create arrays of custom objects. i'm running problems trying wrap subscript operator (operator[]) used access elements inside wrapped arrays. swig tells me operator[] ignored , should use %extend instead: small.i:18: warning 389: operator[] ignored (consider using %extend) so i'm trying use extend no matter syntax i've tried, can't inserted code show in _wrap.cxx file. here's swig input file: %module tltest %{ ... %} namespace nite { template <class t> class array { public: %rename(__getitem__) operator[]; const t& operator[](int index) const {return m_data[index];} %rename(__len__) getsize; int getsize() const {return m_size;} }; class userdata : private niteuserdata { public: }; %template(userdataarray) array<userdata>; }; %extend array<userdata> { userda...

php - Regex values between brackets -

i want receive values between brackets array, don't working. input: hello, name {names.id1} , {user.age} , {hobby.name}. ouput: array ( [0] ( [category] > "names"; [value] > "id1"; ) [1] ( [category] > "user"; [value] > "age"; ) [2] ( [category] > "hobby"; [value] > "name"; ) ) i made this, not working properly. can me out please? /(\{([^\]]*)\.([^\]]*)\})/i http://regex101.com/r/ft2lw0 well typed braces instead of brackets... /(\{([^}]*)\.([^}]*)\})/gi alternatively use /{(.*?)}/gi

jquery - javascript detect scrollbar not working -

i know question has been asked ad nauseum, stumped because after trying several different solutions, still cannot script detect scrollbar. here function using try , detect scrollbar: function checkscrollbar() { var hcontent = $("body").height(); // height of content var hwindow = $(window).height(); // height of visitor's browser window if(hcontent>hwindow) { // if height of content bigger height of browser window, have scroll bar return true; } return false; } the problem though on page there literally vertical scrollbar popping because content of page longer window on laptop, function still says window height equal body height. i still newer javascript/jquery, please gentle if there major error have missed. you need consider offset of page. function checkscrollbar() { var hcontent = $(document).height(); // height of content var hwindow = $(window).height(); // height of visitor's browser window if(hcontent>hwi...

unicode - Create an invalid UTF8 perl string? -

what's way create perl string utf8 flag set contains invalid utf8 byte sequence? is there way set utf8 flag on perl string without performing native encoding utf-x translation (for instance, happens when call utf8::upgrade )? i need track down possible bug in dbi driver. that's encode's _utf8_on does. use encode qw( _utf8_on ); $s = "abc\xc0def"; # string use raw buffer content. utf8::downgrade($s); # make sure each char stored byte. _utf8_on($s); # set utf8 flag. (never use _utf8_on except when want generate bad scalar.) you can view damage using use devel::peek qw( dump ); dump($s); output: sv = pv(0x24899c) @ 0x4a9294 refcnt = 1 flags = (padmy,pok,ppok,utf8) pv = 0x24ab04 "abc\300def"\0malformed utf-8 character (unexpected non-continuation byte 0x64, after start byte 0xc0) in subroutine entry @ script.pl line 9. [utf8 "abc\x{0}ef"] cur = 7 len = 12

c++ - What does it mean to declare a variable as a function? -

in example below do myclass (); i've been told function returns myclass neither of following lines work. myclass b = a(); a.a = 1; so , can it? #include "stdafx.h" #include "iostream" using namespace std; class myclass { public: int a; }; int _tmain(int argc, _tchar* argv[]) { myclass (); // function? mean? can a? int exit; cin >> exit; return 0; } i've been told function returns myclass [...] that function declaration . declares function called a , makes compiler aware of existence , signature (in case, function takes no arguments , returns object of type myclass ). means may provide definition of function later on: #include "iostream" using namespace std; class myclass { public: int a; }; int _tmain() { myclass (); // *declares* function called "a" takes no // arguments , returns object of type myclass... myclass b = a(); // r...

c# - Error System.Windows.Media.Color.A.get -

i have project image editor , erroneous reference markets 'system.windows.media.color.a.get' , not because make mistake brand error code in visual studio 2012 windows phone 8 would appreciate help public writeablebitmap process(writeablebitmap input) { var result = new writeablebitmap(input.pixelwidth, input.pixelheight); var resultpixels = result.pixels; var inputpixels = input.pixels; var ta = color.a; var tr = color.r; var tg = color.g; var tb = color.b; (int = 0; < inputpixels.length; i++) { var c = inputpixels[i]; var = (byte)(c >> 24); var r = (byte)(c >> 16); var g = (byte)(c >> 8); var b = (byte)(c); int gray = (r * 6966 + g * 23436 + b * 2366) >> 15; = (byte)((a * ta) >> 8); r = (byte)((gray * ta) >> 8); g = (byte)((gray * ta) ...

cocos2d iphone - Adding CCSprite on Tiled tile properties -

i'm trying add sprite beside player, when tile beside player not wall. know tiled tiles working properly, job in method: cgpoint p = cgpointmake(tilecoord.x, tilecoord.y - 1); if ([self isvalidtilecoord:p] && ![self iswallattilecoord:p]) { [tmp addobject:[nsvalue valuewithcgpoint:p]]; t = yes; i checking tiled on coordinate these 2 methods: -(bool)isprop:(nsstring*)prop attilecoord:(cgpoint)tilecoord forlayer:(cctmxlayer *)layer { if (![self isvalidtilecoord:tilecoord]) return no; int gid = [layer tilegidat:tilecoord]; nsdictionary * properties = [_tilemap propertiesforgid:gid]; if (properties == nil) return no; return [properties objectforkey:prop] != nil; } -(bool)iswallattilecoord:(cgpoint)tilecoord { return [self isprop:@"wall" attilecoord:tilecoord forlayer:_bglayer]; } (thanks raywenderlich) and code adding sprite cgpoint tilecoord = ccp(_player.position.x - 24 +60, player.position.y); cgpoint ctilecoord = [self tilecoordforpo...

sql - Custom Sort (not using ORDER BY) and pagination -

i have moderately complex query (over 1k loc far) search-type web page. result set needs in order. there 7 different criteria used order set. have 2 table variables 1 called @stagetable , @resulttable. run dynamic query search parameters , put results @stagetable. process @stagetable each of 7 order criteria , put each chunk in @resulttable. working expected. i asked add pagination monster query. went cte row_number() route. however, realized not respecting order in @resulttable. issue i'm running row_number() on clause uses order not allow me keep order crafted in @resulttable. tried different things including adding case block in cte. the issue applies when user loads page first time, , when scrolling without using criteria search page. any ideas on how deal this? when define @resulttable, add identity column: declare @resulttable table ( resulttableid int not null identity(1, 1), . . . ); when insert table, put other columns in column list: ins...

c++ - Can't get the RTC to work -

i trying create simple program reads rtc clock value , prints serial monitor. usart working fine, can't figure out what's wrong rtc. giving me time same value set in seturtc(). second interrupt not working either. edit: using stm32f1 development board, same this here rtc setup: void setuprtc(void){ rcc->apb1enr |= (rcc_apb1enr_pwren | rcc_apb1enr_bkpen); //enable power , backup interface clocks setting pwren , bkpen bitsin rcc_apb1enr register pwr->cr |= pwr_cr_dbp; //enable access backup registers , rtc. rcc->bdcr |= rcc_bdcr_lseon; //external low speed oscillator enable while((rcc->bdcr & rcc_bdcr_lserdy) == 0); //wait until external oscillisator stabilised rcc->bdcr |= rcc_bdcr_rtcsel_lse; sendstr(textlse); rcc->bdcr |= rcc_bdcr_rtcsel_lse; //select source (lse oscillator clock used rtc clock ) rcc->bdcr &= ~((1 << 8) | (1 << 9)); //unusable cloc...

python - 'MarkovGenerator' object has no attribute 'together' -

i come problem class , don't know reason, can me out? the problem in def together(), here code. class markovgenerator(object): def __init__(self, n, max): self.n = n # order (length) of ngrams self.max = max # maximum number of elements generate self.ngrams = dict() # ngrams keys; next elements values beginning = tuple(["that", "is"]) # beginning ngram of every line beginning2 = tuple(["on", "the"]) self.beginnings = list() self.beginnings.append(beginning) self.beginnings.append(beginning2) self.sentences = list() def tokenize(self, text): return text.split(" ") def feed(self, text): tokens = self.tokenize(text) # discard line if it's short if len(tokens) < self.n: return # store first ngram of line #beginning = tuple(tokens[:self.n]) #self.beginnings.append(beginning) in range(len(tokens) - self.n): gram = tuple(tokens[i:i...

IUP, menu, webbrowser, tree, tabs -

i have such menu situation: int menu_create(ihandle *menu) { hamburger = iupitem("&hamburger", "hamburger"); iupsetattributes(hamburger, "autotoggle=yes, radio=yes"); char* ce = "Ćev&apčići"; cevapcici = iupitem(utf8_to_cp1250(ce), "cevapcici"); iupsetattributes(cevapcici, "autotoggle=yes, radio=yes"); exit = iupitem("exit\talt+f4", "exit"); img4 = iuploadimage("icons\\delete_16x16.ico"); iupsetattributehandle(exit, "titleimage", img4); menu = iupmenu( iupsubmenu("file", iupmenu( hamburger, cevapcici, iupseparator(), iupitem("carro&t", "carrot"), iupseparator(), exit, null)), null); iupsetfunction("exit", (icallback)mnu_exit); ... etc... iupsethandle("menu", menu); return iup_default; } ...

php - display data in multiple columns -

Image
hi need build table 4 columns mysql table. here have now: <?php "<table>"; while ( $row = mysql_fetch_array( $result , mysql_assoc) ) { "<tr>"; "<td>"; print("<p><img id='g1' src='/$row[img]' width=130 height=130 onclick='f1()'>" ); print( "<p> name: $row[name] <br>"); "</td>"; "</tr>"; "</table>"; } ?> the output 1 column table this: i need table in 4 columns this: is possible if how do that? <?php $items_in_row = 4 ; $index = 0 ; ?> <table> <tr> <?php while ($row = mysql_fetch_array( $result , mysql_assoc)){ $index++ ; ?> <td> <p> <img id='g1' src='/<?php echo $row["img"] ;?>' width=130 heigh...

asp.net - Class Diagram aspx -

i bussy class diagram. my project has classes (example: user.cs, friend.cs, message.cs). and have .aspx , .ascx (web user control) files have classes, example: showfriends.ascx has showfriends.ascx.cs-class. what know is: need take create class in class diagram showfriends.ascx.cs-class? or not allowed because it's part of .ascx file? if don't it, miss lots of things in class diagram. if allowed: how can seperate friend.cs showfriends.ascx.cs file in class diagram? because friend.cs file has attributes in it, , showfriends.ascx.cs file has methods showfriends(). , if create relation between user , and friend.cs , showfriends.ascx.cs looks weird. for me it's more logical have 1 class called friend.cs or attributes , methods in (methods showfriends()), dont have that, because need create methods in .ascx.cs file because of using request.querystring["username"]. thanks in advance! the best practice define classes in separate file. if you'...

c# - decode multiple qr code webcam based QR decoder -

Image
i learning on qr code decoder. previously, took example " https://zxingnet.svn.codeplex.com/svn/trunk/clients/emgucvdemo/ " , and rebuild it. added additional function it. working fine shown below however realize decoder cannot decode if there more 1 qr code in image during webcam video capture i looked @ " http://zxing.org/w/docs/javadoc/com/google/zxing/multi/multiplebarcodereader.html " , use method stated still cant detect qr code if there more 1 in image. appreciate if gv heads or tutorial on matter. thank you you should change following code within emgucvdemo // decode var result = reader.decode(image); // show result if (result != null) { ... } to // decode var results = reader.decodemultiple(image); // show results if (results != null) { // it's array of results ... ...

android - downgrading google play services from 6 to 5 -

the image of sdk want downgrade version of google play services rev version 6 rev version 5. need run maps on emulator cant figure out on how it. [i have found kind of solution here][2] [2]: the latest com.google.android.gms google play services revision 6 can't figure out how downgrade it. on version getting error google play services out of date. requires 3027100 found 2012110 if know on how please share or if can provide new apk files installed on device work maps. you can download older revision here: http://venomvendor.blogspot.co.il/2012/03/android-sdk-extras-by-google-inc.html then remove newer version workspace, , add desired one. once did can refrence project , check again. you can read blog post wrote on matter well: google maps api v2 in emulator

c# - SQLDataReader Null to datetime -

having issue casting datetime reader value null. form._date101 = reader[52] == dbnull.value ? dbnull.value : (datetime?)reader[52]; getting: type of conditional expression cannot determined because there no implicit conversion between 'system.dbnull' , 'system.datetime?' any ideas? i suspect meant: form._date101 = reader[52] == dbnull.value ? null : (datetime?)reader[52]; that's assuming _date101 field of type datetime? . expect want "use null value of datetime? if value null in database; otherwise use non-null value.

shopify - Python Requests Invalid URL Label error -

i'm trying access shopify's api uses url format of - https://apikey:password@hostname/admin/resource.xml e.g. http://7ea7a2ff231f9f7:95c5e8091839609c864@iliketurtles.myshopify.com/admin/orders.xml doing $curl api_url downloads correct xml when import requests api_url = 'http://7ea7a2ff231f9f7d:95c5e8091839609c864@iliketurtles.myshopify.com/admin/orders.xml' r = requests.get(api_url) # invalid url label error any idea why i'm getting this? curl / opening link directly in browser working fine. because length of url long? thanks! the error ( 'url has invalid label.' ) bug in requests library: applies idna encoding (for internationalized domain names) on hostname userinfo attached, source : netloc = netloc.encode('idna').decode('utf-8') that might raise 'label empty or long' error long username:password. can try report on requests' issue tracker . a:b@example.com form deprecated otherwise request...

mysql - why is this query in SQL/PHP not working? -

i have sql query made in php. query resulst in error. if remove and first_name '{$first_name}%' , works fine , produces right output. unable follow wrong below syntax. appreciated. thanks $db = new pdo("mysql:dbname=newbie"); $first_name=$_get["firstname"]; $first_name =$db->quote($first_name); $last_name=$_get["lastname"]; $last_name=$db->quote($last_name); $rows=$db->query("select id,first_name actors last_name=$last_name , first_name '{$first_name}%' order film_count desc limit 1"); i think because missed quotes on $lastname , given text-field. $db = new pdo("mysql:dbname=newbie"); $first_name=$_get["firstname"]; $first_name =$db->quote($first_name); $last_name=$_get["lastname"]; $last_name=$db->quote($last_name); $rows=$db->query("select i...

Rails has_many not populated on create -

i've run migration introduce new has_many , has many :through association. "standard" has _many "layers" through "layers_assoc". new feature works fine on existing standards, creating new standard, no new layers or layers_assocs created. despite creating association , migration having defaults, have create instances of association when standard created? here migration layers_assocs table class createlayersassocs < activerecord::migration def create_table :layers_assocs |t| t.timestamps t.integer :layer_id, :null => false # has_many t.integer :standard_id, :null => false # has_many t.boolean :visible, :default => true end add_index :layers_assocs, :layer_id add_index :layers_assocs, :standard_id layersassoc.reset_column_information puts "== populating layersassoc table ============================" standard.all.each |standard| layer.all.each |layer| ...

wix3.5 - WiX Installer Spawn an Executable -

my questions this, have wix installer .msi want able to, after successful installation, executable runs installation. reason need wix installer installs application developed , executable need run installs application developed long time ago. second executable independent first installation , not have uninstalled when application installed .msi is not have worry roll backs. wondering if there way have .msi use ca launch .exe upon completion? know how .msi launch application installs after installation executable need not included in .msi, confusion/deleama coming from. if maybe point me in right direction great! thanks. this typical case installer chainer, particularly since installers independent. wix offers bootstrapper project type creates bootstrapper/downloader/chainer. ideal situation. you can create such project using bootstrapper project template in visual studio or writing needed xml files hand. default, bootstrapper creates uninstall entry uninstalled ,...

php - Warning: Input variables exceeded 1000 -

i'm building rests service in php should accept large json post main data (i send , read data discussed here: http://forums.laravel.io/viewtopic.php?id=900 ) the problem php gives me following warning: <b>warning</b>: unknown: input variables exceeded 1000. increase limit change max_input_vars in php.ini. in <b>unknown</b> on line <b>0</b><br /> is there way php not count input variables (or should surpress startup warnings)? i found out right way handle json data directly in php (via file_get_contents('php://input') ) make sure request sets right content-type i.e. content-type: application/json in http request header. in case i'm requesting pages php using curl code: function curl_post($url, array $post = null, array $options = array()) { $defaults = array( curlopt_post => 1, curlopt_header => 0, curlopt_url => $url, curlopt_fresh_connect => 1, curlopt_returntransfer =...

sql - Touch function in Postgres with PostGis -

i have postgresql installed postgis, try run following: select n1.edname "borders royal exchange a" eds_census2011 n1, eds_census2011 n2 touch(n1.the_geom, n2.the_geom) , n2 = 'royal exchange a' and error (below) there have add postgres or enable something? error: function touch(geometry, geometry) not exist line 3: touch(n1.the_geom, n2.the_geom) ^ hint: no function matches given name , argument types. might need add explicit type casts. ********** error ********** error: function touch(geometry, geometry) not exist sql state: 42883 hint: no function matches given name , argument types. might need add explicit type casts. character: 96 run these 2 queries (in same session trying above query) pin down problem: in schema function touch() live? select p.proname, n.nspname pg_proc p join pg_namespace n on n.oid = p.pronamespace proname = 'touch'; what current schema search_path of role: show search_path; if ...

android - Persist Facebook bundle for later reuse -

i have login facebook implemented in application. need relogin every 10 minutes want save facebook bundle reuse on scheduled relogin. how persist bundle not force users relogin manually? at time of first login, set current session active session -> session.setactivesession(session); //session - current session object override onsavedinstancestate of activity lifecyle this-> @override protected void onsaveinstancestate(bundle outstate) { // todo save current session super.onsaveinstancestate(outstate); session session = session.getactivesession(); session.savesession(session, outstate); } now next time when want login again use-> session session = session.getactivesession(); you logged in session , can use session performing tasks.

c# - ASP.NET NumericUpDownExtender with button hold support? -

hi trying "updown" button allows user hold increment/decrement button , increment/decrement decimal value. have been trying using ajaxtoolkit:numericupdownextender seems allow increment/decrement button clicks. rather clunky since value percentage. ideas of better way handle within asp.net? i able make pretty javascript using timer. here aspx part of it: <asp:textbox id="factor" runat="server" maxlength="6" width="60"/> <input id ="upbutton" value="&#9650;" type="button" onmousedown="timerid = setinterval(function(){factup()},100);" onmouseup="clearinterval(timerid);"/> <input id ="downbutton" value="&#9660;" type="button" onmousedown="timerid = setinterval(function(){factdown()},100);" onmouseup="clearinterval(timerid);"/> and javascript: var timerid = 0; function factdown() { var ob...

jsp - is there a way to collapse all the panels of Kendo Panelbar, on an action? -

i working on app adding panelbars (multiselection) using jsp wrapper (which means no id each of panels), , inside have grids. the grids storing data specific selected person, displayed list items(images) on top of page. what want when user changes selection of person, current selected another, collapse panels of kendo panelbar. in reloading data of new person, because when user select/expand panel see data, catch event , reload grid new datasource, based on selected person. i hope make sense here, not sure how collapse panels of panelbar. any suggestions?? if id of panelbar panel , do: $("#panel").data("kendopanelbar").collapse($("li", "#panelbar")); or var panelbar = $("#panelbar").data("kendopanelbar"); panelbar.collapse($("li", panelbar.element)); i.e. collapse every li element under #panelbar . edit : if want remove selection, add: $(".k-state-selected", panelbar.ele...

php - Magento won't keep sessions on front end only -

i've got magento store refuses keep session information on front end. strangly admin works fine. php independent of magento able write sessions. magentos var/ directory writable webserver. can see files being written var/session. this site running on ec2 under nginx. wasn't having these problems under apache , far can tell configuration of magento same. yes it. wasn't able see in firefox console, in chrome see domain wrong ( although looked ok in admin, maybe confused ) updated cookie_domain fields in core_config_data table , working. @datasage

unhandled exception - Within CPPUNIT_ASSERT, Keep Getting Access Violation -

i have set of classes trying apply unit tests, maintain current utility through future revisions. my problem within cppunit, new, where-ever call cppunit_assert ( [condition] ), met error unhandled exception...: access violation @ 0xffffffffffffffff. this happens write simplest test case int main(){ cppunit_assert ( true ); } i have tried calling testing functions manual calls, adding them registry, done in money example. problem reportedly arises within constructor sourceline, filename string expects bad pointer. after bit of search i've found called within cppunit_assert, it's macro following definition #define cppunit_assert(condition) \ ( cppunit_ns::asserter::failif( !(condition), \ cppunit_ns::message( "assertion failed", \ "expression: " #condition), \ ...

overlapping - force scrollbar itself to stop moving upwards (fake limit) while the div is still being scrolled up. -

jsfiddle: http://jsfiddle.net/2ezq9/2/ on site, using nicescroll3 have scrollbar within container div pulling data ajax. problem this: when scroll top of container div, scrollbar continues scroll under header , top of container. normal, know, scrollbar stop @ bottom of header when container finishes scrolling. basically, want scrollbar stop top-margin same height of header (i.e.: not overlap header). have searched endlessly , cannot find solution online. thank in advance! html <div id="wrapper"> <div id="header">sticky header</div> <div id="content">content <br />content<br />content<br />content <br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content<br />content <br />content<br /...

jquery - AJAX image upload with Rails, Backbone, Remotipart -

i've been using remotipart upload images via ajax while now, we've decided go backbone route, , since forms rendered via js templates, i'm no longer able use :remote => true syntax generate iframe transport code. don't want have figure out how manually. thoughts on how can remotipart work when using js templates? figured out solution. little confused on how js remotipart works. after little research, here's found: remotipart works binding ajax:aborted:file event, triggered when jquery ujs (which handles traditional ajax form submits) detects file within form. since script (along dependent iframe transport plugin) included on page, need manually add data-remote="true" to form. jquery has .on() event bound forms such attributes, if include that, remotipart triggered. another issue, though, if form submitted, still fail upload file due lack of csrf token. solution manually add hidden input tag token. here's final markup worked me...

android - Animating lazy load of ArrayAdapter -

hello using animation arrayadapter. want animate thumbnail when loaded... every time thumbnail of list loaded, animation starts every items of array adapter. consequence, animation of each thumbnail started 5 times. have prevent starting animation when of items loaded? public view getview(int position, view item, viewgroup parent){ viewholder holder; video video = mvideolist.get(position); if(item == null) { item = minflater.inflate(r.layout.adapter_recommended_videos, null); holder = new viewholder(); holder.title = (textview)item.findviewbyid(r.id.adapter_recommended_videos_textview); holder.thumb = (imageview)item.findviewbyid(r.id.adapter_recommended_videos_imageview); holder.title.settypeface( typeface.createfromasset(mcontext.getassets(), "roboto_medium.ttf")); item.settag(holder); } else { holder = (v...