Posts

Showing posts from September, 2012

.net - Windows Mobile Application for barcode scanning with Emulator -

i want develop simple application motorolo mc 9190 g mobile has inbuilt bar code scanner, want scan bar code , display them in msg box. dont have mobile have test in emulator. when deploy code in emulator gives null exception error. code add sample.barcode dll private barcodereader symbol.barcode.reader // error occurs here barcodereader = new symbol.barcode.reader() barcodereader.actions.enable() dim nextreaderdata symbol.barcode.readerdata = barcodereader.getnextreaderdata() messagebox.show(nextreaderdata.text) i mm beginner this.. pls help.. you need create interface , mock, along these lines: interface ibarcodereader { string readbarcode(); } public class symbolreader : ibarcodereader { private reader m_reader; public symbolreader() { m_reader = new symbolreader.barcode.reader; m_reader.actions.enable(); } public string readbarcode() { return m_reader.getnextreaderdata().text; } } public class mockreade...

sorting - Is there an efficient way to sort the results of a join in RethinkDB? -

in rethinkdb, need perform join between 2 tables (representing has-and-belongs-to-many relationship) , sort results of join. there hundreds of thousands or millions of results, need sort them efficiently. ideally, use orderby() index. orderby() can use index when called on table , , .eqjoin() returns stream or array . here’s example of query i’m working with. want conversations have given topic: r.table('conversations_topics') .getall('c64a00d3-1b02-4045-88e7-ac3b4fee478f', {index: 'topics_id'}) .eqjoin('conversations_id', r.table('conversations')) .map(row => row('right')) .orderby('createdat') the unindexed orderby() used here starts getting unacceptably slow when topic contains few thousand conversations, , break @ 100,000 due rethinkdb's array size limit. topics in db contain many hundreds of thousands, or millions, of conversations, unacceptable. i need query return small number of results @ t...

CMake cannot find MathGL's dependency PNG -

i'm trying generate visual studio 2013 projects files mathgl 2.3.3 cmake. for reason cmake not understand png_png_include_dir statement. cmake "-dzlib_include_dir=c:\users\chenning\projects\zlib-1.2.8\" "-dzlib_library_debug=c:\users\chenning\projects\zlib-1.2.8\zlib.lib" "-dzlib_library_release=c:\users\chenning\projects\zlib-1.2.8\zlib.lib" "-dpng_png_include_dir=c:\users\chenning\projects\lpng1620\" "-dpng_library_debug=c:\users\chenning\projects\lpng1620\projects\vstudio\x64\debug\libpng16.lib" "-dpng_library_release=c:\users\chenning\projects\lpng1620\projects\vstudio\x64\release\libpng16.lib" . the path exists , variable called png_png_include_dir 2 png. cmake telling me: -- found zlib: c:\users\chenning\projects\zlib-1.2.8\zlib.lib -- not find png (missing: png_png_include_dir) cmake error @ cmakelists.txt:341 (message): couldn't find png library. -- configuring incomplete, errors occurred! s...

testing - Doxygen test plan generation -

does doxygen have capability generate test plans number of test cases? atlassian jira plug-in called "zephyr" doxygen provides command '@test', starts paragraph describe test case , creates additional "test" index. in combination capability create custom commands , create pdf files via latex should create test plans doxygen. used document unit tests.

SQL Server round the decimal data if decimal part is 0 -

in sql server stored procedure casting variable decimal: cast( @tovalue decimal(38,5) ) if result 57282.0000 (decimal value 0 ) want appear 57282. else want appear 57282.48300 example. i cannot use float because if value greater 8 digit number, displayed exponential format. how can solve this? you should in formatting options reporting software. if reason isn't possible following might work. ;with t(val) ( select 57282 union select 57282.48300 ) select case when 1= 0 null when val = floor(val) cast(cast(val int)as sql_variant) else cast(val decimal(38,5)) end t

layout - Centering multiple textViews programmatically on Android -

Image
i have open gl es 2.0 app , displaying android textview on top of glsurfaceview. i have actual textviews displaying ok need try centre them. this have far: text1 = new textview(this); text1.settext("this sample text"); text1.settextcolor(color.white); text1.settextsize(textsize); text2= new textview(this); text2.settext("and more sample text"); text2.settextcolor(color.white); text2.settextsize(textsize); relativelayout.layoutparams textparams = new relativelayout.layoutparams(layoutparams.wrap_content,layoutparams.match_parent); lp.addrule(relativelayout.center_horizontal); textlayout = new relativelayout(this); textlayout.setlayoutparams(textparams); textlayout.addview(text1); textlayout.addview(text2); mainlayout.addview(textlayout); however, when run this, text1 centered. text 2 isn't, , starts @ left side of first (correctly centered) textview. try might, can't seem both of th...

objective c - Set order on displaying paths/images -

i have couple of arcs , rects in uiview , , uiimageview well. want have uiimageview in background. have ordered in ib image view behind labels , buttons. first, need put image in image view, don't want in ib. i've tried code uiimage *myimage = [uiimage imagenamed:@"image.png"]; uiimageview *myimageview = [[uiimageview alloc] initwithimage:@"myimage"]; but doesn't work. after working, can move paths in front of image view? add image uiimageview : uiimage *myimage = [uiimage imagenamed:@"image.png"]; uiimageview *myimageview = [[uiimageview alloc] initwithimage:myimage]; [self.view addsubview:myimageview];

javascript - AngularJS - how do show element on odd number of clicks anywhere on browser? -

i have dropdown bar class "navigation-dropdown" shows when variable called "dropdown" true (dropdown value flipped when navbar clicked). way close dropdown click in navbar again. there way close dropdown clicking anywhere in body? code sample: <nav class="navigation-nav hide-mobile" ng-controller="leftnavctrl" ng-click="dropdown=!dropdown"> <h2>dropdown</h2> <ul class="navigation-dropdown" ng-show="dropdown" ng-click="dropdown=!dropdown"> <li class="navigation-dropdown__item"> <a>account</a> </li> <li class="navigation-dropdown__item"> <a>help</a> </li> </ul> </nav> you try this: $(document).on("click", function(e) { if (!$(e.target).closest(".navigation-nav").length) { $scope.dropdown = false; } $scope....

python - How to mathmatically represent a set of data -

Image
i'm analyzing set of data shown on picture: if save data csv i'll end huge file. i'm trying fit polynomial first n data points , same next n data points. of course there needs constraint there smooth transition between first , second polynomial. @ point should able save coefficients of polynomials expect way more memory efficient raw data. is there way in python? right approach? best way analytically describe curve? another idea create bezier path data in order polynomial representation of data. so think approaches? how solve problem? i go classic solution , create table x , y coordinates. end thousands of records no problem modern applications. make simple things simple, think best approach.

python - Importing a code-containing __init__.py from a cousin folder? -

given directory structure: program/ setup.py ilm/ __init__.py app/ __init__.py bin/ script.py note: setup.py not typical setup.py, rather custom-made setup uniquely py2app. program/ilm/app/__init__.py non-empty: contains main() function, instantiates class in same file. question: in program/ilm/bin/script.py , if want import , execute main() function in program/ilm/app/__init__.py , valid ways of achieving this? reason ask script.py doing thus: import ilm.app app if __name__ == '__main__': app.main() based on (admittedly limited) understanding of packaging , importing, shouldn't work, since have not explicitly told script.py project/ilm/app/__init__.py using .. . , indeed, get: macbook-pro-de-pyderman:program pyderman$ python ./bin/script.py traceback (most recent call last): file "./bin...

jekyll - Querying post.next in a given category -

when iterating through posts in given category, {% post in site.categories.category %} , post.next returns next post in reverse chronological order. there way query post.next in specific category, rather in general? i ended doing ron mentioned, iterated through site.categories capturing each one, , iterating posts in category.

Objective-C: How to find the highest value in an array without sorting? -

im working on assignment in have find highest value in array using loop, , without sorting it. feel have far close being correct not quite there. below example of code have far. nsarray *unsortedarray = @[ @2, @44, @11, @99, @35 ]; (int = 0; < 4 ; i++) { id number = [unsortedarray objectatindex:i]; id largestnumber = 0; if (largestnumber < number) { largestnumber = number; nslog(@"%@ largest number", largestnumber ); return 0; } } now returning first value in area loop stopping, assigning wrong values largestnumber , number? new code, appreciate , feedback , examples. thanks! key-value-coding solution, no loop nsarray *unsortedarray = @[ @2, @44, @11, @99, @35 ]; nsnumber *maxnumber = [unsortedarray valueforkeypath:@"@max.self"]; nslog(@"%@", maxnumber); // 99 see interesting article mattt thompson: kvc collection operators

javascript - Chrome Extension: How to make background wait executescript? -

i've started developing first google chrome extension, , experiencing issue. in background.js script each second call script.js , smth like: script.js: /* code */ if (condition1) { settimeout(func1, 500); result = 1; } else if (condition2) { settimeout(func2, 4000); result = 2; } else /*some code */ result background.js: function func() { chrome.tabs.executescript(null, {file: 'script.js'}, function (result) { console.log(result[0]); } ); /* code using results of scipt.js */ }; var interval = null; function onclickhandler(info, tab) { if (info.menuitemid == "addon") { if (interval != null) { clearinterval(interval); interval = null; } else { interval = setinterval(func, 1000); } } }; chrome.contextmenus.onclicked.addlistener(onclickhandler); chrome.runtime.oninstalled.addlistener(function() { chrome.contextmenus.crea...

css - 90% zoom on browser makes no media query used -

i wrote css media queries deal the width of class: @media (max-width:1920px) { .slides { width: 860px; } } @media (max-width:1500px) { .slides { width: 852px; } } @media (max-width:1280px) { .slides { width: 850px; } } @media (max-width:1097px) { .slides { width: 680px; } } @media (max-width:960px) { .slides { width: 540px; } } @media (max-width:768px) { .slides { width: 410px; } } all of these media queries hitting browser zoom 500% 100%. once 90% none of them being applied. why , doing wrong? at 90% zoom page has more 1920px , why none of queries apply. don't have default case. add, example: .slides { width: 960px; } before queries. of course, should change 960px desired width of .slides when on screens wider 1920px . on 1920px monitor, @ 90% , page's width ~2133px . @ 50% have 3840px , on... if want .slides percentage of screen, use vw (1vw = {...

oracle - Abort insert/update operation in trigger using PL/SQL -

i write trigger checks information inserted/updated, compare them data database , if not correct, stops whole operation. wrote before trigger (for each) , threw application exception if wrong, not working, becouse read table updated, ora-04091 error. and wondering how solve this? idea of mine write before trigger insert necessary data package , read them after trigger won't each. there's problem how abort edition? if make rollback undo operations in transaction think not smart. how solve problem? don't go there. ora-04091: table xxxx mutating indicator whatever you're trying complex done reliably triggers. sure, use package array variable , handful of triggers (ugh!) around error, code likely: be unmaintainable due complexity , unpredictable nature of triggers not respond multi-user environment this why should re-think approach when encounter error. advise build set of procedures nicely grouped in package deal inter-row consistency. revoke p...

linux - What is the reason to kill old server threads/processes and launch new ones after serving certain number of requests -

for example apache httpd provides directive maxconnectionsperchild controls how server recycles processes killing old ones , launching new ones. what reason killing old threads @ after serving number of connections. isn't hot cache thing applicable here? from the docs : setting maxconnectionsperchild non-zero value limits amount of memory process can consume (accidental) memory leakage. so if you're leaking 1 mb per request ( malloc() not free() ), gradually use more , more memory until run out , apache gets killed. if set maxconnectionsperchild 100 , child gradually use 100 mb of memory, killed , go down 0. the "hot cache" thing applicable here, setting maxconnectionsperchild slow down apache. that's why default infinite. maxconnectionsperchild meant inelegant duct-tape on memory leaks. time-pressured programmer might prefer spending 1 minute setting maxconnectionsperchild, rather 1 week hunting malloc() calls.

php - Sonata Admin Bundle listbox sort order -

i have 2 entities 1 referenced many 1 relation. example, user , city. need listbox cities in user edit page sorted name, not id. how can it? in entity, can specify ordering . example : <?php /** * @manytomany(targetentity="group") * @orderby({"name" = "asc"}) */ private $groups;

asp.net - Web Forms Url Routing in Mono -

i'm new mono , trying run simple hello world application routing. while application runs fine on iis, i'm getting 404 error when browse root of site. i've got route mapped follows: routetable.routes.mappageroute("default", string.empty, "~/site/home.aspx") browsing directly file ( http://myhostname/site/home.aspx ) works. i tried using following web.config -- both , without system.webserver section: <configuration> <system.web> <compilation strict="false" explicit="true" targetframework="4.0" /> <customerrors mode="off"/> </system.web> <system.webserver> <modules runallmanagedmodulesforallrequests="true"> <add name="urlroutingmodule" type="system.web.routing.urlroutingmodule, system.web, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> </modules> <handlers> <add name=...

php - Rollback a particular migration? -

is possible rollback particular migration in laravel? for example: if make 4 migration m1, m2, m3 , m4 , later decided add more fields in m2. can roll way directly m2? or edit existing m2 migration file directly? the best practice @farkie's comment, create new migration. if want hack, way laravel rollbacks migrations this: on migrations tables there column called 'batch' when rollback executed records biggest batch number rollbacked , records of rollbacked migrations deleted migrations table. a way hack be: if migrations table like: migration | batch =========================== m1 | 1 m2 | 1 m3 | 1 m4 | 1 edit table looks like migration | batch =========================== m1 | 1 m2 | 2 m3 | 2 m4 | 2 so when rolling rollback m2, m3 , m4, changes , migrate again

javascript - Using $http.get to retrieve from API(zendesk) not working -

i'm trying make api call zendesk's api , keep getting 401 auth code though same thing works when curl in terminal. how can make work in angular? function dataservice($http) { var service = { getmacros: getmacros }; return service; ///////////////////// function getmacros() { var client = { username: window.btoa('myemail'), token: window.btoa('/token:mytoken'), remoteuri: 'https://mycompany.zendesk.com/api/v2/macros.json' }; console.log('loading...'); return $http({ method: 'get', url: client.remoteuri, headers: { 'authorization': client.username + client.token } }) .then(getmacroscomplete) .catch(function (message) { exception.catcher('failed getmacros')(message); }...

Print an arabic unicode string in Python(x,y) -

this question has answer here: python, unicode, , windows console 11 answers i have arabic unicode string want print in python (using python(x,y) on windows 7), can't print, unicode representation printed out. the string defined as: ss = u'\u0647\u0630\u0627 \u0647\u0648 \u0627\u0644\u062d\u0644 \u0627\u0644\u0648\u062d\u064a\u062f \u0644\u0644\u0645\u0634\u0643\u0644\u0629 \u0627\u0644\u062a\u064a \u0646\u0648\u0627\u062c\u0647\u0647\u0627' and should this: "هذا هو الحل الوحيد للمشكلة التي نواجهها" when try print , gives following error print ss traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\python27\lib\encodings\cp1252.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_table) unicodeencodeerror: 'charmap' codec can't encode c...

linux - symbols in kernel module -

i built linux kernel module ssp support mips architecture. added -fstack-protector-all compilation flags. after loading module i've got undefined references __stack_chk_guard , __stack_chk_fail . added libssp.so linker. looks should export symbols in kernel this: export_symbol(__stack_chk_guard); because kernel old , didn't contain them yet. unfortunately should use version. my question is: why user space can use symbols toolchain library, kernel space don't ? i think, missed linux kernel essentials. you can't link kernel shared libraries. if have static library of libssp, may work - require library isn't calling else cause problems in kernel. in general, stack-checking isn't should doing on kernel - i'm pretty sure serves no particularly purpose [i'm pretty sure kernel uses "guard page" each kernel stack].

java - AsyncTask not updating UI after doInBackground finishes -

i'm trying make simple app that's looks wifi networks, , connects them. i'm having problem updating ui. a few pointers great. thank time. class uiupdater extends asynctask<void, void, list<scanresult>> { @override protected void onpreexecute() { super.onpreexecute(); textview searching = (textview) findviewbyid(r.id.searching); searching.settext("currently searching..."); } @override protected list<scanresult> doinbackground(void... params) { wifimanager manager = (wifimanager) client.this.getsystemservice(context.wifi_service); if (!manager.iswifienabled()) manager.setwifienabled(true); return manager.getscanresults(); } @override protected void onpostexecute(list<scanresult> items) { super.onpostexecute(items); arraylist<items> wifi = new arraylist<>(); (scanresult s : items) wifi.add(...

mySQL Throwing a 1111 Invalid use of Group Function -

for life of me can't figure out why query throwing 1111 error. help! select fs.player_id, count(fs.game_id) eg.flag_stats fs, eg.flag_games fg fs.here = '1' , fg.start_time > max(re.end_time) , fs.freq = fg.winning_freq , fs.game_id = fg.id group fs.player_id order count(fs.game_id) desc; please , thanks! thanks @sgeddes below fix. select pl.name, count(fs.game_id) eg.flag_stats fs, eg.flag_games fg, eg.player pl fs.here = '1' , fg.start_time > (select max(end_time) eg.reset) , fs.freq = fg.winning_freq , fs.game_id = fg.id , fs.player_id = pl.id group fs.player_id order count(fs.game_id) desc

Very slow MySQL code (inline and JOINS) -

how can restructure query below run faster? takes several minutes run, slows down webserver significantly. query gets details of product several tables, using inline queries , joins. have feeling there must faster way. what efficient way of writing query below? select p.*, pd.*, pd.name name, pi.*,p.image default_image, (select first product_shipping psi psi.product_id = p.product_id) flat_rate, (select name manufacturer m m.manufacturer_id = p.manufacturer_id) manufacturer, (select price product_special ps ps.product_id = p.product_id , ps.customer_group_id = 8) special_price product p left join product_description pd on ( p.product_id = pd.product_id ) left join product_image pi on ( p.product_id = pi.product_id ) order p.product_id a bit of items in select duplicated, since that's how getting data originally, i've kept is. also, using left join s can slower inner...

javascript - Assign multiple selectors to variable based on which one exists -

i'm looping through container , looking possible elements exist. if 1 of elements exist, want assign jquery object element variable. have solution, i'm not sure if it's way go it. html <form> <div> <label>first name</label> <input type="text"/> </div> <div> <label>last name</label> <input type="text"/> </div> <div> <label>location</label> <select> <option>usa</option> </select> </div> </form> js $(document).ready(function(){ var testnum = $('form').find('label').length; for(var i=0; i<testnum; i++) { var currenttest = $('form').find('label').eq(i).parent().find('input').length ? $('form').find('label').eq(i) : false || $('form').find('label').eq(i).parent().find('select').length ? $('form').fin...

php - How to check that a string contains at least 5 unique characters and is minimum 7 characters long? -

i need validation tests string contains 5 unique characters , @ least 7 characters long. i have tried following regex: ^[a-za-z][0-9]{7}$ i'm stuck , have no idea how validation string contains @ least 5 unique characters. i don't think easy check if have @ least 5 unique characters in there regex, use approach. i check preg_match() , string contains characters character class [a-za-z0-9] , @ least 7 characters long, check quantifier : {7,} . then make sure have >= 5 unique characters, split string array str_split() , unique characters array_unique() , check count() if there >= 5 unique characters, e.g. if(preg_match("/^[a-za-z0-9]{7,}$/", $input) && count(array_unique(str_split($input))) >= 5) { //good } else { /bad } as, question not clear if want perform validation in php or javascript , adding similar code using javascript. var regex = /^[a-za-z0-9]{7,}$/; // adding method on prototype, can invo...

How to measure peak heap memory usage in Java? -

how measure peak heap memory usage in java? memorypoolmxbean keeps track of peak usage per memory pool, not entire heap. , peak heap usage not sum of different heap memory pools. did think using totalmemory() function runtime class - docs ? there free tools visualvm or jstat , example: jstat -gc <pid> <time> <amount> hope helps.

How to make meteor work on 64bit mongodb on windows 10? -

i install meteor.js , try use replace old frameworks. issue is: on windows 10 64bit system, meteor use 32bit mongodb(2.6.7), limited th database size 2gb. how make meteor work 64bit mongodb? having researched myself now, looks though meteor version 1.4 release updated version 3.2 of mongodb, in " 32-bit binaries deprecated " github ticket updating of mongodb mongodb declaration 3.2 has deprecated 32-bit binaries meteor 1.4 announcement if upgrading mongodb instance mandatory now , unfortunately looks way manually upgrade binaries yourself. if this, suggest make backup of them in-case messes up. to upgrade version 3.2 first need upgrade version 3.0 , can upgrade version 3.2

javascript - react load new content based on click -

i have 3 separate files. nav.js var navitem = react.createclass({ render: function() { return ( <li><a href="#">{this.props.name}</a></li> ); } }); var navlist = react.createclass({ render: function() { var navnodes = this.props.data.map(function(nav) { return ( <navitem name={nav.name} key={nav.id}></navitem> ); }); return ( <ul classname="nav"> <li classname="current"><a href="#"><i classname="glyphicon glyphicon-home"></i> lists</a></li> {navnodes} <li><a href="#"><i classname="glyphicon glyphicon-plus"></i> add new widget list</a></li> </ul> ); } }); var navbox= react.createclass({ loadnavsfromserver: function() { $.ajax({ url: "http://server/api/widgetlists/?format=json"...

ios - performSegue before the View is visible -

i have 2 views viewcontroller-> main view loginvc -> login view my initial view viewcontroller contains buttons , text. what want achive perform segue transfer view login if user not yet log in. what have done inside viewcontroller did check if user_id nil if nil perform segue. override func viewwillappear(animated: bool) { if globals.user_id == nil{ self.performseguewithidentifier("goto_login", sender: nil) // dispatch_async(dispatch_get_main_queue(), { // self.performseguewithidentifier("goto_login", sender: nil) // }) } } what problem my problem whether use viewwillappear or viewdidload or viewdidappear transfer view viewcontroller loginvc. viewcontroller visible in single second before the login screen appears , want rid of it.can me solve issue. i have same functionality in app. achieved checking userid in appdelegate.swift inside function func applic...

c# - Selecting a default combobox value -

when program loads, combobox has no default value. want first 1 default value when program loaded. how can that? using gtk; using system; class sharpapp : window { label label; label label2; label label3; label label4; public sharpapp() : base(" valutasoffan") { setdefaultsize(411, 199); setposition(windowposition.center); seticonfromfile("..\\..\\web.png"); deleteevent += new deleteeventhandler(ondelete); string[] valutor = new string[] { "yen", "sek", "euro" }; //box1 fixed fix = new fixed(); combobox cb = new combobox(valutor); combobox cb2 = new combobox(valutor); entry entry = new entry (); entry entry2 = new entry (); cb.changed += onchanged; cb2.changed += onchanged2; entry.changed += onchanged3; entry2.changed += onchan...

python - what's the correct way to find out flask's endpoint by function name? -

i have flask demo, , needs access control. access control base on function name, , wrote decorator it. the decorator define is: def permission(fn): @wraps(fn) def wraped(*args, **kwargs): if _do_validate(fn.__name__): # todo check user has privileges here return fn(*args, **kwargs) else: abort(401) return wraped usage example follow: @app.route('/index') @permission def index(): return 'hello world' this work fine if user don't specify endpoint, because flask's default endpoint fn.__name__ , in example endpoint='index' . but when user specify endpoint, or use blueprint, endpoint changed. example: bl = blueprint('admin', __name__) @bl.route('hello') @permission def hello(): return 'hello world in blueprint' the endpoint changed admin.hello . i don't want specify arg in @permission , write new permission decora...

I don't understand why my nodejs/javascript regex isn't working -

i have simple text i'm trying parse: total 4.0k -rw-rw-r-- 1 346 mar 1 08:50 save_1 -rw-rw-r-- 1 0 feb 28 17:28 save_2 -rw-rw-r-- 1 0 feb 28 17:28 save_3 and have regular expression have tested working on different regex testing websites: \w{3}\s+\d{1,2}\s\d{2}\:\d{2}\s\w{4}\_\d i'm trying take sample text input in following function in node.js application , return object or array 3 different matches, month end of line. function parse(str) { var regex = new regexp("\w{3}\s+\d{1,2}\s\d{2}\:\d{2}\s\w{4}\_\d"); return regex.test(str); //return str.match(regex); } i don't understand why boolean .test() false , object .match() null. any appreciated. instead of trying parse output of ls , which bad , should use file system operation provided node.js. using file system operations can sure program work in (almost) edge case output defined. work in case folder contain more or less files 3 in future! as stated in comments want n...

javascript - How to show unbeforeunload alert when form is filled? -

i want show " onbeforeunload alert" when tab closed when fill form , close tab " onbeforeunload alert" isn't appearing. how can change code " onbeforeunload alert" can show when form filled? there's code use: window.onbeforeunload = confirmexit; function confirmexit() { return "you exit system before freezing declaration! if leave , never return freeze declaration; not go effect , may lose tax deduction, sure want leave now?"; } $(function() { $("a").click(function() { window.onbeforeunload = null; }); $("input").click(function() { window.onbeforeunload = null; }); }); how can change code " unbeforeunload alert" can show when form filled? you clicking <input /> filling form right? once click <input /> , unbeforeunload set null (removing alert) following code: $("input").click(function() { window.onbeforeunload = null; }); ...

jsp - how can i format the java.sql.Date to MM/dd/yyyy -

my code is final long millis_in_a_day = 1000*60*60*24; date yesterdaydate= new java.sql.date(new java.util.date().gettime() - millis_in_a_day); out.println(yesterdaydate); the output getting in format yyyy/mm/dd..how can in mm/dd/yyyy please don't . date using date object , parse using simpledateformat . simple . don't go hard coding value. not convenient programmer . please find code date date = new date();//today date simpledateformat format = new simpledateformat("mm/dd/yyyy");// format in format or change change string format= format.format(date); system.out.println(format);// 01/06/2016 or calendar todaydate = calendar.getinstance(); todaydate.add(calendar.day_on_month, -1);//import java.util.* date yesterday = cal.gettime(); simpledateformat format = new simpledateformat("mm/dd/yyyy"); string format = format.format(yesterday); system.out.println(format);// 01/06/2016

php - html form query using check boxes -

Image
i developing a cancer risk assesment tool in phpmysql. user need select risks , symptoms html form containing check boxes , then choices checked against stored in database. form. here screenshots of data stored in mysql database submitted checkboxes checked against. oesophageal_carcinoma_riskfactors_tbl oesophageal_carcinoma_symptoms_tbl oesophageal_carcinoma_riskfactors_tbl in case checked html here the response fetched query should come responseid = 1 response table. how should table linking foreign keys , how should php code query database like. nick, correct in comment when need "relations" table. suggest creating 1 table own primary key , 3 additional columns server foreign keys. e.g: |id|risk_id|symptom_id|response_id| ___________________________________ | 1| 2 | 3 | 4 | and measure index foreign key columns.

Django: how to load a fixture that contains Decimal -

i want load fixture contains decimal. fixture in json "salarymax": "58,689.54", following documentation of django , added true these value: use_i18n = true use_l10n = true use_thousand_separator = true here snippet of fixture: { "fields": { ...#shortened "pub_date": "2015-12-23", "salarymax": "58,689.54", "salarymin": "50,164.66", "salarytype": "annually" }, "model": "emplois.job", "pk": 1 }, here model (for moment salarymax in decimal ) create models here. @python_2_unicode_compatible class job(models.model): #...shortened joburl = models.urlfield(max_length=250, blank=true, null=true) expirydate = models.datefield(auto_now=true, blank=true, null=true) salarymax = models.decimalfield(max_digits=8, decimal_places=2, localize=true) salarymin = models.charfi...

linux - Is there any way to get the page numbers in a PDF of a search pattern? -

i have pdf named test.pdf , need search text my name in pdf. by using script, can job: pdftotext test.pdf - | grep 'my name' is there way page number text "my name" in terminal itself? if want linear page number (as opposed number appears on page), can counting form-feed characters while search text. pdftotext puts form-feed @ end of every page, number of form-feeds prior text 1 less (linear) page number text on. (or thereabouts. pdf files not seem.) something following should work: pdftotext test.pdf - | awk -vrs=$'\f' -vname="my name" \ 'index($0,name){printf "%d: %s\n", nr, name;}' the following more complicated solution prove useful if want scan more 1 pattern. unlike simple solution above, 1 give 1 line per pattern match, if same pattern matches twice on same page: pdftotext test.pdf - | grep -f -o -e $'\f' -e 'my name' | awk 'begin{page=1} /\f/{++page;next} 1{printf "%...

javascript - jQuery Tabs not working -

i don't know why doesn't work, although should: $('#group-tabs').tabs({ iframe: true, load: function(event, ui) { $('a', ui.panel).click(function() { $("#test").load(this.href); return false; }); } }); slightly older versions (jquery 1.8.x , jquery-ui 1.9.x) http://jsfiddle.net/qgzzt/1/ you needed change javascript, accessing wrong elements: $('#group-tabs').tabs({ iframe: true, beforeload: function(event, ui) { $('a').click(function() { alert(this.href); $(".tab-content").load(this.href); return false; }); } }); ref. http://jsfiddle.net/qgzzt/2/ however, don't believe able want, because "due browser restrictions, ajax requests subject "same origin policy"." ref. cannot load external page jquery.load div in page you can; however, try using $.get or changing s...

malloc - CUDA dynamic allocation and coalescence (compute capability >2.0) -

maybe can me out. use dynamic allocation in cuda kernel simple reason each block require significant amount of global memory scratchpad , number of blocks in order of 4000. statically allocating scratchpad have preference, not possible due memory size restrictions. figured in case dynamic allocation useful amount of memory number of active blocks, order 100-200. side note , let know not have preference too, seems me way forward. coming point, according cuda c programming guide section b.17; the cuda in-kernel malloc() function allocates @ least size bytes device heap , returns pointer allocated memory or null if insufficient memory exists fulfill request. returned pointer guaranteed aligned 16-byte boundary. and according f.4.2; a cache line 128 bytes , maps 128 byte aligned segment in device memory. memory accesses cached in both l1 , l2 serviced 128-byte memory transactions whereas memory accesses cached in l2 serviced 32-byte memory transactions. caching in ...

android - Remove the background of a textview -

i set background textview , want remove dynamically dosen't work, there suggestion? if (mtoday) { monthview[mrow][mcolumn].setbackgroundresource(r.color.black); } else { monthview[mrow][mcolumn].setbackgroundresource(0); } i found reasonable explanation here why happen, again didn't solve problem. try this. txtemail.setbackgroundresource(android.r.color.transparent);

css - How do I center an HTML5 video horizontally and vertically in a bare bones HTML document? -

this question has answer here: how center element horizontally , vertically? 12 answers let's have very simple html page single html5 video element. it's source code is: <html> <head> <title>{title}</title> </head> <body> <video height="{height}" width="{width}" controls=""> <source src="{source}" type="{type}"/> </video> </body> </html> what can center video element both horizontally , vertically in web browser? i'd prefer css solution or @ least solution uses little in way of hackish techniques possible, i'll take can get. use following css make video element center vertically , horizontally. video { left: 50%; position: absolute; top: 50%; transform: t...

spring - Dynamically change select tag in a view -

i have following model, major , university , application . when creating new application, want majors list withing application change dynamically based on choose of university field. i used dojo in code, it's not working.. create application tag <?xml version="1.0" encoding="utf-8" standalone="no"?> <div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/web-inf/tags/form/fields" xmlns:form="urn:jsptagdir:/web-inf/tags/form" xmlns:jsp="http://java.sun.com/jsp/page" xmlns:spring="http://www.springframework.org/tags" version="2.0"> <jsp:directive.page contenttype="text/html;charset=utf-8" /> <jsp:output omit-xml-declaration="yes" /> <spring:url value="/applications/majorsbyuniversity?university=" var="ajax_url" /> <script type="text/javascript...

C - Honestly at a loss for this odd behaviour -

so... have little piece of code have been working on of morning. it's little project me remember syntax , on. have missed kind of massive error code returns segmentation fault reasons don't understand. #include <stdio.h> #include <stdio.h> #include <unistd.h> #include <time.h> #include <getopt.h> struct cards { int card_value[99]; char card_name[99]; char card_suit[99]; int card_tally; }; struct cards hand[2]; void tally (int a) { int k, j; (k=0; k<5; k++) { j = j + hand[a].card_value[k]; } hand[a].card_tally = j; } void check_for_ace (int a) { int d; (d=0; d>5; d++) { if (hand[a].card_name[d] =='a') { int y; int z = 10; (y=0; y<5; y++) z = z + hand[a].card_value[y]; if (z < 22) hand[a].card_value[d]=10; else hand[a].card_value[d]=1; } } } void draw_card (int a) { int z = 1 + rand () % 13; int x=0; whi...

javascript - Knockout computed gives Function expected error in IE only -

i'm getting "script5002: function expected" happens in ie. i'm testing against version 9. happens when use defined computed observable inside of computed observable. my application bit more complex this, i've reproduced error simpler code below. error happens on line z = self.subtotal(); when enter number in number 1, number 2, , number 3 (and tab out). this error not occur in chrome or firefox , i've googled quite while. can un-stick me. here link jsfiddle: http://jsfiddle.net/kcmtg/ here javascript: function putvars() { self = this; self.number1 = ko.observable(); self.number2 = ko.observable(); self.subtotal = ko.computed(function () { return parsefloat(self.number1()) + parsefloat(self.number2()); }, self, { deferevaluation: true }); self.number3 = ko.observable(); self.number4 = ko.observable(); self.total = ko.computed(function () { var x, y, z; x = self.number3(); y ...

c - NCurses chat misbehaving, blocking in select -

i wrote c application socialization network , simple room-based chat. used ncurses, sockets , basic networking stuff. the problem function uses select() read server socket , stdin when start write message, output window freezes , shows messages other clients after hit enter. i tried possible .. there way fix ? i tried force nocbreak().it works okay if that, when write message, echoing disabled , nothing shows in input window type, though message there "invisible". here code : ssize_t safeprefread(int sock, void *buffer) { size_t length = strlen(buffer); ssize_t nbytesr = read(sock, &length, sizeof(size_t)); if (nbytesr == -1) { perror("read() error length ! exiting !\n"); exit(exit_failure); } nbytesr = read(sock, buffer, length); if (nbytesr == -1) { perror("read() error data ! exiting !\n"); exit(exit_failure); } return nbytesr; } ssize_t safeprefwrite(int sock,...

postgresql: large insert duration -

the database postgresql 9.3. there big table, 70 more columns. use case 700 inserts per second, , each insert takes 1 row. here key items in postgresql.conf: shared_buffers = 1024mb # system memory 8096mb in total work_mem = 32mb maintenance_work_mem = 128mb bgwriter_delay = 20ms synchronous_commit = off checkpoint_segments = 64 checkpoint_completion_target = 0.9 effective_cache_size = 4096mb log_min_duration_statement = 1000 the log show duration of inserts exceed 1 second, after number of rows reaches ten million. anybody help?

c# - Sharing current page screenshot -

i developing app windows phone 8.1, in 2 functionality there, user can share text , current page screenshot app text sharing functionality working. i'd implement share current page screenshot. how this?

c# - Getting Object details from list -

i working in win form there list named notes contains different values noteid , notetype , notename . each created note shown in panel noteid, note type,notename .like panel loaded in form. the requirement when ever user clicks on of field i.e. noteid or notetype or notename, details should loaded in editable text-boxes editing. when user clicks on noteid unique following note details: foreach (note n in noteretrieve) { var index = array.findindex(noteretrieve, x => x.notetype == clickvalue); } so index of particular note , notedetails tbtitle.text = noteretrieve[index].notename; & on. but notetype , notename not unique , can't use above logic. how ? well upon given suggestion , analysis found solution. label objects have tag property. can assign id value each type , name label. then, when click label, can note id tag property. for example, consider note id, type , name 1, type1 , name1. now, labels show type1 , name1 hav...