Posts

Showing posts from February, 2015

parsing - Explanation on this FIRST function -

ll(1) grammar: (1) var -> id dimlist (2) dimlist -> ε dimlist' (3) dimlist' -> dim dimlist' (4) dimlist' -> ε (5) dim -> [ const ] and, in script reading, says function first(ε dimlist') gives {#, [} . but, how? my guess since right side of (2) begins ε , skips epsilon , takes first(dimlist') is, considering (3) , (5), equal {[} , also, because of (4), takes follow(dimlist') {#} . other way that, since (2) begins ε skips epsilon , takes first(dimlist') takes follow(dimlist) (2)... first 1 makes more sense me, though i'm still in process of learning basics of ll(1) grammars appreciate if takes time make clear, thank you. edit: and, of course, neither of these true. the usual definition of first function result in first(dimlist) (or, if like, first(ε dimlist') being {ε, [} . ε in first(ε dimlist') because both ε , dimlist' nullable. [ element because first symbol in derivation of ε di

django - order_by('-distance') not working as expected -

i trying make database query gives me 20 closest users ordered distance (so closest first) doing follwoing distance_mi = 100 origin = geosgeometry('srid=4326;'+ 'point('+ str(user_profile.current_location.x)+' '+str(user_profile.current_location.y)+')') close_users = userprofile.objects.exclude(user = user).filter(current_location__distance_lte=(origin, d(mi=distance_mi))).distance(origin).order_by('-distance')[:20] but returns 3 users (which correct) first user 0 mi away, second 8 mi away , third 0 mi away excepting 8 mi user @ end. i not sure doing wrong in this. also, userprofile has following model class userprofile(models.model): # field required. user = models.onetoonefield(user) # other fields here current_location = models.pointfield(null = true) seller_current_location = models.pointfield(null = true) objects = models.geomanager() def __unicode__(self): return u'%s' % (self.use

logging - Resque log handling: what sort of strategy? -

i'm having issues resque logger. works when start command line (it flushes standard output). deamonize it, don't see log anymore. thought default rails app logger, nothing shows there. plus, i'm using library writes of output (mostly debugging purposes) standard error , standard output (namely, $stderr , $stdout). these constants flush resque logger (moreover, should they)? how bundle them together? not that, wanted write log of forked process separate file, is, need change log file before process job. (which hook) best it? question-1 : i thought default rails app logger answer 1: nope resque logger default log stdout have change log specific file. question 2: plus, i'm using library writes of output (mostly debugging purposes) standard error , standard output (namely, $stderr , $stdout). answer 2: nope, unless log there output resque.logger.[info|warn|error] syntax question 3: not that, wanted write log of forked process separate fil

java - Grep character sequence -

i need match character sequences of form abcd12345 , others of form abcd54321.aaa . i have written code check both forms, works correctly input sequence abcd12345 because abcd54321.aaa matched both regex's (the 1 abcd54321.aaa , 1 abcd54321 ). how modify regular expression(s) 1 of them matches when input abcd54321.aaa ? here snippet of java code shows patterns using match character sequences: string[] patternvalues = new string[] { "[aa.][bb][cc][dd]\\d+\\.+[a-za-z]{3}","[aa.][bb][cc][dd]\\d+"} ; for(int = 0 ; <= (patternvalues.length - 1) ; i++) { pattern regexp = pattern.compile(patternvalues[i]); ..... } you want regular expression abcd54321 -only match: abcd54321(?!\.aaa) that match abcd54321 not followed .aaa . if want case-insensitive, first prepare pattern.compile() using case_insensitive flag: pattern.compile("abcd54321(?!\\.aaa)", pattern.case_insensitive);

stringtemplate - perform iteration in StringTemplate4 (C#) -

in stringtemplate4 cheat sheet ( http://www.antlr.org/wiki/display/st/stringtemplate+cheat+sheet ), mentions perform iteration <attribute:{anonymous-template}> apply anonymous template each element of attribute. iterated `it` attribute set automatically. i have tried below code: list<textparsetests.testmodel> data = new list<textparsetests.testmodel>(); (int = 0; < 10; i++) { textparsetests.testmodel model2 = new textparsetests.testmodel(); model2.name = i.tostring(); data.add(model2); } string template = @"testtemplate|| <list:{ [datalist <it.name>] }> [end]"; template t = new template(template); t.add("list", data.toarray()); var result = t.render(); sb.appendline(result); update 1 below testmodel data structure , related classes. using these just public class contactdetailstest { public

python - How to read and plot time series data files as candlestick chart? -

Image
here time series data. i'd read data file , plot candle chart. actually, googled find pyghon logic want day long, couldn't. comments appreciated. thank in advance. 2011-11-01 9:00:00, 248.50, 248.95, 248.20, 248.70 2011-11-01 9:01:00, 248.70, 249.00, 248.65, 248.85 2011-11-01 9:02:00, 248.90, 249.25, 248.70, 249.15 2011-11-01 9:03:00, 249.20, 249.60, 249.10, 249.60 2011-11-01 9:04:00, 249.55, 249.95, 249.50, 249.60 2011-11-01 9:05:00, 249.60, 249.85, 249.55, 249.75 2011-11-01 9:06:00, 249.75, 250.15, 249.70, 249.85 2011-11-01 9:07:00, 249.85, 250.15, 249.80, 250.15 2011-11-01 9:08:00, 250.10, 250.40, 250.00, 250.15 2011-11-01 9:09:00, 250.20, 250.35, 250.10, 250.20 to read in data set clipboard do from pandas import read_clipboard matplotlib.dates import date2num names = ['date', 'open', 'close', 'high', 'low'] df = read_clipboard(sep=',', names=names, parse_dates=['date']) df['d'] = df.date.map

android - How to reference TextView in RelativeLayout -

still total noob here... i'm trying render specs football match (teams, time, tournament etc.) i have created team.xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <imageview android:id="@+id/teamimageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="2dp" android:adjustviewbounds="true" android:src="@drawable/sofabold_launcher" android:layout_alignwithparentifmissing="false" android:clickable="false" android:croptopadding="true" android:contentdescription="@string/teamlogocontentdescription"/> <textview android:id="@id/teamname" android:layout_width="wrap_content" android:layout_height="wrap_

php - Windows is not resing on Social Engine -

when i'm in panel control(admin) try no edit html code, click on edit , appears: http://i.stack.imgur.com/dohia.jpg obs: can't modify because block stays in small size. when try in demo appears this: http://i.stack.imgur.com/lmzkc.jpg i have tried other pcs , result same. happens every time needs load windows those. can guys please that?? it common socialengine problem goes through version worked (starting 4.1.6). you can enlarge size of smoothbox frame using chrome inspector or other tool prefer. unfortunatly should perform operation every time you're editing html block.

html - How to simulate xmp bahavior -

i read xmp tag deprecated, need output code plain text. there way how simulate xmp tag behavior? help. you cannot simulate special parsing mode of xmp elements in html, except in genuine xhtml (i.e., xhtml served xml media type), can use cdata sections . reason low-level parsing of html, hard-wired browsers. so if don’t want use xmp , way “escape” characters “&” , “<” in content. note html5 drafts require browsers keep supporting xmp (while declaring obsolete , forbidden).

javascript - Popup with same target location shows appears differently -

i have 2 popups come in line code: <script type="text/javascript"> sys.debug = true; var popup; sys.require(sys.components.popup, function () { popup = sys.create.popup("#popup", { parentelementid: "target", }); }); var popup2; sys.require(sys.components.popup, function () { popup2 = sys.create.popup("#popup2", { parentelementid: "target", }); }); </script> this "target" referencing: <span id="target" style="position: absolute; top: 50%; left: 50%; margin-top: -125px; margin-left: -200px;"></span> inline code: <div id="popup" style="background: #eafdb3; color: #000; padding: 15px; margin: 0px"> //content </div> and: <div id="popup2" style="background: #eafdb3; color: #000; padding: 15px; margin: 0px"> //content &

php - Delete part of index name in multidimensional array -

in php, possible cut |xyz part away key names? array looks this: array(30) { ["1970-01-01|802"]=> array(4) { ["id"]=> string(3) "176" ["datum"]=> string(10) "1970-01-01" ["title"]=> string(8) "vorschau" ["alias"]=> string(16) "vorschau-v15-176" } ["1970-01-01|842"]=> array(4) { ["id"]=> string(3) "176" ["datum"]=> string(10) "1970-01-01" ["title"]=> string(8) "vorschau" ["alias"]=> string(16) "vorschau-v15-176" } ... thank help, toni for example, might use this: $newarray = array(); foreach( $oldarray $key => $value ) { $newarray[ substr( $key, 0, 10 ) ] = $value; } or modify array in-place: foreach( $somearray $key => $value ) { unset( $somearray[ $key ] );

c++ - How to print double using wsprintf -

i unable print double value using wsprintf() . tried sprintf() , worked fine. syntax used wsprintf() , sprintf() follows: wsprintf(str,text("square %lf "),isquare); // not show value sprintf(str," square %lf",isquare); // works okay am making mistakes while using wsprintf() ? wsprintf doesn't support floating point. mistake using @ all. if want sprintf , wide characters/strings, want swprintf instead. actually, since you're using text macro, want _stprintf instead though: it'll shift narrow wide implementation in sync same preprocessor macros text uses decide whether string narrow or wide. for it's worth: wsprintf entirely historic relic. w apparently stands windows . included part of windows way when (back @ least windows 2.1, windows 1). written without support floating point because @ time, windows didn't use floating point internally (at all).

javascript - match 2 urls with localhost -

i'm having hardest time javascript regex, can't figure out how match url: http://localhost:11111/#!/quote/18283 and http://www.myurl.com/#!/quote/23834 with same regex. i don't understand regex rules well. http://[\w\d\.:]+/#!/quote/\d{5} - without other context. don't know negative cases are. parts of urls important, etc, etc.

asp.net - Customized Generated HTML + GridView Capabilities -

Image
asp.net's gridview controller great, it's easy use, offers sorting, paging, , other stuff, find difficult customize way looks. the gridview generated table headers , divided columns, need users see better looking listed items, customized using css. in other words, don't want this: i want this: but when i'm going generate html , customize way looks, take time implement paging , sorting myself, scratch. so how can mix customized html capabilities of gridview? you looking repeater ! complete control on layout , rendering, downside lot of built-in stuff paging , sorting not there. i've used repeater combined aspnet pager: http://www.codeproject.com/articles/11418/pager-control-for-asp-net , , rolled own multi-sort. it's more work gridview , if want complete control, there's no better option.

php - Calculate dates relative to input date -

with code have now, managed return dates way off in 1969 , 1970.example of $enddate 23-8-2013. day, month, year. $enddte = date_create_from_format('j-n-y', $enddate); echo date('y-m-d', strtotime('-1 sunday', strtotime($enddte))). date('y-m-d', strtotime('+1 saturday', strtotime($enddte))); this code doesn't seem give me previous sunday , next saturday relative date given i'm wondering if i'm doing wrong. date_create_from_format returns datetime object, not string should run through strtotime ...: $date = date_create_from_format('j-n-y', $enddate); $startdate = clone $date; $startdate->modify('-1 sunday'); $enddate = clone $date; $enddate->modify('+1 saturday'); echo $startdate->format('y-m-d').' => '.$enddate->format('y-m-d');

Adding django-pagedown to Django 1.5 Blog Comments -

i'd add django-pagedown site's blog. have site, , application called blog, built django, , i've implemented built-in comments. these work fine i'm trying django-pagedown work in comments. example, if user comments on 1 of articles, able support markdown users comment code snippets or formatting without using html (which don't want support). i installed django-pagedown pip: pip install django-pagedown i added installed_apps section in settings.py , collected static files: installed_apps = ( ... 'pagedown', ... ) python manage.py collectstatic something happened, because when added code blog/admin.py file admin post preview window appeared: ... pagedown.widgets import pagedownwidget, adminpagedownwidget django.db import models .... class postadmin(admin.modeladmin): ... formfield_overrides = { models.textfield: {'widget': adminpagedownwidget }, } ... since i'm not familiar django yet, do

c# - Trouble with INSERT INTO statement -

i can't seem figure out why keep getting syntax error in insert statement . the code below. static void abschangeeventstable(string controlnumber, string currentstatus) { using (var connection = new oledbconnection(straccessconnabstracting)) using (var command = connection.createcommand()) { connection.open(); command.commandtext = "insert events (date_time, details, regarding, user, control_number) values (@date_time, @details, @regarding, @user, @control_number)"; command.parameters.addwithvalue("@date_time", datetime.now); command.parameters.addwithvalue("@details", "old:"+currentstatus+" new: received fax"); command.parameters.addwithvalue("@regarding", "status changed"); command.parameters.addwithvalue("@user", "system"); command.parameters.addwithvalue("@control_number", controlnumber); try

php - Online Admissions System -

i working on online admissions system in mysql , php. i need save applicant's personal academic details. far have created 1 table save personal details applicant id (auto increment) primary key. academic details bit confused. fields required academic details are: degree level (like master, bachelor, high school); roll no; subjects; grade; institution; percentage; degree image (image field save scanned copies of transcripts). i not know how relate these 2 tables. uploading image files (scanned copies of transcripts) affect database performance? you have 2 tables applicants id | name | address | etc, etc academicdetails id | applicantid | degree | rollno | degreeimageurl | etc, etc to list applicants select * applicants to search specific applicant name. select * applicants name = 'tom jones' to select applicant id=1 , academic details use join select * applicants join academicdetails on academicdetails.applicantid=applicants.id appl

sqr - Addressing both commas and double quotes in a CSV -

i writing report in sqr produces csv output file. while testing, ran instance following string used in 1 of fields: table - 210" x 60" x 29", oak, i have double quotes surrounding string. when use method, output produced this: col 1 |col 2|col 3 table - 210 x 60" x 29" | oak | , obviously, entire line should fit in first column. i understand it's possible use other delimiters, prefer keep comma delimiter. know of way address issue? here simplified version of current code: let $asset_descr = '"' || &dep_asset.descr || '"' let $string = $asset_descr write 1 $string i able solve after lot of searching , testing. in order fix this, replaced each double-quote 2 double-quotes. having 2 double-quotes treats double-quote 'escape value'... guess means double-quote not treated closed quote. this might sqr specific solution. simplified code solution: let $as

c++ - Reconstructing integers using bit mask -

i quite new bit masking , bit operations. please me understanding this. have 3 integers a, b, , c , have created new number d below operations: int = 1; int b = 2; int c = 92; int d = (a << 14) + (b << 11) + c; how reconstruct a, b , c using d? a 0000 0000 0000 0000 0000 0000 0000 0001 b 0000 0000 0000 0000 0000 0000 0000 0010 c 0000 0000 0000 0000 0000 0000 0101 1100 a<<14 0000 0000 0000 0000 0100 0000 0000 0000 b<<11 0000 0000 0000 0000 0001 0000 0000 0000 c 0000 0000 0000 0000 0000 0000 0101 1100 d 0000 0000 0000 0000 0101 0000 0101 1100 ^ ^ { } b c = d>>14 b = d>>11 & 7 c = d>>0 & 2047 way ,you should make sure b <= 7 , c <= 2047

Is mapping a 'GET' request to 'controller#destroy' in Rails routes.rb dangerous/bad practice? -

i'm wondering convention regarding use of requests mapped 'destroy' actions in rails. checking out railscast on authentication , ryan chose map request sessions#destroy action link using simple anchor tag, rather form_for/button_to helper generate button contains _method: delete attribute: auth::application.routes.draw "log_in" => "sessions#new", :as => "log_in" "log_out" => "sessions#destroy", :as => "log_out" "sign_up" => "users#new", :as => "sign_up" root :to => "users#new" resources :users resources :sessions end i under impression not how supposed done, ryan bates 1 of creators of rails i'm wondering if big of deal i've been made believe. are there serious downsides kind of routing implementation or stylistic convention meant promote clarity? you're violating spec http/1.1 if use destroy a

xpath, how to select more than one item using indices -

in query, select 3rd //tablecontainer/table/tbody/tr/td[3] how select both 3rd , 4th 's? to both 3rd , 4th td s, can use expression: //tablecontainer/table/tbody/tr/td[position() >= 3 , position() <= 4]

angularjs - Angular and Breeze fetchMetaData -

i'm curious if there alternatives fetching meta data breeze when using angular. since $q , q promises don't play nice each other decided use q.js promises , not $q. in controller i'm checking if metadatastore empty: if (maindataservice.manager.metadatastore.isempty()) { $log.info('metadatastore empty') ; maindataservice.getmetadata() .then(function () { enablecreatebutton(); }); } the basic idea if don't have meta data go fetch , enable buttons allow me create new record. to accomplish define q promise in data service after breeze resolves promise resolve promise. function getmetadata() { var mymetadatapromise = q.defer(); q.delay(0).then(function () { manager.metadatastore.fetchmetadata(servicename).then(function () { mymetadatapromise.resolve(); }); }); return mym

c++ - Template deduction of pointer-to-array-member's size -

sometimes convenient template function deduce size of constant array when array passed reference. template <unsigned n> void foo (int (&arg) [n]); int data [3]; foo (data); // deduces n=3 now want perform deduction on pointer array member. should give idea struct x { int inner_data_1 [3]; int inner_data_2 [4]; }; template <typename t, unsigned n> void bar (int t ::* (& arg1) [n], int (& arg2) [n]) { // in example below: // arg1 should pointer x::inner_data_x // arg2[i] should value of outer_data_x[i] // , want pointer x::inner_data_x[i] } int main () { x x; int outer_data_1 [3]; int outer_data_2 [4]; bar (& x::inner_data_1, outer_data_1); bar (& x::inner_data_2, outer_data_2); // should create compile error because n mismatched //bar (& x::inner_data_1, outer_data_2); } i'm not expressing correctly, think type of arg1 in bar "array[n] of pointer-to-member-of-t"

c# - Reflection - Access custom attributes by name -

i'm attempting see if given method decorated attribute, (the attribute in question nunit.framework.testattribute ) need able check attribute regardless of version attribute is. currently, have nunit.framework.dll version 2.6.2 in project using reflection, , version 2.6.0 of dll in test. reflection not finding attribute. is there way do bool istest = method.getcustomattributes(typeof(testattribute), true).length > 0; without having access correct version of testattribute dll? where method of type methodinfo . you can attributes , filter name: method.getcustomattributes(true) .where(a => a.gettype().fullname == "nunit.framework.testattribute");

javascript - "SELECT MAX(rowid) FROM table" query works only after "SELECT * FROM table" has been called -

the below function in javascript file. intent return maximum value in rowid column of sqlite database. currently, works after "select * table query" has been run. why this? function lastrecord(){ db.transaction(function (tx) { tx.executesql('select max(rowid) mr surveys', [], function(tx, results){ var maxrowid = results.rows.item(0).mr; alert(maxrowid); }); }); } i appreciate clarification regarding needs loaded select max(rowid) show correct max rowid value every time function called. standard format (structure) implementing max function? thanks. have tried using order , limit? select rowid mr surveys order rowid desc limit 1 might work better you.

c# - Removing special characters from strings in a List -

i have list<string> names = new list<string>{"asa","@!","~!@#$%^tryt","asas**)_+lk"};//just example...will populated @ run time list<string> unsupportedcharacters = new list<string> { "~", "!", "#", "$", "%", "^", "&", "*"}; now want remove unsupported characters each string in "names" list. foreach loop , checking each string wondering if there better way of achieving this? may using linq ? question edit how if have replace unsupportedcharacters single space character..so "my@@naame!@%%is~~foo" should converted "my name foo"?ofcourse strings still in list "names" edit 2 solved using regex.replace() better way . not sure. different way? maybe. var names = new list<string> { "asa", "@!", "~!@#$%^tryt", "asas**)_+lk" }; var unsuppo

java - Drawing textured quads OpenGL not working -

i trying render group of textured quads. i can colored quads render, not textured ones (screen comes empty.) i using lwjgl , pngdecoder. code initializing ogl: gl11.glmatrixmode(gl11.gl_projection); gl11.glloadidentity(); gl11.glortho(0, 800, 0, 600, 1, -1); gl11.glmatrixmode(gl11.gl_modelview); gl11.glenable(gl11.gl_texture_2d); code decoding image: bytebuffer buffer = null; inputstream in = classloader.getsystemresourceasstream(filename); try { buffer = decodestreamtobuffer(in); } { in.close(); } return buffer; my decodestreamtobuffer(inputstream in) : pngdecoder decoder; bytebuffer buf = null; try { decoder = new pngdecoder(in); buf = bytebuffer.allocatedirect(4*decoder.getwidth()*decoder.getheight()); decoder.decode(buf, decoder.getwidth()*4, format.rgba); buf.flip(); } catch (exception e) { e.printstacktrace(); } return buf; my rendering code: gl11.glclear(gl11.gl_color_buffer_bit | gl11.gl_depth_buffer_bit); gl11.glcol

list - Python - How do you assign a variable to a table displayed on seperate lines -

sorry horrible title. im trying here import pyperclip y = [] x in range(1,158): y.append("- " + str(x)) pyperclip.copy(y) what table, when copied clipboard pasted left right want elements of list pasted downward so instead of 1 2 3 4 5 i'd get 1 2 3 4 5 is there anyway this? you need newline characters, '\n' , in string. try this import pyperclip y = [] x in range(1,158): y.append("- " + str(x) + '\n') pyperclip.copy(y) a more pythonic way be import pyperclip y = '\n'.join('- ' + str(x) x in range(1, 158)) pyperclip.copy(y)

javascript - Jquery variable not instantiated until click event -

problem: element not 'maxing' until user double clicks on red square. basically variable 'clicked' being instantiated onclick instead of being instantiated before hand. resulting behavior user has click once 'clicked' variable instantiated , function works desired. here jsfiddle and important sections of code: var container = $(this).parents('.container'); var paragraph = $(container).find('.text'); if (this.clicked == 0) { container.removeclass("large-4"); container.addclass("large-8"); paragraph.removeclass("hide"); this.clicked = 1; } any appreciated thanks! details (don't have read :d): the reason i'm doing inverted selection (selecting child element , parent element) because there many of these '.container' elements , each 1 needs have same respective min/max functionality clicking on minmax icon. obviously method not referencing single local 'clicked'

Parsing with Python -

i attempting parse file. currently, have file: word1 52345325 word2 12312314 word3 7654756 word4 421342342 i attempting store word1 word2 word3 , word4 array , numbers adjacent words array. so if a[0] should word1 , , if b[0] should 52345325 , on. i thinking making key-valued pair dictionary object may little complex @ point getting python. i doing of course, ain't working :p def csvstringparser(): = {} b = {} = 0 f = open('/users/settingj/desktop/noxmultiplier.csv') line in f.readlines(): reader = csv.reader(line.split('\t'), delimiter='\t') row in reader: #print '\t'.join(row) #print

terminal - iterm2 zshell cmd+click open to github diff page -

i have been researching how change behavior day no luck, here goes. is there way in iterm2, when viewing git logs, change way cmd+click functions on git log hash? ideally, hoping cmd+click would open browser window correct github url change set viewed. if not possible, please let me know. believe helpful others, wish had magic wand figure out how configure this. thoughts? while not ideal, here how able work around issue. built commit hook! not perfect, know. ideas? #!/bin/sh # # automatically adds branch name , branch description every commit message. # edit .git/hooks/commit-msg & make sure excutable chmod +x # requires git config --add remote.github.url {value} # name=$(git branch | grep '*' | sed 's/* //') description=$(git config branch."$name".description) text=$(cat "$1" | sed '/^#.*/d') git_commit_short_id=$(git rev-parse --short head) git_commit_id=$(git rev-parse head) git_github_url=$(git config --get re

GWT: how to get FlexTable width? -

hello all) task looked pretty easy - flextable's width , set width scrollpanel rid of horizontal scrollbar - until figured out method table.getelement().getclientwidth() returns 0. maybe smth wrong way - create table, fill data call int tableheight = table.getelement().getclientwidth(); , int 0 despite table looks normal in browser , width 310 px. thanks lot help. if want width flextable has, can use: table.getelement().getstyle().getwidth(); but return width set it. set width, can use: table.setwidth(); note : getwidth() method return whatever css width table has, whether or not set programmatically. also, getclientwidth() give width of table after attached parent widget, why why returning 0 you.

c# - Horizontal text alignment in a PdfPCell -

i using code align horizontally. cell = new pdfpcell(); p = new phrase("value"); cell.addelement(p); cell.horizontalalignment = pdfpcell.align_center; //tried element.align_center also. tried adding line before adding element also. table.addcell(cell); it's not working. i creating table 5 columns in , adding cells dynamically in runtime in loop above code. want cells content centered. try this, cell = new pdfpcell(); p = new phrase("value"); cell.addelement(p); cell.horizontalalignment = element.align_center; //tried element.align_center also. tried adding line before adding element also. table.addcell(cell);

How to git blame to see what code from a single committer before X date has survived? -

i joined experienced developer team complete ror newb year ago , we're trying guess how of code wrote in first 6 months has survived. i think can use git blame on entire repo , grep username i'm hitting wall. there many git statistics tools, maybe see if job need? click here , here . edit: i went discover 1 of these tools , found suits you. gitinspector , following it's text output format: $ ./gitinspector.py -wthl /path/to/some/git/repository following historical commit information, author, found in repository: author commits insertions deletions % of changes john smith 288 7721 4617 39.19 james johnson 135 8910 2422 35.99 robert brown 71 2564 1352 12.44 michael davids 134 2943 954 12.38 below number of rows each author have survived , still intact in current revision: author

How do I extract information from inner parameters in Haskell? -

in of programming languages support mutable variables, 1 can implement java example: interface accepter<t> { void accept(t t); } <t> t getfromdoubleaccepter(accepter<accepter<t>> acc){ final list<t> l = new arraylist<t>(); acc.accept(new accepter<t>(){ @override public void accept(t t) { l.add(t); } }); return l.get(0); //not being called? exception! } just not understand java, above code receives can can provided function takes 1 parameter, , supposed grape parameter final result. this not callcc : there no control flow alternation. inner function's parameter concerned. i think equivalent type signature in haskell should be getfromdoubleaccepter :: (forall b. (a -> b) -> b) -> so, if can gives function (a -> b) -> b type of choice, must have a in hand. job give them "callback", , keep whatever sends in mind, once returned you, return tha

jquery - Adding current class to div on link click -

what best way add current class .navimg divs (next li) when parent link clicked? html: <div id="navbox"> <ul id="navigation"> <li id="home"><a href="#">home</a></li> <div id="imghome" class="navimg current"></div> <li id="corp_gov"><a href="#">corporate <br /> governance</a></li> <div id="imggov" class="navimg"></div> <li id="board"><a href="#">board &amp; <br /> directors</a></li> <div id="imgboard" class="navimg"></div> <li id="permit"><a href="#">permit <br /> details</a></li> <div id="imgpermit" class="navimg"></div> <li id=

java - How to take first word of new paragraph into consideration? -

i'm trying build program takes in files , outputs number of words in file. works when under 1 whole paragraph. however, when there multiple paragraphs, doesn't take account first word of new paragraph. example, if file reads "my name john" , program output "4 words". however, if file read"my name john" each word being new paragraph, program output "1 word". know must if statement, assumed there spaces before new paragraph take first word in new paragraph account. here code in general: import java.io.*; public class helloworld { public static void main(string[]args) { try{ // open file first // command line parameter fileinputstream fstream = new fileinputstream("health.txt"); // use datainputstream read binary not text. bufferedreader br = new bufferedreader(new inputstreamreader(fstream)); string strline; int word2 =0;

Signalr webfarm with Backplane out of sync -

we have signalr application built , tested use on single web server. requirements have changed , need deploy application webfarm. signalr supports several backplanes, since application uses sql server have implemented. introduction of second web node ran issue keeping data cached within hub synced between nodes. each hub has internal cache in form of dataset. private static dataset _cache; cache gets populated when client first requests data, , there interaction updates local cache , sql server, notifies connected clients of changes. the backplane handles broadcast messages between clients other node not receive message. our first thought there might method wire triggered backplane sending message nodes clients, have not seen such thing mentioned in documentation. our second thought create .net client within hub. private async void connecthubproxy() { ihubproxy eventviewerhubproxy = _hubconnection.createhubproxy("eventviewerhub"); eventvi

ServiceStack IAuthSession empty after authentication with FacebookAuthProvider -

Image
i'm trying user data through iauthsession after doing authentication facebook, when try user request.getsession(true) returns authusersession (implements iauthsession) partial subset of data following: i'm trying use in service method [clientcanswaptemplates] [defaultview("dashboard")] public dashboardresponse get(facebookrequest userrequest) { var user1 = request.getsession(true); return new dashboardresponse(); } i've added auth providers apphost follows: plugins.add(new authfeature(() => new authusersession(), new iauthprovider[] { new facebookauthprovider(appsettings), new twitterauthprovider(appsettings), new basicauthprovider(appsettings), new googleopenidoauthprovider(appsettings), new linkedinauthprovider(appsettings), new credentialsauthprovider() })); as far know fac

Autohotkey Switch left and right mouse buttons -

im windows8 user, , im trying switch left , right buttom inside irfanview (picture viewer application) because default pan left mouse buttom, in irfan view right mouse buttom, want whenever hold down left mouse button, send hold down right mouse buttom instead. have tried macro: works inside irfanview affect windows desktop, , other programs also. #noenv #singleinstance, force #persistent #installmousehook #ifwinactive ahk_class irfanview lbutton::rbutton rbutton::lbutton #ifwinactive ahk_class fullscreenclass lbutton::rbutton rbutton::lbutton could please give me advice, pehaps conditional?? thanks advanced. the behavior seeing due fact 1 of selected windows activated, , trying click on window. the solution make hotkeys use window class mouse on instead of active window. i've included function , how use below: #if (mouseisoverclass("irfanview") or mouseisoverclass("fullscreenclass")) , !mouseisovercontrol("irfanviewerclass1")

screen - Libgdx background and foreground in single stage -

my requirements: background filling entire physical screen (stretching if required) preserve aspect ratio of foreground assets (work virtual width , height) for this, use 2 stages in screen shown in code below. public void render(float delta) { backgroundstage.act(delta); backgroundstage.draw(); foregroundstage.act(delta); foregroundstage.draw(); } public void resize(int width, int height) { background.setwidth(width); background.setheight(height); backgroundstage.setviewport(width, height, true); foregroundstage.setviewport(maingame.width, maingame.height, true); foregroundstage.getcamera().position.set(-foregroundstage.getgutterwidth(),-foregroundstage.getgutterheight(),0); } in tutorials have read, have seen 1 stage being used each screen. so, how fulfill both requirements in single stage? expensive have separate stages? (i have read spritebatch objects heavy!) this how solved problem: to rid of background stage, update

sql - Performance selecting rows not matching entry in another table when NULL is present -

related question: how select rows no matching entry in table? i trying select rows using method , couldn't work in sqlite. after bit of wrangling occurred me reason might there null values in fields. sure enough, right, , when changed = is in query below things started behaving expected: create temp table newevent(id integer,t integer,name,extra,extra2,extra3); insert newevent(id,t,name,extra,extra2,extra3) values (0, 1376351146, 'test', null, null, null), (0, 1376348867, 'old', null, null,null); select n.id,n.t,n.name,n.extra,n.extra2,n.extra3 newevent n left join event e on n.t = e.t , n.name e.name , n.extra e.extra; , n.extra2 e.extra2; , n.extra3 e.extra3 e.id null; drop table newevent; in above example, there existing record in table event name='old' . new

c# - Object reference is not set -- WPF -- Rows Deletion -

Image
i using wpf , devxpress. made 2 operations in application add , delete row grid. both working fine. if drag drop column deletion stops work delete multiple rows @ same time. here code , image, please answer query. private void deletebutton_click(object sender, routedeventargs e) { if (dxmessagebox.show("are sure, want delete?", "delete item-confirmation", messageboxbutton.yesno, messageboximage.question) == messageboxresult.yes) { try { myentities dbcontext = new myentities(); name per = grid.selecteditem name; dbcontext.names.remove(per); dbcontext.savechanges(); refresh(); } } catch (exception ex) { dxmessagebox.show(ex.message.tostring()); }}} where code below working fine delete single row: name per = grid.selecteditem name; dbcontext.names.remove(per)

oracle - SQL Insert calculated average value from another table -

i tried insert calculated average table table writing sql below didnt work. can please me out ? how can write stored procedure in oracle cater many states i.e. ca, il, ga, wi .... ? insert employee(averagesalary, averagetax) (select avg(salary), avg(tax) hrdeptemployee state = 'ny') leave off parentheses around select, not subselect. edit: second question in comment (error: null value of id column of target table): add id insert select list (assuming want use id 1 ): insert employee(id, averagesalary, averagetax) select 1, avg(salary), avg(tax) hrdeptemployee state = 'ny'

vb.net - Specific sorting of a multidimensional array -

i'm translating vba project vb.net. , have little issue sorting of datatable. my table : ... | ... | firstname3 | name3 | pay3 | firstname1 | name1 | pay1 | firstname2 | name2 | pay2 |... ... | ... | firstname2 | name2 | pay2 | firstname3 | name3 | pay3 | firstname1 | name1 | pay1 |... and on... export 56 columns needed datatable array , try sort horizontaly on name. did way in vba : public sub sorttable(byref aggtab(,) object, byval columntosorton integer, byval lowervalue byte, byval uppervalue byte) dim ref object = aggtab((lowervalue + uppervalue) \ 2, columntosorton) dim reflowervalue byte = lowervalue dim refuppervalue byte = uppervalue dim temp object while aggtab(reflowervalue, columntosorton) < ref reflowervalue = reflowervalue + 1 loop while ref < aggtab(refuppervalue, columntosorton) refuppervalue = refuppervalue - 1 loop if reflowervalue <= refu

html - What are ways to minimize popup window using javascript? -

i have popup window.there screenshot functionaltity being done in popup there's button in popup window take screenshot,on click of button screenshot of entire page taken plus in screenshot popup comes dont want how rid of popup.i dont want use window.close cause need popup want minimize popup window programmatically using javscript ideas?

android - contextual action mode in fragment - close if not focused? -

Image
i implemented contextual action mode bar in nested fragement. fragment part of view pager , view pager fragment , part of navigation drawer. my problem: want close contextual action mode bar if fragment no more focused. so, if swipe through view pager action mode bar should close. if use onpause() method of nested fragment, method not called directly. waits until swiped 2 or 3 times forward... here pictures: in second picture can see action mode bar still there. question is: in method should call actionmodebar.finish() method, close directly action mode bar if leave fragment? maybe code of fragment helps you: public class editorfragment extends fragment { private static final string key_position="position"; listview listview; private boolean ismultiplelist = false; private actionmode acmode; private int counterchecked = 0; private actionmode.callback modecallback = new actionmode.callback() { public boolean onprepareactionmode(actionmode m

bash - Fast way of finding lines in one file that are not in another? -

i have 2 large files (sets of filenames). 30.000 lines in each file. trying find fast way of finding lines in file1 not present in file2. for example, if file1: line1 line2 line3 and file2: line1 line4 line5 then result/output should be: line2 line3 this works: grep -v -f file2 file1 but very, slow when used on large files. i suspect there way using diff(), output should just lines, nothing else, , cannot seem find switch that. can me find fast way of doing this, using bash , basic linux binaries? edit: follow on own question, best way have found far using diff(): diff file2 file1 | grep '^>' | sed 's/^>\ //' surely, there must better way? you can achieve controlling formatting of old/new/unchanged lines in gnu diff output: diff --new-line-format="" --unchanged-line-format="" file1 file2 the input files should sorted work. bash (and zsh ) can sort in-place process substitution <( ) : diff -

installing kobo with python creates path errors -

i have python 2.7.3 installed on system trying install kobo module. path module located is: c:\users\nelson.menezes\desktop\new softwares\kobo-0.3.6 .i opened command promt , set above mentioned path. specified run following command install kobo. python setup.py install but gives me following error file "c:\python27\lib\distutils\util.py", line 204, in convert_path raise valueerror, "path '%s' cannot absolute" % pathname valueerror: path '/usr/bin' cannot absolute i know error generated due path problems. cannot figure out how resolve it. great if in possible way. rights ask questions have been removed. editing question in order resolve problem. sorry inconvenience need error resolved. ok, opened jira bug tracking tool , here using: project issue type (bug, improvement, new feature) summary priority (blocker, critical, major, minor, trivial) affects version/s fix version/s description attachment field component/s

html - set innerHTML of div tag under li tag in javascript -

i have below html , want add innerhtml of div tag. <li id="liflashdetectionmessage" class="width730 height30 divfloatleft marginleft15"> <div id="divflashdetectionmessage" class="divfloatleft marginleft5 width730"> </div> </li> i have written below giving javascript error. document.getelementbyid("divflashdetectionmessage").innerhtml = "oops, flash player not installed on browser."; can how it? without having seen full code, bet code run before dom ready. since browser parse code top bottom , execute javascript immediately, if <script> tag put before actual <div> element try manipulate, in source, won't find match when run document.getelementbyid() because @ time piece of code execute, browser still doesn't know tag declare further down page. try moving script-element bottom of page, before closing </body> tag. if can't/don't want