Posts

Python int() to the nearest value -

the way python int() function works rounds number smallest value. such 4.99 = 4 what can if want 4.99 equal 5? int() truncates float values, removing non-integral portion of number. looking rounding instead. you can use round() function that: >>> round(4.99) 5

embedded linux - how to add libselinux into the openwrt build system? -

i building openwrt system selinux support. first meet bug cannot find , during busybox compiling. , know there libselinux library needed build busybox selinux support. not familiar openwrt makefile, want know how add library in it? there guide? further more, have find code in selinux github( https://github.com/selinuxproject/selinux ) different code have find in local linux source in openwrt ("/linux/security/selinux/*"). why? know selinux supported in linux2.6. seems still have port selinux linux self? this problem has blocked me long time. soft of appreciated, thanks! i know selinux on debian, since mix different things, answer "why?" part: the linux-kernel offers interface via linux security modules (lsm) selinux , other security modules (that see in "local linux source"). to manage selinux , policies there userland tools (that github link). selinux policies compiled .pp files consist of .te/if/fc files , there ready-to-use rules c...

objective c - Cocoa/objectiveC UI design issue -

i'm trying build app on macosx - objectivec. don't not find ressource understand how can create view need , steps made it. i'm looking create 3 sections. section 1: few buttons , 1 image section 2: treeview have file browser/finder section 3: progress bar show disk usage. i'm creating app read android device , manage file transfer. such android file transfer. first , foremost need on tutorial apple provides on creating first mac app . second can use nsoutlineview create treeview, here's tutorial on this. then need nsprogressindicator progress bar, here's tutorial. i suggest on @ ray's tutorials started xcode , interface builder tools.

python - How do I quantize data in pandas? -

i have dataframe a = pd.dataframe(a.random.random(5, 10), columns=['col1','col2','col3','col4','col5']) i'd quantize specific column, col4 , according set of thresholds (the corresponding output integer 0 number of levels). there api that? most pandas objects compatible numpy functions. use numpy.digitize : import pandas pd = pd.dataframe(pd.np.random.random((5, 5)), columns=['col1','col2','col3','col4','col5']) # col1 col2 col3 col4 col5 #0 0.523311 0.266401 0.939214 0.487241 0.582323 #1 0.274436 0.761046 0.155482 0.630622 0.044595 #2 0.505696 0.953183 0.643918 0.894726 0.466916 #3 0.281888 0.621781 0.900743 0.339057 0.427644 #4 0.927478 0.442643 0.541234 0.450761 0.191215 pd.np.digitize( a.col4, bins = [0.3,0.6,0.9 ] ) #array([1, 2, 2, 1, 1])

javascript - Enable datetime selection in ruby on rails -

i new ruby on rails. want display date format yyyy-mm-dd hh:mm:ss . on using calendar_date_select method :time=>true in view, able display format yyyy-mm-dd hh:mm . there method overwrite current diplaying format format need? you can use 'strftime' method on dates format desire. ex. time = time.now time.strftime('%y-%m-%d %i:%m:%s %p') #this gives 2015-07-15 08:28:38 pm

Combining four tables in SQL Server -

i have 4 tables table a , table b , table c , table d . schema of 4 tables identical. need union these 4 tables in following way: if record present in table a considered in output table. if record present in table b considered in output table if not present in table a . if record present in table c considered if not present in table a , table b . if record present in table d considered if not present in table a , table b , , table c . note - every table has column identifies table every record (i don't know if of importance) records identified based on particular column - column x not unique within each table you (only 2 cases shown should see how extend this) with cte1 ( select 't1' source, x, y t1 union select 't2' source, x, y t2 ), cte2 ( select *, rank() on (partition x order case source when 't1' 1 when 't2' 2 ...

java - How to parse HttpServletRequest for curl / wget options? -

when request done in curl user parameter like: curl -u <user> http://url... how can user? since curl uses http basic authentication default, user , password combined using : separator , encoded using rfc2045-mime variant of base64. can base64-encoded value authorization header. header may looks authorization: basic qwxhzgrpbjpvcgvuihnlc2ftzq== . see this wiki , rfc 2617 more information.