Posts

Showing posts from August, 2011

codenameone - How to use variables to refer to Components in codename one? -

i created ui uibuilder. instead of using findxxxx () , love in statemachine : public class statemachine ... { private container c; private tabs t; initvars () { initall(); } .... private initall () { container c = findcontainer(); tabs t = findtabs(); ... } } and use them c.getyyy() . is possible? if yes, how? yes can that, not advisable. the danger of when have 2 components same name on different forms, may reference wrong component , may hard debug. if sure can deal above, can declare , initiate variables inside statemachine class outside of methods private global variable. public class statemachine ... { private container c = findcontainer(); private tabs t = findtabs(); initvars () { } .... }

java - Spring Boot without Model + MySQL -

i need make application without using models, because require make model every tables - isn't needed me. we can go class execute queries directly or rest api. has have idea achieving this? as suggested in other answers, not require models . see spring boot documentation , can download simple working example you need have application.properties file properties below spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.driver add spring boot jdbc dependency in pom.xml <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-jdbc</artifactid> </dependency> you want inject jdbctemplate in controller class or other component scanned class, private final jdbctemplate jdbctemplate; @autowired public mycontroller(jdbctemplate jdbctemplate) { this.jd

Slack integrations -

i building slack app whereby using incoming-webhook scope. while authorising, post channel option comes created channels, don't create new channel , post option. any highly appreciated. thanks. update :- attached screenshots 1) this app 2) some other app. create new channel option missing in mine updated: looks want link create new channel correct? if that's case, slack dev team have add. on end, incoming webhooks not allow automated new channel creation.

Adding Drawable to Android library project -

when place ic_sam.png in drawables of module project main app includes, while getting drawable r.drawable.ic_sam below error java.lang.nosuchfielderror: is cannot add drawables in library projects? if no add ? experts please guide. you have create aar project if want bundle resources library. more in how create aar project can found out here

php - How to handle differnet purched price and quantity in same product -

i'm developing automobile parts inventory system using php , mysql. system have purchase module add/update/increase quantity of parts & sale module decrease/out quantity of parts. query have 2 section a. storing data suppose have parts a1 in our stock quantity 30 , price of parts a1 $20 when purchase it. now want stock parts more example want buy 50 more items of parts a1 new price of parts a1 $24. what best way/logic make these items separate know how parts purchased price $20 , new price $24 on sale page. 1. store same parts more once in database 2. normalize database: parts hasmany parttransctions purchased price , quantity b. retrieving data what decrease method when sale (suppose 60 unit in above example) a1 parts also want calculate the profit of sale how handle of situation. in advance normalize database: parts hasmany parttransctions purchased price , quantity or you can handle issue using batch purchase. need create table called p

java - Save perspective containing multiple instances of the same view -

my understanding of situation: there 2 ways persist state of views in eclipse: mementos: these saved on workbench close , restored on open idialogsettings: these can saved , restored @ will packageexplorerpart in eclipse uses both (e.g.) linking files in explorer editors. i have multiple instances of same view different state, , want save them in perspective. if save using mementos, closing , opening eclipse restore state correctly. if open new window file | new window, saved perspective does not provide mementos nor secondary ids views, cannot restore. is there way save state of these views perspective can correctly restored? while technically dialogsettings can used persist view state, mementos passed savestate() , init() meant therefore. not sure why package explorer such double-entry book keeping . there reson for, haven't had necessity so. new window creates new view , hence there nothing restore. if restart eclipse 2 windows open, both re

git - TortoiseGit Repo-browser context menu not visible -

i installed tortoisegit 1.18.16.0 (x64 bit) in windows 8 os. when right click on tortoisegit sub-menu, i'm getting following options : settings help about whereas tortoisesvn -> repo browser menu option visible. i tried enabling settings dialog of tortoisegit enable repo browser context menu option. still i'm not able view menu. however other git menus [like pull , fetch , diff , diff previous version etc..,] visible. only menu remains hidden :( . could 1 please tell me how browse git repository using tortoisegit. suggestions appreciated! git menu not visible helped me fix issue, need install following git bash here , git gui here during installations. once installed these, need press 'shift+ right click menu "git repo-browser" make visible. after performing above things, i'm able view 'git repo-browser' menu option [note : remember context menu not visible normal right click instead need shift + right

xpages - SessionAsSigner & restoreWrappedDocument() -

Image
faced following issue: actively use dominodocument class (wrapped document) in projects, particularly basis business model objects. very have need access / iterate business model objects anonymous user underlying lotus.domino.document retrieved based on sessionassigner session object (for example in case of rest services, or in case of xagent, etc). the behavior of restorewrappeddocument() method in such cases breaks flexibility of using such architecture: method tries restore wrapped document based on current execution environment access rights, , of course causes errors acl. let’s consider following code snippet example: public void test3() { try { system.out.println(">>>>>"); system.out.println(">>>>> start"); lotus.domino.database db = appbean.getsessionassigner().getdatabase(appbean.getinstance().getcontactsdbservername(), appbean.getinstance().getcontactsdbname(), false); document

ios - Handling Push Notifications when App is Terminated -

when app not running , receives push notification, if click on notification, app launched - doesn't prompt user alert-view set up, asking them whether want view notification's contents or not. launches, , sits there. the push notifications work when app running - either active app or while in background - nothing works correctly when app not running. i tried logging-out launchoptions nsdictionary in application: didfinishlaunchingwithoptions: see load bringing - comes "(null)". contains nothing - doesn't make sense cause shouldn't contain notification's load? anybody have ideas how make push notifications work when arrive while app not running? i mean how handle push notifications when app in not running state. if, if receive many notifications & did not open app, neither did tap system's notification panel. how preserving push later retrieval. as per question, there no way hold notification when open app, better call api notif

xcode - webview strong iboutlet in delegate is nil, awakefromnib never called -

currently converting obj-c framework swift. in delegate have class iboutlet webview (i defined strong) when try set url (first block phwebviewcontroller): var parent : phfacebook? override func awakefromnib() { let bundle = nsbundle(forclass: phfacebook.self) self.window.title = bundle.localizedstringforkey("fbauthwindowtitle", value: "", table: nil) self.cancelbutton.title = bundle.localizedstringforkey("fbauthwindowcancel", value: "", table: nil) self.window.delegate = self self.window.level = int(cgwindowlevelforkey(.floatingwindowlevelkey)) } var webviewcontroller : phwebviewcontroller? self.webviewcontroller = phwebviewcontroller() self.webviewcontroller!.parent = self self.webviewcontroller!.webview .mainframeurl = authurl my osx app crash , xcode tells me found nil while unwrapping optionnal. have same issue : swift, error exc_breakpoint (code=1, subcode=0x100695474) except me iboutlet connected strong at

javascript - How to prevent a button from going to original state when refreshed -

i have button #first upon click replaced #second . after getting second button , if refresh page going first button. if want button second button after refresh how can achieve this? thank in advance <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { $("#first").replacewith('<button id="second">second button</button>'); }); }); </script> </head> <body> <button id="first">firstbutton</button> </body> </html> set cookie persist state of button , on document.ready,fetch saved state , display such.

javascript - How to do base class concept for CRUD in angularjs? -

currently doing student project in angularjs. in need use base class concept crud operation.. need create 1 base class in class contain create, read, update , delete method.. through out application need use common method based on parameter , object save data corresponding location.. create service or factory handle $http needs. using angular's $http shortcut methods post , get , put , delete returns promise app.factory('dataservice', function($http) { var create = function() { return $http.post("/api/...") // returns promise }; var read = function() { return $http.get("/api/...") }; var update = function() { return $http.put("/api/...") }; var delete = function() { return $http.delete("/api/...") }; return { create: create, read: read, update: update, delete: delete } }); this can re-used throughout application this: app.controller('mycontroller&

android - RadioButton text which is in groupView -

i have few radio buttons in groupview , every radiobutton has own text. if text has more 1 line radio button text center aligned text i'd align radiobutton top of text. my aim :- i have: | text line 1 rb | text line 2 | text line 3 i want: rb | text line 1 | text line 2 | text line 3 for setting text use rb.settext( text ); you can try way: <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <radiobutton android:id="@+id/rb1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <textview android:id="@+id/tv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test_text" /> </linearlayout>

access - update form only with button control -

i saw answeres here none of them fitted me. i have form bounded inputs, want user able edit. though, when user changes fields, , close form - without clicking "update" button - changes data in database. is there way verify data changed when "update" button pressed? thanks you following: 1) define global variable in form "buttonpressed" , set false when enter form or record (e.g. oncurrent). 2) in form_beforeupdate() put following code: if not buttonpressed cancel = true 3) in button_click() put following code: buttonpressed = true docmd.runcommand accmdsaverecord 4) reset buttonpressed after updating form in form_afterupdate() whole code should this: option compare database option explicit dim buttonpressed boolean private sub button_click() buttonpressed = true docmd.runcommand accmdsaverecord end sub private sub form_afterupdate() buttonpressed = false end sub private sub form_beforeupdate(cancel integer)

Android ChildFragmentManager().findFragmentById() always null -

i stumbled crazy little 'bug', or i'm doing wrong. trying reference fragment inside fragment. have parentfragment , child of mainactivity . can reference parentfragment without problem, because parentfragment added mainactivity via code: parentfragment fragment = new parentfragment(); fragmenttransaction transaction = getsupportfragmentmanager().begintransaction(); transaction.replace(r.id.fragmentplaceholder, fragment); transaction.commit(); i have added childfragment parentfragment via xml this: parent_fragment.xml <relativelayout ... etc> .. other views, findviewbyid('') works great on these. <fragment android:layout_width="70dp" android:layout_height="70dp" android:id="@+id/childfragment1" android:tag="1" class="com.my.package.childfragment" android:name="com.my.package.childfragment" tools:layout="@layout/ch

ruby on rails - What is the accepted method for a global state? -

i wondering guys consider best way go having simple stuff stored across sessions without using db. i'm looking have having 'modes' website. can in mode or b, , depending on mode, buttons different things. would using rails.cache.read , write best option ? i've heard has issues heroku if leave cache filesystem, has problems memcache because of multi-threading ? i'm trying avoid having whole table on db getting used users checking global state of site each request. in order have "global" state, need create singke dependency each instance of application. in fact, can't rely on cookies or sessions, client-oriented , not shared between clients. the database common approach. may able use file system in cases, not heroku there may several different instances of app running under different file systems. any solution can shared across instances work: memory database redis sql or nosql database cache systems, long not specific 1 in

python - Use 4 input boxes rather than 3 in tkinter? -

i working on computing level project. using tkinter create text input dialog box. can make work 3 labels need have 4, know if possible? , if how? many thanks edit: http://pastebin.com/7yx7ep51 link has code creating dialogue box. @ moment 4th ones commented out testing other parts the problem closing parenthesis: root = tk() label1 = label(root, text = "dive number") e1 = entry(root, bd = 5) label2 = label(root, text = "time in") e2 = entry(root, bd = 5) label3 = label(root, text = "time out") e3 = entry(root, bd = 5) label4 = label(root, text = ("max depth"))#--------------new-------------- e4 = entry(root, bd = 5) def getinfo(): print (e1.get()) print (e2.get()) print (e3.get()) print (e4.get()) submit = button(root, text = "submit", command = getinfo) label1.pack() e1.pack() label2.pack() e2.pack() label3.pack() e3.pack() label4.pack() e4.pack() submit.pack(side =bottom) root.mainloop()

python 3.x - SQLAlchemy: Formatting a db.DateTime() column result -

i have relative simple sqlalchemy query (on mysql database): my_date = db.session.query(func.max(mytable.date_column)).one() the queried column of type db.datetime() . now want format returned date in my_date : my_date.isoformat() # fails my_date.strftime("%y-%m-%d %h:%m:%s %z") # fails what object result , have datetime object can formatted? when use debugger inspect returned object see following: (datetime.datetime(2016, 1, 28, 12, 35, 17),) - real python datetime.datetime object looks different in debugger. dir(my_date) returns following: ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', &#

javascript - how to change order script tag in head - joomla? -

i use bt-content-showcase plugin in joomla site, slider not work when login works correctly. problem ordering script tag in head section, how change order script tag? here have posible solutions: go extension folder, find script link , comment line, extensions include link in file helper.php . a. manually, add script link before </head> in template. b. templates have option in extensions > templates > your template . c. using extension scriptsdown or javascript async , defer , find this , other extensions in extensions directory . regards.

AngularJS - Detailed explanation on $resource actions -

i not able understand how use $resource actions argument. can please explain example $resource actions argument how "timeout" works etc.

bash - Custom Shell Prompt in iTerm -

i watching a polymer video on youtube , noticed rob's iterm had different shell prompt. the '-> crisper-app part' how can set same in iterm, running on osx yosemite? he using oh zsh , default robbyrussell theme. there lot more themes, can check them out here

Android - Scroll of the content to top of the screen -

Image
i have app structure of image below (1) in xml. need scroll, app remains in image (2). not know how works nicely coordinatorlayout, nestedscrollview... what changes need in xml it? thank you xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/color_primary_dark"> <include android:id="@+id/fondo_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/toolbar" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <rela

python - Get tag information from openstreetmap, specifically tag info -

i have code giving me information geotag of image have obtained flickr. code following: geolocator = nominatim() location = geolocator.reverse("{}, {}".format(lat, lon)) print(location.address) print url print(location.raw) dict = location.raw osmid = dict.get('osm_id', 'default_value_if_null_here') osmtype = dict.get('osm_type', 'default_value_if_null_here') print osm_type i obtaining lat, lon , url variables image obtain. using geopy package receive following results 5, linnaeusweg, paardenveld, ijsselstein, bestuur regio utrecht, utrecht, nederland, 3401ms, nederland https://farm2.staticflickr.com/1456/24640378196_c096ea190b_m.jpg {u'display_name': u'5, linnaeusweg, paardenveld, ijsselstein, bestuur regio utrecht, utrecht, nederland, 3401ms, nederland', u'place_id': u'37712154', u'lon': u'5.0540829', u'osm_type': u'node', u'licence': u'data \xa9 openstreetm

category - Display all categories assigned to a custom post type using post id wordpress -

i have created custom post type in wordpress site. , added many posts custom post type. i want display categories assigned each posts in custom post type. please me. thankz... you can try: $terms = get_the_terms($post->id, 'your_taxonomy_name'); http://codex.wordpress.org/function_reference/get_the_terms but have set taxonomy cpt first: http://codex.wordpress.org/function_reference/register_taxonomy

javascript - setting Dropdown value by JQuery -

i have tried various method none of them seems working .. my dropdown autocomplete , have used "select2" plugin that this dropdown @html.dropdownlist(model.deptprop, new selectlist(bmsa.ui.utility.utility.getalldepartments(model.countrycode), "value", "text", model.deptid), new { onchange = "getarrnds();" }) this jquery function function loadmap(qstr){ alert($('select[name$=deptid]').val()); //this working fine, getting value dropdown // following methods not working var deptid=3; $("select[name$=deptid]").val(deptid); $("select[name$=deptid]").get(0).selectedindex = deptid; $('select[name$=deptid]').val(deptid).attr("selected", "selected"); $('select[name^="deptid"] option:selected').attr("selected",deptid); $('select[name^="deptid"] option[index="3"]').attr("selected","sele

c# - Regex for two characters -

how construct regex allow enter ca or ch ? tried \bc(a|h) , c(a|h) need validate in keypress event of textbox this; private regex _regex = new regex(@"c(a|h)"); private void txtcach_keypress(object sender, keypresseventargs e) { if (char.iscontrol(e.keychar)) return; if (!_rolfregex.ismatch(e.keychar.tostring().toupper())) e.handled = true; } you can use if (e.keychar != (char)8) // not backspace key if (!regex.ismatch(txtcach.text.toupper() + e.keychar.tostring().toupper(), @"^c[ah]?$")) // if value not ch or ca e.handled = true; // not let pass inside keypress event handler, txtcach.text contains value before adding next key. so, full value need add newly pressed key value. after that, can check if value 1 can accept. ^c[ah]?$ this regex accepts c or ca or ch values, can type them in. then, need validate @ other event ^c[ah]$ ( leave event, example). live validation cannot performed

reactjs - react router cannot access child url from browser -

here redux route: const routes = ( <router history={browserhistory}> <route path="/" component={app}> <indexroute component={login} /> <route name="first" path="/first" component={first} /> <route name="second" path="/second" component={second} /> </route> </router> ) export default routes my app component have header , : class header extends component { render() { return ( <div> <h3><link to="first">first</link></h3> <h3><link to="second">second</link></h3> </div> ) } } export default header this works fine.. header rendered , when click routed thier respective url.. what facing problem can route on click.. when access /first url browser getting 404 . when access / redirects me login page header , on clickin

Creating a Cassandra Connection Pool with JBoss -

i'm new cassandra , jboss, , trying create connection pool. i've searched everywhere , found bits , pieces of information, i'm still missing something. i'm not clear on need in standalone file, within driver element. should specify driver-class , xa-datasource-class? and, in module..xml, path should using in resource-root element? i have these 2 jar files - correct? cassandra-driver-core-2.0.2.jar cassandra-driver-dse-2.0.2.jar i'm able open connection , execute cql queries standalone java class, need create connection pool in jboss. appreciated. thanks. cassandra driver, maintains connection pool (atleast datastax jars), configurable, in run-time, , can configured while making session. on top of cassandra driver lets read connection pool status, if have chosen that. can create own monitoring service connection pool status. so, not sure, trying achieve here, pool on top of pool?

Change row names of a dataframe in R -

i have dataframe df df<-structure(list(site_id = structure(c(2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 4l, 4l, 4l, 4l, 4l, 4l), .label = c("day", "id.1.00000", "id.10.0000", "id.11.0000", "id.12.0000", "id.13.0000", "id.14.0000", "id.15.0000", "id.16.0000", "id.17.0000", "id.18.0000", "id.19.0000", "id.2.00000", "id.20.0000", "id.21.0000", "id.22.0000", "id.23.0000", "id.24.0000", "id.25.0000", "id.26.0000", "id.27.0000", "id.28.0000", "id.29.0000", "id.3.00000", "id.30.0000", "id.31.0000", "id.32.0000", "id.33.0000", "id.34.0000", "id.35.0000", "id.36.0000", "id.37.0000", "id.38.0000", &quo

upgrade - MATLAB dicominfo fails in 2015b -

when trying open dicom file this: index exceeds matrix dimensions. error in dicominfo>parseperson (line 371) personname(p).(pnparts{q}) = [personname(p).(pnparts{q}) '=' componentparts{q}]; however used work smoothly in 2013a. know matter? it's indeed bug in matlab r2015b. solution change p q didn't work me. seems work: swap line 336 of dicominfo.m for personname = repmat(makeperson(pnparts),[1,numel(splitrawdata)]); swap line 354 of dicominfo.m for personname(p) = makeperson(pnparts);

javascript - Passing Array From PHP to JQuery json_encode -

i have html form generated php has dropdown of voucherproviders. i want select provider , have populate form editing. here jquery code: $(document).ready(function() { $(document).on('change','#id_voucherprovider',function(){ var voucher_providers = <?php echo json_encode($voucher_providers); ?>; //the value have got drop down is.... var value = $('#id_voucherprovider option:selected').val(); var vendortext = $('#id_voucherprovider option:selected').text(); //so voucher provider alert(vendortext); $('.ftext input').val(vendortext); $("textarea#id_vendornotes").val(voucher_providers[value]); }); }); voucherproviders not being passed jquery despite echo json_encode($voucher_providers); code working when inline php code. it seems return null array. can see wrong? many thanks dave var voucher_providers = <?php echo json_encode($v

javascript - How to show table rows based on checkbox selected -

i have 3 check boxes of types "one", "two"and "three" , table having column 'type' contains 3 distinct values one, 2 , 3 across few rows. requirement is, based on check boxes selected or deselected rows of table should shown value of 'type' column match check box value. for example, if check box "one" selected, rows having "one" type should shown. if both "one" , "three" selected,those rows having "one" , "three" type should displayed. again if "three" deselected, rows matching "three" type should hidden,only rows of type "one" should shown , on. but, not able produce desired result, attached code below, can please help. <html> <head> <script src ="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery. min.js"></script> <title>hello </title> </head> <body> <

Sql programming Language -

scenario: lets assume have order id 1001 ,where have 5 products being ordered in order (1001)..when had issue in 1 of product,we assign customer executive solve issue , there customer executive resolved date 1 product..i want date applied 4 products present within same order id (1001)... i have explained 1 order..consider situation have thousands of order id s. how map them eg: 1001: p1,p2,p3,p4,p5 since there issue product p2,the issue forwarded cet , once resolve have cet resolved date i want same date replicated in p1,p3,p4,p5 in case had issue p2,p3 pick max of 2 dates , replicated in p1,p4,p5 same case should applied other order ids too a generic solution create before update trigger capture incoming order id , cet_resolved_date . find max(date) order_id , compare incoming et_resolved_date . ever maximum, save in variable. run update statement order_id , set other dates date saved in variable. suppose 1001 . p2 got updated date, before u

c# - UWP: Using Cloud image FilePath Access Denied -

i'm using file picker select image use in app. save filepath in other pages of app, display image filepath. when image on device, works. if image on cloud, file path: "c:\data\users\defapps\appdata . . .\tempstate\sharecache\img_1613.jpg" gives me error message access denied. one solution can think of once image selected making copy of image device filepath accessible. is best practice handle situation? this code i'm using: private async void addpic_onclick(object sender, routedeventargs e) { fileopenpicker openpicker = new fileopenpicker(); openpicker.viewmode = pickerviewmode.thumbnail; openpicker.suggestedstartlocation = pickerlocationid.pictureslibrary; openpicker.filetypefilter.clear(); openpicker.filetypefilter.add(".bmp"); openpicker.filetypefilter.add(".jpg"); openpicker.filetypefilter.add(".jpeg"); openpicker.filetypefilter.add(".png");

python 3.x - flask_moment current time refresh in browser not updating -

following basic setup python3.4, jinja2, flask_moment (0.5.1), flask(0.10.1) integration. trying out capability understand workings. example nonsensical want browser display: firstly, actual time in real time ("the local time ...") continually updated in real time secondly, time elapsed ("that ..."). jinja2 code: <p>the local time {{ moment(current_time).format('lt', refresh=true) }}.</p> <p>that {{ moment(current_time).fromnow(refresh=true) }}</p> the second line refresh works fine in browser ("that 1/2/3 minutes ago"), indicating libraries working correctly, first line refresh doesn't work. the method moment(current_time).format('lt', refresh=true) thought display time in real time refresh option set "true", doesn't. looking @ browser markup, libraries there , there no errors. see markup below. hints appreciated or maybe misunderstanding capability? browser source:

c# - datetime parsing exception -

i finding taking current date (only date) in datetime datatype. for made googling , made following code>> datetime dtcurrdate; dtcurrdate=datetime.parseexact(datetime.now.date.toshortdatestring(),"mm/dd/yyyy",null); this code giving me exception : string not recognized valid datetime. what mistake within it? please me. i believe aware of datetime.now.date property, give current date time set 00:00:00 . now why having problem in parsing: probably because of current culture, datetime.toshortdatestring() give (for en-us culture): displaying short date en-us culture: // 6/1/2009 (short date string) and later parsing with: "mm/dd/yyyy" need single digit m , d so code be: dtcurrdate=datetime.parseexact(datetime.now.date.toshortdatestring(),"m/d/yyyy",null); it better if can store result of toshortdatestring() in string , check kind of format get, , parse accordingly.

monitoring - Sudden Mongodb high connections/queues, db completely freezes -

Image
the issue we have strange issue on our mongodb setup. peaks of high connections , high queues , mongodb process stops responding if let queues , connections increase. need restart instance using sigkill htop . it seems there system limit / mongodb configuration blocking mongodb operating, because hardware resources ok. versions of issue happening on stand alone , replica set on production servers. details ahead. about software environment this stand alone mongodb instance (not sharded nor replica sets), it's operating on dedicated machine, , it's queried other machines. i'm using mongodb-linux-x86_64-2.6.11 under debian 7.7. the machines querying mongo using django==1.7.4, mongoengine=0.10.1 pymongo==2.8. on django settings.py file i'm connecting database using following lines: from mongoengine import connect connect( mongo_db, username = mongo_user, password = mongo_pwd, host = mongo_host, port = mongo_port ) mms stats as can

angularjs - How to set cookies in angular dynamic -

i have problem cookies in angularjs. tried create cookie when user did action. saw others examples, in each example cookie created statical when controller created. html code: <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="style/bootstrap-3.3.6.min .css"> <link rel="stylesheet" type="text/css" href="style/style.css"> </head> <body ng-app="myapp"> <div class="container-fluid" ng-controller="myctrl"> <div class="row" id="all_products" data-ng-init="init()"> </div> </div> <script type="text/javascript" src="script/angular-1.4.9.min.js"></script> <script type="text/javascript" src="script/angular-cookies-1.4.9.min.js"></script> <script type="text/javascr

c - Can't see logical issue on this simple program -

i wrote program, , supposed read numbers, calculate medium value , print closest number it. #include<stdio.h> int main(){ const int num = 6; int i, i2 = num - 1; float numeros[num], dist[num]; float media = 0; (i = num - 1; >= 0; i--){ printf("digite um numero\n"); scanf("%f", &numeros[i]); media = media + numeros[i]; } media = media / num; (i = num - 1; >= 0; i--){ if (numeros[i] <= media){ dist[i] = media - numeros[i]; } else{ dist[i] = numeros[i] - media; } } (i = num - 2; >= 0; i--){ if (dist[i] < dist[i + 1]){ i2 = i; } } printf("o numero mais proximo da media '%1.0f' eh '%1.0f'", media, numeros[i2]); printf("\n\npressione 'enter' para sair"); fflush(stdin); getchar(); return 0; } but like input 50 50 50 500 24 20 (o

linq - Retrive value of lambda expression -

i have function : public static iqueryable<tsource> whereif<tsource>(this iqueryable<tsource> source, expression<func<tsource, bool>> exp1, expression<func<tsource, bool>> exp2, expression<func<tsource, bool>> exp3) { } and use function : adverts.whereif(x=>x.deactivateddate.hasvalue, x => x.deactivateddate.value > stardatetime, x => x.modifieddate > stardatetime); how can value of exp1 ? in extenssion need know if deactivateddate.hasvalue true you can evaluate expression, need instance of tsource evaluate against. since "input" collection of tsource youe solution might like: foreach(tsource t in source) { bool istrue = exp1.compile()(t); // evaluate exp1 item if(istrue) // else // else } but note return type in iqueryable<tsource> - i'm not sure you've thought through how intend build resulting query...