Posts

Showing posts from March, 2010

java - "Null object" error when setting a adapter -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i'm getting error when set adapter. have listview id lv_cine in view. edit 1: added wrong codes same this. edit 2: ok managed past first error, i'm getting similar one: 12-01 20:43:44.445 7617-7617/com.example.maria.maria e/androidruntime﹕ fatal exception: main process: com.example.maria.maria, pid: 7617 java.lang.nullpointerexception: attempt invoke interface method 'int java.util.list.size()' on null object reference @ android.widget.simpleadapter.getcount(simpleadapter.java:93) @ android.widget.listview.setadapter(listview.java:487) @ com.example.maria.maria.cinema$getcontacts.onpostexecute(cinema.java:146) @ com.example.maria.maria.cinema$getcontacts.onpostexecute(cinema.java:67) @ android

string - MATLAB: populate cell array and format number -

what's efficient way populate cell array values vector (each formatted differently). for example: v = [12.3 .004 3 4.222]; desired cell array: array = {'a = 12.30' 'b = 0.004' 'c = 3' 'd = 4'}; is there easier way calling sprintf each , every cell? array = {sprintf('a = %.2f',v(1)) sprintf('b = %.3f',v(2)) ... } there's no vectorized form of sprintf supports different formats, you're stuck sprintf call per cell. arrange code easier deal in loop. v = [12.3 .004 3 4.222]; names = num2cell('a':'z'); formats = { '%.2f' '%.3f' '%d' '%.0f' }; c = cell(size(v)); = numel(v) c{i} = sprintf(['%s = ' formats{i}], names{i}, v(i)); end it tricky faster naive way without dropping down java or c, because it's still going take sprintf() call each cell, , that's going dominate execution time. if have large number of elements , relatively sma

C: write (and then read) a string to file using a hash function to locate the byte's position -

i want write 1kb file, , want use hash function calculate position of byte i'm going write. want able later retrieve data in correct order. to locate position of byte read/write use hash function f = (index*prime) mod 1024 where index index in string, , prime prime number need avoid collisions, i.e. not rewriting 2 times in same position. f, strlen (b first create file dd bs=1024 count=1 if=/dev/zero of=test.fs and after compile , run program passing "w" parameter $ ./a.out w now, seems me write() function job correctly, because if do... $ cat test.fs or $ hexdump test.fs ... can see content of file consistent string inserted! however, if run read-mode passing "r" parameter, curious random output, seems me if i'm reading thrash memory. cannot understand read() function fails, thank in advance. the c code follows: #include <stdio.h> #include <string.h> #define prime 7919 int main(int argc, char *argv[]) { int

git - How Do Unmerged Paths in Index Occur -

in "git status" man page, there table describes meaning of xy status code when short-format or porcelain format used. specifically, table is: x y meaning ------------------------------------------------- [md] not updated m [ md] updated in index [ md] added index d [ m] deleted index r [ md] renamed in index c [ md] copied in index [marc] index , work tree matches [ marc] m work tree changed since index [ marc] d deleted in work tree ------------------------------------------------- d d unmerged, both deleted u unmerged, added u d unmerged, deleted them u unmerged, added them d u unmerged, deleted unmerged, both added u u unmerged, both modified ------------------------------------------------- ? ? untracked ! ! ignored ------------------------------------------

r - Require lib.loc and Required base packages -

say have set of external packages in folder x . , want load 1 of these packages, example through require(my.package, lib.loc='x') any requirement (dependency) of my.package external, looked in same folder x . base packages? need copy base packages folder x or r fallback default folder despite different lib.loc specified? so tried right new set , observed @ least on mac os x, base packages still included default lib path.

scala - Access data files in production play server -

i have play in scala application directory structure looks this: app conf data <- added manutally logs project public target test the data directory have manually added, contains number of json files application depends on. getting hold of them in code seems easy enough, , works when run "play run". code use reference them: val projectroot = play.application.path.getabsolutepath val statfiles = new file(projectroot + "/data/"+tier+"/usage").listfiles however, when run "play start" nullpointerexceptions, stack trace looks this: caused by: java.lang.nullpointerexception: null @ scala.collection.mutable.arrayops$ofref$.length$extension(arrayops.scala:192) ~[org.scala-lang.scala-library-2.11.1.jar:na] @ scala.collection.mutable.arrayops$ofref.length(arrayops.scala:192) ~[org.scala-lang.scala-library-2.11.1.jar:na] @ scala.collection.seqlike$class.size(seqlike.scala:106) ~[org.scala-lang.scala-library-2.11.1.jar:na] @ sc

How to accept two connections using sockets in Python -

i working on chat program. right can except 1 client. how make can accept 2 clients? still bit of noob when comes sockets can explain thoroughly? server code: import socket def mainfunc(): host = "" port = 50000 iplist = [] nicknamelist = [] num = true s = socket.socket() s.bind((host, port)) s.listen(1) c, addr = s.accept() print("connection from: " + str(addr) + "\n") iplist.insert(0, str(addr)) while true: data = c.recv(1024) if not data: break if num == true: nicknamelist.insert(0, str(data)) num = false else: print("from " + nicknamelist[0] + ": " + str(data) + "\n") message = raw_input("message want send: ") print("\n") c.send(message) c.close() i have tried changing s.listen(1) s.listen(2). did not seem allow second

C++ Regex getting all match's on line -

when reading line line call function on each line looking function calls(names). use function match valid characters a-z 0-9 , _ '('. problem not understand c++ style regex , how through entire line possible matches?. regex simple , strait forward not work expected im learning c++ norm. void readcallbacks(const std::string lines) { std::string regxstring = "[a-z0-9]+\("; regex regx(regxstring, std::regex_constants::icase); smatch result; if(regex_search(lines.begin(), lines.end(), result, regx, std::regex_constants::match_not_bol)) { cout << result.str() << "\n"; } } you need escape backslash or use raw string literal: std::regex pattern("[a-z0-9]+\\(", std::regex_constants::icase); // ^^ std::regex pattern(r"([a-z0-9]+\()", std::regex_constants::icase); // ###^^^^^^^^^^^## also, character range doesn't contain desired underscore ( _ ).

What is the initial code for the string.split() function in python? -

i want know code .split() function in python (simple way nice). newb python , couldn't figure out myself. help? edit: here's have far... stringinput = str(input("give me string: ")) mylist = [] firstpointer = 0 secondpointer = 0 x in stringinput: secondpointer += 1 if (stringinput[firstpointer] == chr(32)):#ascii 32 space character stringinput +=1 mylist = stringinput[firstpointer, secondpointer] i presume doing learning exercise. after have read tutorial, imitating string methods 1 way learn. .split 1 of harder ones. s = '''this \tstring split''' sl = [] = none # start of 'word' j, c in enumerate(s + ' '): if c.isspace(): if not none: sl.append(s[i:j]) = none else: if none: = j print(sl) # ['this', 'is', 'a', 'string', 'to', 'be', 'split']

ios - Swift - Coding A Tie Function in Tic Tac Toe -

i'm 13 , trying follow swift tutorial brian advent. he's teaching me how simple tic tac toe game. i'm trying code tie function in swift after many hours of research found lot of code nothing me. this message winner: if winner != "" { //if winner let alert = uialertcontroller(title: "tic tac toe", message: "the winner \(winner)!", preferredstyle: uialertcontrollerstyle.alert) alert.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: { (alert:uialertaction!) -> void in //todo reset fields self.resetfield() })) self.presentviewcontroller(alert, animated: true, completion: nil) } and message in case of tie: else if winner == "" { let alert = uialertcontroller(title: "tic tac toe", message: "it tie", preferredstyle: uialertcontrollerstyle.alert) alert.addaction(uialertaction(title: "ok", style: uialertactionstyle.

JavaScript: XML DOM Load Error -

i have problem load xml file (xml dom load),using javascript so,whene this: var xmlfile=loadxmldoc("test.xml"); it load correct , can use , exploit it. whene spécifie xml filename load input value(xml filename load=input value) this: dosn't work , need solution please ... var usr = document.getelementbyid('user').value+".xml"; //exemple:if (input id="user" value)="test", result "test.xml" var xmlfile=loadxmldoc(usr); //load "test.xml" file ... its dosn't work , need solution please

mips - How do I print a specific bit of a number? -

i'm struggling question: prompt user enter number, print number in 16-bit two's complement to print number print each bit either string "1" or string "0", using loop print 1 bit in each iteration. start printing bit 15. (recall number bits starting 0 @ low order bit.) in loop test bit 15, , print either "1" or "0". use shift instruction next bit position 15 before repeating. i unfortunately missed lecture shifts , using masks, don't have understanding of how go doing lab. how can print specific bit of number? understand keep printing bit 15, , doing shift left, have no idea done in mips. appreciated. edit: i understand shifting perfectly, it's printing bit thats confusing me. for example, if number wanted convert two's complement 25 , in register $t0. first print 15th bit. shift left. , repeat 15 times. it should this: # print bit sll $t0, $t0, 1 i don't how print first bit @ s

joomla3.3 - Event Handling in Joomla Custom Component -

i want ask expert joomla devs out there, event handling(dropdown values etc.) on how coded? in .net(vb/c#) there custom event handler every control in user interface during development (e.g button1_click). references? there aspects answer. firstly, need make sue comparing .net web development joomla web development here. surprised every click on .net control can hooked callback architecture, again not .net developer. joomla has event trigger system, can used in conjunction joomla plugins, see here: http://docs.joomla.org/plugin/events on top of this, many more complex components define own events, examples jevents , jseblod

python - Detecting triangles using hough transforms -

Image
how go detecting triangle (of known shape) in image. environment uncluttered , free of other objects. here example i have looked hough transforms, used houghlines detect lines , simple python logic trying make triangles out of them. resulted in loot of noise, , impossible find correct triangle. how go this? have tried using contrast? if image above representative example, contrast white black , green gives distinctive feature recognised. make sure threshold image before applying edge detection. you try mapping lines found contrast triangle of specific size wanted (i notice mentioned mapping triangles, no mention of using size). note size constraint affected distance of camera object. also, if have full control on object detection (as looks using detect of own making), add other shapes within triangle, or more contrast layers. full circles shape use (as noise won't have complete loop)

c# - asp.NET controller does not seem to be executing in proper order -

Image
i using jquery file upload plugin , posting zip files controller. happening execution order cannot seem figure out. when set debug point @ top seems jump on place in controller , because of this, code not seem working think should. here post: $('#fileupload').fileupload({ url: '/fileupload/import', add: function (e, data) { var filesubmit = data.submit() .success(function (result, textstatus, filesubmit) { var name = data.files[0].name; filevalidation(name, textstatus); }) .error(function (filesubmit, textstatus, errorthrown) { var name = data.files[0].name; filevalidation(name, textstatus); }); }, done: function (e, data) { $.each(data.files, function(index, value){ if (value.name == "") { alert("error uploading: " + value.name + ". " + failstatus);

javascript - HTML5 drag and drop, "drop" event not firing in Firefox -

despite reading mozilla developer network docs carefully, , answers find on stack overflow, still cannot html5 drag , drop working in firefox. using in angularjs app. works fine in chrome , internet explorer, not in firefox (v33.1). rather not have resort using jqueryui. hopefully can spot here missing. can see in code below, have added console.log() calls each event handler check make sure each event firing expected. in firefox, of events fire except "drop" event. here simplified version of code: var assignevents = function() { var rows = angular.element('.row'); if (self.rows.length > 0) { // event handlers rows angular.foreach(self.rows, function(row, key) { angular.element(row) // clear existing bindings .off('dragstart') .off('dragenter') .off('dragover') .off('dragleave') .off('drop') .off('dragend') // add bindings .on('dragst

windows 7 - git commit error with sublime text 2 -

this question has answer here: how can make sublime text default editor git? 13 answers i'm taking course "how use git , github" on udacity. i'm following along examples i've run problem. i've been @ trying fix problem via googling , trial , error myself 2 hours. think it's time make stackoverflow post. prefer trying figure out issue without posting on stackoverflow, seems @ point, i'm not being productive , i'm sure issue gotcha more experienced developer , save hours posting here, here am. i've found forum posts on varying sites similar issues mine , have followed appropriate action no avail. appreciate or guidance. so, learning git , doing our first git commit. i'm on windows 7. i'm using git bash navigate through directories on computer , git commands. course had set default editor git sublime text 2 command...

android - Showing only one DialogFragment -

i trying set dialog fragment pops when android user receives push notification. code have below triggers dialog. issue running if users multiple pushes, see multiple dialog boxes popup. my desired action show 1 dialog box , if 1 pops before current 1 closed, current 1 should destroyed , new 1 shown. public abstract class baseactivity extends actionbaractivity { public void showshiftsdialog(string time) { string dialog_alert = "dialog_alert"; fragmenttransaction transaction = getfragmentmanager().begintransaction(); android.app.fragment prev = getfragmentmanager().findfragmentbytag(dialog_alert); if (prev != null) transaction.remove(prev); transaction.addtobackstack(null); // create , show dialog dialogfragment newfragment = shiftsdialogfragment.newinstance(time); newfragment.show(getsupportfragmentmanager().begintransaction(), dialog_alert); } } i have tried using code android docs ( http://developer.android.com

Binary files on c -

trying save array of structs in binary file. think need for. typedef struct { int y, o; }num; int main(){ num numbers[10]; (i = 0; < 10; i++){ numbers [i].y = i; numbers [i].o = * 2; } file *f; f=fopen("test","r+"); } if compatibility different architectures and/or compilers isn't of concern can write data ( in sense write load it). if have have compatiblity can't use method have write functions read , write on more abstract level. pass reference data first fwrite() , in case pointer numbers use sizeof() function on struct name in 2nd argument, tells function how big data is. sizeof(num) you use amount of indeces of array write correct amount file. have 10 10 . last file * see here short example: typedef struct { int y, o; }num; int main(){ num numbers[10]; (i = 0; < 10; i++) { // blow array bounds, fixed numbers [i].y = i; numbers [i].o = * 2; }

c# - Cannot access protected member? -

i learning c#, written below code not working. the protected members can accessble inheriting class, in below code not working can 1 please tell me doing mistake? class protecteddemo { protected string name; public void print() { console.writeline("name is: {0}", name); } } class demo : protecteddemo { static void main(string[] args) { protecteddemo p = new protecteddemo(); console.write("enter name:"); p.name = console.readline(); //here getting error. p.print(); console.readline(); } } from protected (c# reference) the protected keyword member access modifier. protected member accessible within class , derived class instances. so comment, accessible within protecteddemo or inheriting class demo and example class { protected int x = 123; } class b : { static void main() { a = new a(); b b = new b(); // error cs1540,

javascript - Iterating over jQuery selector with variable, using closures -

[first time on stackoverflow.] trying dynamically add html buttons page , give them javascript function run when clicked, using jquery's click. want have 1 button each element in array, used loop. code looks (simplified) for (var = 0; < results.length; i++) { $("#" + place[i].place_id).click(function(){console.log("test");}) $("#" + place[i].place_id).click(); } (i inject buttons right id's in same loop.) code, when run, console logs "test" right number of times, afterwards, last button responds "test" when clicked. (this situation little absurd.) so, think event handler ends using final value of assign event handler. think problem has closures, not sure how make closure out of jquery selector (and in general not familiar them). in contrast, hack solution, "manually" wrote code below right below , outside loop, , works expected, in clicking causes console log. $("#" + place[0].p

python - Unable to retrieve required indices from multiple NumPy arrays -

i have 4 numpy arrays of same shape(i.e., 2d). have know index of last array (d) elements of d smaller 20, indices of d should located in region elements of array(a) 1; , elements of array (b) , (c) not 1. i tried follows: mask = (a == 1)|(b != 1)|(c != 1) answer = d[mask | d < 20] now, have set regions of d 1; , other regions of d 0. d[answer] = 1 d[d!=1] = 0 print d i not solve problem. how solve it? import numpy np = np.array([[0,0,0,1,1,1,1,1,0,0,0], [0,0,0,1,1,1,1,1,0,0,0], [0,0,0,1,1,1,1,1,0,0,0], [0,0,0,1,1,1,1,1,0,0,0], [0,0,0,1,1,1,1,1,0,0,0], [0,0,0,1,1,1,1,1,0,0,0]]) b = np.array([[0,0,0,1,1,0,0,0,0,0,0], [0,0,0,0,0,0,1,1,0,0,0], [0,0,0,1,0,1,0,0,0,0,0], [0,0,0,1,1,1,0,1,0,0,0], [0,0,0,0,0,0,1,0,0,0,0], [0,0,0,0,1,0,1,0,0,0,0]]) c = np.array([[0,0,0,0,0,0,1,0,0,0,0], [

vb.net - Why won't this write to my text file in Visual Basic? -

i have been trying , searching hours , telling me doing, why won't code write text file? no errors being thrown, data won't write dim newday boolean = true dim attendance streamwriter if newday = true try attendance = file.appendtext("attendancelog.txt") attendance.writeline(date.today.tostring("dd/mm/yyyy")) newday = false catch messagebox.show("file access denied", "error") end try end if when using streamwriter , send put in queue avoid writing file everytime new part needs appended (which inefficient large files logs). to process queue, call streamwriter.flush() . but discouraged. should instead use streamwriter.close() @ end, automatically , disposes object memory, too. dim newday boolean = true dim attendance streamwriter if newday = true try attendance = file.appendtext("attendancelog.txt") attendance.

ios - Capturing blocks from method parameters in Kiwi? -

i'm working firebase ios sdk , , i'm struggling figure out how fully-test of firebase method calls using kiwi. i'm using instance of firebase "watch" path: firebase *streamsreference = [self.firebaseref childbyappendingpath:@"streams"]; and using streamsreference observe events: [streamsreference observeeventtype:feventtypechildadded withblock:^(fdatasnapshot *snapshot) { // stuff in block here }]; i want test effects of code in block. this i've got far: it(@"should handle incoming connections hook webrtc", ^{ id mockfirebaseclass = [kwmock mockforclass:[firebase class]]; // mock firebase object handle "/streams" path id mockfirebasestreamsreference = [kwmock mockforclass:[firebase class]]; // return streams reference object via mock firebase object [mockfirebaseclass stub:@selector(childbyappendingpath:) andreturn:mockfirebasestreamsreference]; // at

ios - FBDialog Photo Sharing issue -

i sharing photo usingfbdi presentsharedialogwithphotoparams / presentsharedialogwithphotos method in fbdialogs . method shares photo on wall returns error, meaning posts photos nserror. error like.... error domain=com.facebook.facebook.platform code=103 "the operation couldn’t completed. (com.facebook.facebook.platform error 103.)" userinfo=0x16d874f0 {error_code=103, error_description=an unknown error occurred., app_id=593434950703264, error_reason=( { result = 1; } )} why happen? i believe answer deleted previous one, anywho... the issue have been fixed!!!, update facebook app v20, released on december 8th. see: code=103 "the operation couldn’t completed ..." in share photo note: want add comment question don't have privilege that, add answer instead.

java - Variable's value doesn't change to the new one specified in the actionListener -

so created variable called savedname , set value of new value in action listener method. prints changed value in action listener in action listener. seems once action listener has taken place, variable's value changed "null" (the default value). username_txt text field user enters information. stated, value changed temporarily in action listener method seems , once action listener has taken place, changes default value. have bolded statements savedname. public class loginwindow extends javax.swing.jframe { /** * creates new form loginwindow */ connection conn = null; resultset rs = null; preparedstatement pst = null; **private string savedname;** public loginwindow() { initcomponents(); conn = javaconnect.connecrdb(); } private void jbutton2actionperformed(java.awt.event.actionevent evt) { // todo add handling code here: string user_sql = "select * users user

axapta - Ax 2012 tts error -

Image
hi facing error while updating record in invent table. using following sample code. static void job4(args _args) { csinvbomsplitqtycalchelper bomcalc; qty qty; inventtable inventtable; inventtable updateinventtable; bom bom; boolean result; bomid bomid; bomversion bomversion; itemid item = "1000m-3c-pcs"; select firstonly * bomversion bomversion.active == true && bomversion.itemid == item && csislengthitem(item) == false; if (0 != bomversion.recid) { select * bom bom.bomid == bomversion.bomid exists join inventtable bom.itemid == inventtable.itemid && inventtable.csislengthitem == true; }

How to group_by year in this type data in Ruby -

i want group year: [{"_id"=>{"year"=>2013, "month"=>8}, "count"=>69605}, {"_id"=>{"year"=>2013, "month"=>7}, "count"=>60620}, {"_id"=>{"year"=>2013, "month"=>12}, "count"=>56026}, {"_id"=>{"year"=>2014, "month"=>5}, "count"=>55067}, {"_id"=>{"year"=>2014, "month"=>4}, "count"=>51313}, {"_id"=>{"year"=>2013, "month"=>11}, "count"=>48044}, {"_id"=>{"year"=>2014, "month"=>8}, "count"=>43802}, {"_id"=>{"year"=>2014, "month"=>1}, "count"=>40428}, {"_id"=>{"year"=>2014, "month"=>3}, "count"=>39564}, {"_id"=&

random - How to easily shuffle a list in sml? -

how can shuffle list of tuples in sml? there doesn't seem built in function so. i assume need use random number generator how move items in list have no idea. this moscow ml's random library . sml/nj's random library , have adjust random functions slightly. val _ = load "random" val rng = random.newgen () (* select([5,6,7,8,9], 2) = (7, [5,6,8,9]) *) fun select (y::xs, 0) = (y, xs) | select (x::xs, i) = let val (y, xs') = select (xs, i-1) in (y, x::xs') end | select (_, i) = raise fail ("short " ^ int.tostring ^ " elements.") (* recreates list in random order removing elements in random positions *) fun shuffle xs = let fun rtake [] _ = [] | rtake ys max = let val (y, ys') = select (ys, random.range (0, max) rng) in y :: rtake ys' (max-1) end in rtake xs (length xs) end

ios - Core data doesn't display data / nil relationships -

i have ios application uses core data. have quite complex model (10+ entities) , working well... of time. need in tracking down root cause of couple of issues or general pointers causing issues , for. a couple of end users experiencing issues. there 2 issues both relating core data. both seem appear after while (hours/days after first use). the first retrieving list of call objects array generate json them. code works fine, 1 or 2 users after while start getting error. call entity has relationship callstatus object - relationship called statusforcall . there no way user set relationship nil . relationship defineltly set when call entity generated. status set , happy after initial save user has checked this). 1 times call objects statusforcall relationship returning nil . installing app on top seems fix issue (the data doesn't changed doing this, relationship magiacally works again). the second issues have different. retrieving list of call objects through nsfetchedresu

java - hot deployment of tomcat project in weblogic? -

Image
i have tomcat project directory structure is previously using tomcat server, whenever modified .java files used build project , restarted server in eclipse through plugin changes have taken effect. now in company changed tomcat weblogic since new it, used build war file every time , deploy manually check changes. can 1 tell me how hot deployment in web logic. googled says need change project type dynamic project, cant since in development. is better way make changes java file build , no need restart server through eclipse in weblogic 12c. eclipse ide luna weblogic 12c server project type : tomcat project structure i think how doing little old fashioned. eclipse luna, tomcat 5.0 - tomcat 8.0 supported. , take effort turn project 'dynamic web project', in way benifit lot experience of other people. for hot redeploying, can try jrebel , reload changed java class without reloading whole applcaition.but it's commercial software, , don't know , free

mysql - How to get row position from sql table in Php -

i need 'position (row)' sql table using php script. tested sql statement , worked fine. output correct. my sql statement: set @rownum = 0; select position, name,cash (select name, cash, @rownum := @rownum + 1 position 'my_db'.'cash' order cash desc ) t name = 'user44'; output: "position":44,"name":"user44","cash":"5600" but if put in php: $query="set @rownum = 0; select position, name,cash (select name, cash, @rownum := @rownum + 1 position 'my_db'.'cash' order cash desc ) t name = 'user44';"; it shows me errant query . i tried this: $query="select position, name,cash (select name, cash, @rownum := @rownum + 1 position 'my_db'.'cash' order cash desc ) t name = 'user44';"; output: "position":null,"name":"user44","cash":"5600" thanks volkerk, solved problem with:

Hyphen library: What does "hyphenation vector" mean? -

hyphen library seems popular , free way have hyphenation in app. what hyphenation vector mean? i running example attached library source code. example output: hibernate // input word 030412000 // output hyphenation vector hi=ber=nate // hyphen points - hi=bernate - hiber=nate odd numbers in vector indicate hyphenation points. but, of values mean? lászló németh describes algorithm in openoffice's documentation in full detail. the library uses algorithm developed frank m. liang ("word hy-phen-a-tion com-pu-ter"): letters in digrams, trigrams, , longer patterns assigned numerical values indicate it's 'usual' place (an odd number) or 'unusual' place (an number) hyphen occur. higher number is, greater importance -- pattern never broken on larger number, , on larger odd number. number sequences statistically determined on corpus of pre-hyphenated words. note numbers positions between 2 characters. better notation have been

android - advise connecting mongodb and uniqush -

i have android , ios shopping app need send push notifications whenever new promotion stored in db. have mongodb our database , setup uniqush our push notification server. now, need advise on building robust integration system polls offers document collection in db , sends uniqush on http. technologies/frameworks should use , there open-source ready-made system? have tried simple implementation of meteor livequery not suitable handle more 100k users use app. running on centos distribution suggestions welcome. thanks there isn't system ready that, there's variety of languages out there libs mongodb , clients uniqush. worked on simple ruby wrapper uniqush . mongoid popular mongodb client ruby. you can build system relies on chronjobs pulling newest documents mongo every few minutes, or can use resque enqueue job run on background generate , request push notifications uniqush-push server every time offer created. resque preferred option it's pretty standard

Bash Script for deleting old backup files -

every night server creates backups every mysql database. of these files saved in folder /backup/mysql/2014-11-28. on last few months lot of folders , files have been stored in directory , reduce this. therefore need bash script deletes every folder in given directory, except every folder created month (not in last 30 days, actual month) , except 1 backup every week (for example backup sunday). since have no clue how sunday party decided simpler keep backups 07th, 14th, 21st , the 28th. #!/bin/bash in_array() { local haystack=${1}[@] local needle=${2} in ${!haystack}; if [[ ${i} == ${needle} ]]; return 0 fi done return 1 } year=`date +%y` lastyear=`date +%y -d "1 year ago"` month=`date +%m` days="07 14 21 28" in $( ls ); backup_year=$(echo "${i}" | cut -d'-' -f1) backup_month=$(echo "${i}" | cut -d'-' -f2) backup_day=$(echo "${i}" | cut -d'-' -f3) delete=false if [[ "$backup_year&qu

image processing - What is the best way to parallelize Hough Transform algorithm? -

in hough line transform, each edge pixel, find corresponding rho , theta in hough parameter space. accumulator rho , theta should global. if want parallelize algorithm, best way split accumulator space? what best way parallelise algorithm may depend on several aspects. important such aspect hardware targeting. have tagged question "openmp", assume that, in case, target smp system. to answer question, let start looking @ typical, straightforward implementation of hough transform (i use c, follows applies c++ , fortran well): size_t *hough(bool *pixels, size_t w, size_t h, size_t res, size_t *rlimit) { *rlimit = (size_t)(sqrt(w * w + h * h)); double step = m_pi_2 / res; size_t *accum = calloc(res * *rlimit, sizeof(size_t)); size_t x, y, t; (x = 0; x < w; ++x) (y = 0; y < h; ++y) if (pixels[y * w + x]) (t = 0; t < res; ++t) { double theta = t * step; size_t r = x * cos(theta) + y * sin(theta);

jquery plugins - bxslider-4- doesn't work in Safari -

i use bxslider-4 plugin (the fully-loaded, responsive jquery content slider) creating picture slider. reason doesn't work in safari. familiar issue? <div class="mini-resume-content"> <p><span class="text-default">dhjkdfshjk hdjkshfkd dksfl;k; ,sl;ajd;asj; dfnsdlk</span></p> </div> </section> <script type="text/javascript"> if('true'){ $.ajax({ url:"/threebaysover/profile/accomodationoverview", type:"post", data: {id:'10'}, success:function(data){ $('#accomendation').html(data); } }); } $(document).ready(function(){ $('.bxslider').bxslider(); }); var mme = $("#mypanel"); mme.mmenu({ classes: "mm-white"}).on('click', '.mm-subclose', function () { $("#mypanel").trig

asp.net mvc - Javascript object to C# object does not correctly convert double -

i'm trying send model created using javascript (because created manually user) mvc controller. the model quite complex , 1 class uses double? type variable. works fine int numbers when use "0.5" value set null. what reason why double value fail , can it? some code: var serie = {}; serie.name = $(elem).children("#name").val(); serie.unitmeasurement = $(elem).children("#unitmeasurement").val(); serie.thresholdred = $(elem).children("#redthreshold").val(); serie.thresholdyellow = $(elem).children("#yellowthreshold").val(); public class serie { public string name { get; set; } public string unitmeasurement { get; set; } public double? thresholdred { get; set; } public double? thresholdyellow { get; set; } } you can use class like- public class serie { public string name { get; set; } public string unitmeasurement { get; set; } pub

jquery - How to add a static content to Bootstrap carousel? -

here have code bootstarp carousel , working fine different devices. <div id="mycarousel" class="carousel slide" data-interval="3000"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#mycarousel" data-slide-to="0" class="active"></li> <li data-target="#mycarousel" data-slide-to="1"></li> <li data-target="#mycarousel" data-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="item active"> <img src="img/t1/p-banner1.jpg" alt="" /> <div class="carousel-caption"> <h3>image 1</h3> <p>image 1 description</p> </div> </div> <div class="item"> <img src="img/sizeimg/dal.png"

go - Golang Hide XML parent tag if empty -

after trail , error i'd share issue dealing with. i'm populating struct , convert xml ( xml.marshal ) can see below foo example works expected. bar example creates empty group1. so question : "how prevent group1 generated if there no children set." package main import ( "fmt" "encoding/xml" ) type example1 struct{ xmlname xml.name `xml:"example1"` element1 string `xml:"group1>element1,omitempty"` element2 string `xml:"group1>element2,omitempty"` element3 string `xml:"group2>example3,omitempty"` } func main() { foo := &example1{} foo.element1 = "value1" foo.element2 = "value2" foo.element3 = "value3" fooout, _ := xml.marshal(foo) fmt.println( string(fooout) ) bar := &example1{} bar.element3 = "value3" barout, _ := xml.marshal(bar) fmt.println( string(barout) ) }

How to move a bitmap (like long green grass moving by the wind) fixing its pivot at the bottom center point of the bitmap in android? -

in application,i have long green grass bitmap.i have fix bitmap not move bottom part , should placed @ left bottom corner of screen.so have fix pivot @ bottom center of bitmap.after should move bitmap (like grass moving wind) left,some pixels , right,some pixels distance.but bitmap should not move pivot position.i unable fix pivot position , achieve grass moving.i posting code have done.please me solve this. private float direction = 1; private float mangle = 0; bitmap green_1 = bitmapfactory.decoderesource(getresources(), r.drawable.green_1); private void drawpaper(canvas canvas){ paint paint=new paint(); paint.setantialias(true); paint.setfilterbitmap(true); if (mangle >= 3) { direction=-0.2f; } else if (mangle<=-3) { direction=0.2f; } mangle = mangle + direction; matrix matrix = new matrix(); matrix.posttranslate(0,heightofcanvas

beautifulsoup - Python: Writing multiple variables to a file -

i'm new python , i've written scraper prints data scrap exact way need it, i'm having trouble writing data file. need exact same way , in same order when prints in idle import requests import re bs4 import beautifulsoup year_entry = raw_input("enter year: ") week_entry = raw_input("enter week number: ") week_link = requests.get("http://sports.yahoo.com/nfl/scoreboard/?week=" + week_entry + "&phase=2&season=" + year_entry) page_content = beautifulsoup(week_link.content) a_links = page_content.find_all('tr', {'class': 'game link'}) link in a_links: r = 'http://www.sports.yahoo.com' + str(link.attrs['data-url']) r_get = requests.get(r) soup = beautifulsoup(r_get.content) stats = soup.find_all("td", {'class':'stat-value'}) teams = soup.find_all("th", {'class':'stat-value'}) scores