Posts

Showing posts from April, 2012

javascript - Adding an event in a dynamically generated class on hover -

i attempting loop hover effect such image dances 4 corners of site (top left corner -> top right corner -> bottom right corner -> bottom leftcorner -> top left corner) the way doing adding class, hoverleft, right, down, up, etc. , removing previous class. issue have dynamically added classes not recognized after page loads. have been trying work .on() function have been having difficulty. not sure why , pretty sure missing simple. here have, html js: fiddle here: http://jsfiddle.net/5w0nk6j9/4/ <div class="bodycontainer"> <div id="kim"> <div id="dance" class="dancingkim"> <div class="header"> <h2 class="introheader">hover original</h2> </div> <img src="http://placehold.it/240x208" /> </div> </div> $('#kim').hover(function(){ $(".header h2").text("hover text"); }); $(...

java - JUnit: Test exception doesn't work (AssertionError: Expected exception even if exception thrown) -

i'm trying test class exception. i've been trying couple different methods, nothing works. doing wrong here? the class i'm trying test, primenumber.java: public class primenumber { static final logger log = logmanager.getlogger("log"); private string primenumberstr; public primenumber(string primenumberstr) { this.primenumberstr = primenumberstr; } public string getprimeresult() { string resultstr = ""; try { // convert user input int int primenumberint = integer.parseint(primenumberstr); // beginning of return message resultstr += primenumberint + " "; // add "not" if it's not prime if (!primes.isprime(primenumberint)) resultstr += "not "; // end return message resultstr += "a prime"; // if not valid number, catch } catch (nu...

android - Reason for NullPointerException if setContentView() is not used -

i know need place setcontentview() in oncreate() method before initializing view otherwise throw null pointer exception. reason it?is setcontentview() similar inflate() method? before initializing view i not know mean "initializing view". given rest of question, going interpret meaning "call findviewbyid() on activity". you need call setcontentview() before calling findviewbyid() , because otherwise there no widgets find. is setcontentview() similar inflate() method? setcontentview() use layoutinflater , inflate() under covers, if pass layout resource id setcontentview() method.

Wanna get only right content in java regex -

what have modify in code: string tags = "<div class='bat'><div id='me'>"; pattern r = pattern.compile("<(.*)>",pattern.case_insensitive| pattern.multiline | pattern.dotall ); // create matcher object. matcher m = r.matcher(tags); while (m.find( )) { system.out.println("found : " + m.groupcount() ); system.out.println(m.group()); } output : found : 1 <div class='bat'><div id='me'> and want output : found: 2 div class='bat' div id='me' you need ahead , behind this i.e. (?<=<)([^>]*)(?=>) string tags = "<div class='bat'><div id='me'>"; pattern r = pattern.compile("(?<=<)([^>]*)(?=>)", pattern.case_insensitive | pattern.multiline | pattern.dotall); output : found : 1 div class='bat' found : 1 div id='me' edit replaced .*? [^>]* performance sugges...

android - Loading Radiobutton from sqlite table -

is possible load radiobuttons/radiogroup straight sqlite table? is, code generate radiobutton/radiogroup loaded sqlite column. i'm attempting load information database table directly listview. user can scroll through list view , click radio buttons inside each listview for can create custom listview , in handle it's onclick appropriate outcome. useful link learn custom list view: http://www.codelearn.org/android-tutorial/android-listview

circle - WPF: 2 string.format in the same TextBlock? -

i have circle slider , inside slider put textblock shows slider value, use string.format present value in int instead of double : <textblock text="{binding path=value, elementname=knobslider, stringformat={}{0:#,#}}" foreground="white" fontfamily="trebuchet ms" fontsize="25" horizontalalignment="center" verticalalignment="center" /> now want add before slider value specific character example '*' , possible user string.format ? no need stringformat - if you're trying add characters before value, need replace double curly braces text. think you're trying achieve: <textblock horizontalalignment="center" verticalalignment="center" fontfamily="trebuchet ms" fontsize="25" foreground="white" text="{binding path=value, elementname=knobslider, ...

swift - NSNumberFormatter inside a computed Property -

i trying format string number nsnumberformatter. code looks this: var displayvalue: double? { { let = "4.2" return nsnumberformatter().numberfromstring(i)?.doublevalue } } the property nil , missing? martin r ! right locale issue "4,2" works fine, thanks!

datetime - extracting days between a dataframe date and today -

i have date in dataframe , create dataframe column has number of days between date (option expiration) , today. date looks this: df2.expiration.head(1) 0 05/29/15 name: expiration, dtype: object i tried this: from datetime import datetime def compare_dates(date): date_format = '%m/%d/%yy' current_date = datetime.strptime(date, date_format) today = datetime.today() diff = current_date - today return diff.days df2['days_since'] = df2['expiration'].apply(compare_dates) but long error message final line of: valueerror: time data '05/29/15' not match format 'mm/dd/yy' thank once again ! john try following (note lower case 'y'): date_format = '%m/%d/%y' %y 4 digit year, , %yy 4 digit year ending in 'y', e.g. '2015y'. s = '05/29/15' >>> dt.datetime.strptime(s, '%m/%d/%y').date() datetime.date(2015, 5, 29)

How can I build Python CFFI modules during development? -

what best practices building cffi modules during development? right i'm using makefile: mylib/_ffi.so: my_lib/build_ffi.py python $< and test can use: $ make && python test.py but seems suboptimal. there better way of building cffi modules during development? if project using setuptools, python setup.py develop appears build library in-place: $ python setup.py develop ... finished processing dependencies my-lib==0.1 $ ls my_lib/ _ffi.so ... but doesn't seem there make clean equivilent ( setup.py clean cleans build/ directory), isn't quite ideal.

How to extract the final part of the URL's path in Haskell -

i using network.uri parse url ( string ). how can returned uri ( parseuri url ) last part of path? or there better alternatives network.uri ? for example from: http://www.foo.com/foo1/foo2/bar.html?q=2&q2=x#tag i "bar.html" you can quite extract final part uri . extract uripath parsed uri , , take in reverse until hit slash. for example, getfinalpart :: uri -> string getfinalpart = reverse . takewhile (/='/') . reverse . uripath

numerical methods - error bound in function approximation algorithm -

suppose have set of floating point number "m" bit mantissa , "e" bits exponent. suppose more on want approximate function "f". from theory know "range reduced function" used , such function derive global function value. for example let x = (sx,ex,mx) (sign exp , mantissa) then... log2(x) = ex + log2(1.mx) range reduced function "log2(1.mx)". i have implemented @ present reciprocal, square root, log2 , exp2, i've started work trigonometric functions. wandering if given global error bound (ulp error especially) possible derive error bound range reduced function, there study kind of problem? speaking of log2(x) (as example) lke able say... "ok want log2(x) k ulp error, achieve given our floating point system need approximate log2(1.mx) p ulp error" remember said know working floating point number, format generic, classic f32, example e=10, m = 8 end on. i can't find reference shows such kind of study. refe...

php - How to use one variable in more function in one controller in laravel 4 -

i have controller has functions , want use 1 variable through them class trainercontroller extends \basecontroller { public function one(){ $variable = "some data"; } public function two() { //how use $variable here ?! } } i tried use session session scope in 1 function (view) in advance make property class trainercontroller extends \basecontroller { private $variable; public functionone(){ $this->variable = "some data"; } public functiontwo() { echo $this->variable; //outputs 'some data' if 1st method has been called } }

rust - Struct that owns some data and a reference to the data -

this question has answer here: how initialize struct fields reference each other 1 answer construction of object allocates data needed lifetime of object, creates object needs keep references data: pub fn new() -> obj { let data = compute(); obj { original: data, processed: anotherobj { reference: &data } } } is possible express in rust's terms? here i'd obj , anotherobj , data have same lifetime, , of course outlive new() call. a raw design of structs based on requirements might this: struct anotherobj<'a> { original: &'a vec<i8>, // let's agree on vec<i8> "data" type. } struct obj<'a> { original: vec<i8>, // <-------------------+ processed: anotherobj<'a>, // should point here --+ } howev...

php - Add table row for each table row in database table -

i couldn't find post problem. trying add in html new table row every new table row have in phpmyadmin table php script. my code is: <?php if($check == true) { echo" <a href='php/logout.php' class='subpages'>logout</a> <tr> <td> filename: <a href='../uploads/$filename'>$filename</a> </td> <td>"; $connect = mysql_connect("localhost","root",""); mysql_select_db("phplogin"); // select db $getcomment = mysql_query("select comment files name='$filename'"); while($row = mysql_fetch_assoc($getcomment)) { echo"comment: ".$row['comment']." </td> </tr>"; ...

html - How to make a text with smaller width stay on a image with 100% width even if the screen is resized? -

how make text smaller width stay on image 100% width if screen resized? want text stays on background. @ moment text goes outside of image when make screensize smaller tried , can't find solution it. please help! html(ruby on rails) <div class="outer-wrapper"> <%= image_tag("x.png" class="background") %> <div class="inner-wrapper"> <p> feel free reach out me that’s on mind. i’m happy hear people , i’ll respond possible. </p> </div> </div> css part .outer-wrapper { } .background { min-width: 100%; margin: 0 auto; display: block; position: relative; height: 900px; } .inner-wrapper { width: 41%; height: 100%; margin: 2% auto; left: 0; right: 0; position: absolute; top: 172%; }

ios - Twitter Kit/Fabric “Show Timeline” Objective-C example build fail -

following along fabric/twitter kit documentation display user timeline. code docs doesn't build. this code in timeline view controller in view did load. [[twitter sharedinstance] loginguestwithcompletion:^(twtrguestsession *guestsession, nserror *error) { if (guestsession) { twtrapiclient *apiclient = [[twitter sharedinstance] apiclient]; twtrusertimelinedatasource *usertimelinedatasource = [[twtrusertimelinedatasource alloc] initwithscreenname:@"fabric" apiclient:apiclient]; self.datasource = usertimelinedatasource; // <- build fail here } else { nslog(@"error: %@", [error localizeddescription]); } }]; xcode complains: "property 'datasource' not found on object of type 'timelineviewcontroller ". not sure why it's acting since verbatim docs example. any appreciated! talked friend, helped me figure out originally had this @interface timelineviewcontroller : uiviewcontroller needed chang...

java - Number of player objects more than 30 -

lets have array list of players , want players above age of 30. players have usual attributes name , age , getname , getage methods. i'm new java here appreciated. thanks. for(player p: players){ if(p.getage() > 30){ system.out.println(p.getname()); }} here possible solution you. assumption: have class player , can read players , add in allplayers arraylist. import java.util.*; public class game { //holds list of players. arraylist<player> allplayers = new arraylist<player>(); //holds list of players older 30 years. arraylist<player> olderthan30 = new arraylist<player>(); public game() { //read players list , fill in above arraylist players have. //for example, allplayers = getallplayers(); can use io methods read external files. //get players older 30 years of age calling method get30olderplayers(). olderthan30 = get30olderplayers(); } private arraylist<player> get3...

cookbook - Setting up private Supermarket Chef -

i setting private supermarket on ec2 driver through test kitchen using omnibus cookbook , have placed corresponding cookbooks "packagecloud" "supermarket-omnibus-cookbook" , "chef-server-ingredient" . when running kitchen converge , getting following error : [2015-06-12t17:13:54-04:00] warn: remote_file[/etc/pki/rpm-gpg/rpm-gpg-key-packagecloud_io] cannot downloaded https://packagecloud.io/gpg.key: 407 "proxy authentication required" ================================================================================ error executing action `create` on resource 'remote_file[/etc/pki/rpm-gpg/rpm-gpg-key-packagecloud_io]' ================================================================================ net::httpserverexception ------------------------ 407 "proxy authentication required" resource declaration: --------------------- # in /tmp/kitchen/cache/cookbooks/packagecloud/provid...

c++ - Cannot access private member declared in class 'CCustomCommandLineInfo' -

i trying add command-line interface existing mfc application, , found class online at website . have adapted needs , when try build error reads "error c2248: 'ccustomcommandlineinfo::ccustomcommandlineinfo' : cannot access private member declared in class 'ccustomcommandlineinfo'" here's code: class ccustomcommandlineinfo : public ccommandlineinfo { ccustomcommandlineinfo() { //m_bexport = m_bopen = m_bwhatever = false; m_bnogui = m_bamode = false; } // convenience maintain 3 variables indicate param passed. bool m_bnogui; //for /nogui (no gui; command-line) bool m_bamode; //for /adv (advanced mode) // bool m_bwhatever; //for /whatever (3rd switch - later date) //public methods checking these. public: bool nogui() { return m_bnogui; }; bool amodecmd() { return m_bamode; }; //bool iswhatever() { return m_bwhatever; }; virtual void parseparam(const char* pszparam, bool bflag, bool blast) ...

javascript - How to remove a UI element from a web page that's not present at document.ready? -

i'm regular user of site https://www.lingq.com . site added "share" side panel, slides in left few seconds after page loaded. it's annoying, covers portion of text on site. after while got fed having manually click away every time. i'm using greasemonkey remove it, problem element not yet there when document.ready occurs. i'm getting around using timeouts. jquery(document).ready(function () { settimeout(function () { jquery('#at4-share').remove() }, 5000) settimeout(function () { jquery('#at4-share').remove() }, 10000) }); after experimenting i've settled on 2 timers. first 1 (after 5 seconds) removes thing moment shows up. second 1 there because sidebar not have appeared in time. site quite bit of javascript processing upon loading, , thing appears after it's done. while solution works, it's crude , ugly. i'd solution reliably removes panel, no matter how long takes appear. ideally, shouldn't see...

sass - Files starting with underscore at the beginning what do they mean? -

i have had couple of projects other people developed. i think ok. the programmers have created files starting underscore , example _variables.scss, have seen in both of projects. i cant figure out why, have googled , cant find answer, if there special reason why people naming files way. thanks! according me reason use underscore before name of partial the underscore lets sass know file partial file , should not generated css file.*" any sass files not beginning underscore rendered on own, fail if using variables or mixins defined elsewhere. in end have concluded underscore used clarify partial file. can use partial file without using underscore prefix.

rust - Cargo dependency version syntax -

is there page documenting different cargo syntax dependencies? far have seen three... [dependencies] crate = "1.0.0" # think exact version match crate = "^1.0.0" # think means "use latest 1.x.x" crate = "*" # think means "use latest" i'd love know how use dependency list. thanks! see crates.io documentation page on "specifying dependencies" . summarise: nothing or caret ( ^ ) means "at least version, until next incompatible version". a tilde ( ~ ) means "at least version, until (but excluding) next minor/major release". is, ~1.2.3 accept 1.2. x x @ least 3, ~1.2 accept 1.2.* , , ~1 accept 1.*.* . a wildcard ( * ) means "anything looks this". is, 1.2.* accept 1.2. anything ( 1.2.0 , 1.2.7-beta , 1.2.93-dev.foo , etc. not 1.3.0 ). inequalities ( >= , > , < , = ) mean obvious: version cargo uses must satisfy given inequality.

javascript - ASP.NET MVC jQuery JSON result redirecting URL -

using mvc/json/jquery. using form create new "group". form on ~group/manage, posting form ~group/create whilst working on this, returning json result working fine, handling in jquery, no url redirection. now, everytime run it, redirects me ~group/create , displays json result. controller group/create [httppost] public actionresult create([bind(include="name,description")] groupmodel groupmodel) { ... return json(new { success = true, message = groupmodel.name }, jsonrequestbehavior.allowget); } form <form id="frm_creategroup" action="/groups/create" method="post"> <h2>create group</h2> <div class="form-group"> @html.labelfor(model => model.name, new { @for = "name" }) @html.textboxfor(model => model.name, new { @class = "form-control", @placeholder = "group name" }) ...

android - how to use Instrumentation under the uiautomator project? -

i'm working on uiautomator project , uiobject.getfromparent turn out wrong element me , source code of uiautomator , found out answer because uiselector used. i found uiautomator using instrumentation ui element stuff : getinstrumentation().getuiautomation().getrootinactivewindow(); i want accessibilitynodeinfo node uiautomator uiautomator didn't exposed this. i’m trying way new class extends instrumentationtestcase,by getinstrumentation() return null me. i found answer on android instrumentation test case - getinstrumentation() returning null needs injectinstrumentation(instrumentationregistry.getinstrumentation()); , told instrumentationregistry official android testing-support-lib:0.1 i have download android support repository , import testing-support-lib-0.1-source.jar project still can't see instrumentationregistry. anyone have idea cast? i'm using extension of instrumentationtestcase , works fine this: @override public void setup...

linux - Shell script doesn't run -

can , tell me why isn't working? i have checked script , solved problems still doesn't works fine , can't find mistake. #!/bin/bash #variabelen ip="192.168.0." array=($@) #functies what's wrong array? linux told me there syntax error on line 12 array doesn't tell me what. function sorteer(){ array=($(printf '%s\n' "$@"|sort -nu)) in ${array[@]};do ping -c -1 "ip"$i done } function telbij(){ # given number $i +200 b=$(( $i + 200 )) if (( b > 255 )) echo "neem kleiner getal"; else ping -c 1 "ip"$b; fi } function xxyy() { #ping 65-68 = ping 65 66 67 68 start=${1%-*} end=${1#*-} ((i=start;i<=end;i++));do ping -c 1 "$ip"$i done } the mistake in if else function: http://prntscr.com/7gr8yf but don't know means: "the mentioned parser error in else clause." if [ "$#" -eq 0 ]; echo "er moet minimaa...

javascript - Code Beautification with angular-ui-codemirror with indention -

i generated xml code jquery using following code, var _outerblock = $("<outerblock>"); (var = 0; < 10; i++) { var _innerblock = $("<innerblock>serial " + + "</innerblock>") _outerblock.append(_innerblock) } var _tmp = $("<div>"); var $output = _tmp.html(); now getting 1 line xml code in $output variable. tried using codemirror.js beautify code, applying styling not adding indention. here tried browser console plain codemirror.js var mycodemirror = codemirror(document.body, { value: code, mode: "text/html", linenumbers:true }); how can use indention? how can display code angular-ui-codemirror? for correct xml syntax indentation need include <script type="text/javascript" src="codemirror/mode/xml/xml.js"></script> (path xml mode js file may different, anyways need such defined..) then use like: config = { mode : "x...

ruby on rails - Running delayed jobs in loop -

i trying put function in delay. delay start in loop: class test def check_function1 while < b self.delay.check_function2(t1, t2) end end def check_function(t1, t2) #saving data end end if loop runs twice, mix data here? there way rectify? can sleep after 1 loop? delayed job runs polling daemon in background polls jobs table @ regular intervals new jobs. if run 1 dj worker, delayed tasks processed in sequence , potential of race condition isn't there. if run multiple workers need take account race conditions , guard against "mixing data" (i assume meant "mix data"). so yes, running multiple delayed jobs has potential "mix data" if run multiple dj workers. see here more detailed explanation: http://ternarylabs.com/2012/04/16/handle-job-queue-workers-concurrency-in-rails/ sleeping when launching jobs has practically no effect on happens job queue. not want sleep doesn't other delay user interface ...

c# - Methods that use convertPoint:fromLayer implicitly in Xamarin.iOS/MonoTouch -

can give me clues methods use convertpoint:fromlayer implicitly? thank in advance. after last update of xamarin.ios app frequent crash reports users 1 below (uibuttoncontent can other (possibly generated) type uimage, __nscftype, __nscfdictionary, os_voucher, etc.). objective-c exception thrown. name: nsinvalidargumentexception reason: -[uibuttoncontent convertpoint:fromlayer:]: unrecognized selector sent instance 0x145c52e0 @ objcruntime.runtime.thrownsexception (intptr ns_exception) [0x00000] in :0 @ objcruntime.runtime.throw_ns_exception (intptr exc) [0x00000] in :0 @ (wrapper native-to-managed) objcruntime.runtime:throw_ns_exception (intptr) @ (wrapper managed-to-native) uikit.uiapplication:uiapplicationmain (int,string[],intptr,intptr) @ uikit.uiapplication.main (system.string[] args, intptr principal, intptr delegate) [0x00000] in :0 @ uikit.uiapplication.main (system.string[] args, system.string principalclassname, system.string delegateclassname) [0x00000] the cause ...

c - How to return an array of pointers? -

i have made code calculate variance , mean of array of numbers, can't find way return array of pointers. this function: float* statistics(int numbers[], int numbers_len, float * ptr_mean, float * ptr_variance, float * ptr_stdev, int * ptr_median){ float*mean; float*variance; float stat[4]; float*array_stat; int i=0; mean=calculate_mean(numbers, numbers_len); variance=calculate_variance(numbers, numbers_len, mean); stat[0]=*mean; free(mean); mean=null; stat[1]=*variance; free(variance); variance=null; for(i=0;i<2;i++){ array_stat=(float*)calloc(2, sizeof(float)); array_stat[i]=stat[i]; } return array_stat; } i need array_stat array of pointers. in int main() call function *statistics() way: int main(){ int array_numbers[max_items]; int n_numbers, i=0; float *calculate_statistics; calculate_statistics = statistics(array_numbers, n_numbers, ptr_mean, ptr_variance, ptr_stdev, ptr_median); for(i=0;i<2;i++){ ...

iphone - How i can read google analytics data from my iOS application? -

i trying read google analytics data sessions , real time users , locations ... iphone objective-c app is there sdk can achieve or maybe rest api google ? you can build rest api in favourite language , use in iphone app.

vim - powerline status-line on ubuntu server 14.04 (no gui) -

Image
first of all, possible powerline looking on image below in non-gui ubuntu installation? so far i've installed using vundle, removed in favor of pip installation, shown below, cannot proper symbols show, ugly place holder blocks: per official installation instruction downloaded , installed patched fonts in ~/.fonts, after trying "fontconfig" unsuccessfully. refreshed font cache system, , restarted vim, stayed same. changes made on .vimrc were... > set t_co=256 > rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/ > laststatus=2 the instructions followed: askubuntu-powerline , powerline-docs ubuntu server 14.04 vim - 7.4.52 xterm = 256 color thanks! yes is! need way use patched font in console. there 1 patched terminal font, terminus, couldn't work. i discovered fbterm , terminal emulator framebuffer allows customize font , size, add background image. set fbterm , add user video group: sudo apt-get inst...

java - Where to place setContentView() in onCreate()? -

i beginner in android , want know why when place setcontentview() after defining textview , app crashes , i.e protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview tv=(textview) findviewbyid(r.id.tv); linkify.addlinks(tv, linkify.web_urls|linkify.email_addresses| linkify.phone_numbers); setcontentview(r.layout.activity_main); //after textview } but when put setcontentview() before defining textview app runs fine. protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //before textview textview tv=(textview) findviewbyid(r.id.tv); linkify.addlinks(tv, linkify.web_urls|linkify.email_addresses| linkify.phone_numbers); } why & , how adding setcontentview() before makes difference ? setcontentview() literally sets views of activity. if try textview tv=(textview) findviewbyid(r...

Compare differences between MATLAB and python images from the same data -

Image
i ploting same values in python , in matlab ( the data same). just doing import scipy.io sio zzz = sio.loadmat(pathtodata) plot(zzz['zzz'][:,0]) #python in matlab plot(zzz) %matlab i trying matplotlib create image looks same matlab figure, this example . the following images created screen capture avoid post processing of image. made sure both of figures in same size. put 1 next other , created screencapture of them both @ same time i put lines 1 next other: it bit hard see matlab image more noisy , looks python image after moving average of ( in start of plot) do have any advice of how make python figure exactly matlab one? ( uploaded the data if interested in experiments ) edit i tried antialiased = false, results bit better, linewidth bigger no matter how small try ( original screencapture ) i think due fact matplotlib uses anti aliasing when producing figure. however, artist property can set: import matplotlib.pyplo...

php - Fatal error: Unsupported operand types in /var/www/mysite/includes/theme.inc on line 637 -

the error occurred when trying customized own login page in drupal, according source: tutorial on how customize , overriding login pages in drupal and i've been using drush cc all clear cache , somehow appeared. haven't done in codes, since still working when i'm trying apply it, , sure, traced edits , nothing seems wrong it. the line in 637 in mysite/includes/theme.inc // merge newly created theme hooks existing cache. $cache = $result + $cache; it states $result , $cache not having same datatype. that's why facing problem. try var_dump() both value , check there datatype. as stated in comment based on need below:- if(isset($result) && !empty($result)){$cache = $result + $cache;}

android - Error inflating class fragment in activity layout -

i have layout activity: <fragment android:name="com.myapp.fragment1" android:id="@+id/fragment1" android:layout_width="match_parent" android:layout_height="match_parent" tools:layout="@layout/fragment1" /> <fragment android:name="com.myapp.listfragment1" android:id="@+id/fragment2" android:layout_width="match_parent" android:layout_height="match_parent"/> </relativelayout> the first fragment (fragment1) extends fragment, whilst second fragment extends listfragment. don't have layout listfragment. the activity code is: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_info); } an exception thrown on setcontentview: error inflating class fragment the listfragment code is: @override public...

terminal - How to make a scrolling menu in python-curses -

Image
there way make scrolling menu in python-curses? have list of records got query in sqlite3 , have show them in box more max number of rows: can make little menu show them without making curses crashing? this code allows create little menu in box list of strings. can use code getting list of strings sqlite query or csv file. edit max number of rows of menu have edit max_row . if press enter program print selected string value , position. from __future__ import division #you don't need in python3 import curses math import * screen = curses.initscr() curses.noecho() curses.cbreak() curses.start_color() screen.keypad( 1 ) curses.init_pair(1,curses.color_black, curses.color_cyan) highlighttext = curses.color_pair( 1 ) normaltext = curses.a_normal screen.border( 0 ) curses.curs_set( 0 ) max_row = 10 #max number of rows box = curses.newwin( max_row + 2, 64, 1, 1 ) box.box() strings = [ "a", "b", "c", "d", "e", "...

R ggplot2 boxplot not properly shown when knitting html -

Image
tried boxplot ggplo2 ggplot(aes(x = quality, y = residual.sugar),data=data)+ geom_boxplot(fill="#9999cc")+scale_y_continuous(limits =c (0,20)) when exucute in r itself, looks want , this: but when knit html file, looks : anyone knows how fix that? confused :( the difference forgot make quality factor within rmd file. for example: set.seed(101) dd <- data.frame(quality = sample(6:9,size=200,replace=true), residual.sugar = rnorm(200)) library(ggplot2) ggplot(aes(x = quality, y = residual.sugar),data=dd)+ geom_boxplot() dd2 <- transform(dd,quality=factor(quality)) ggplot(aes(x = quality, y = residual.sugar),data=dd2)+ geom_boxplot()

css - Nested backface-visibility is not hidden -

i've got problem "nested" backface-visibility . i have flipping div, content on both sides. that, use 2 div flipping, each 1 representing face of "two-faces" div ( .face , .back ). rotation works well. now, want hide container, , reveal when page loaded flip. can see, .face div visible. how avoid .face visible before animation? here's shorten working example made (chrome favor): .flip { position: relative; backface-visibility: hidden; transform: rotatex(180deg); animation: init 1s ease 2s 1 normal forwards; } .flip div { backface-visibility: hidden; transition: 1s; margin: 0; padding: 20px; border: 1px solid; width: 200px; text-align: center; } .back { position: absolute; top: 0; left: 0; } .face, .flip:hover .back { transform: rotatex(0deg); } .flip:hover .face, .back { transform: rotatex(180deg); } @keyframes init { { transform: rotatex(180deg); } { transform: rot...

jquery - Javascript object property 'null' when iterating through an array of objects -

Image
i have array of objects. somehow, 1 of properties goes missing within each loop. have tried many different types of loops , nothing resolves issue. somefunction(somearrayofobjects) { console.log(somearrayofobjects); // logs objects expect them $.each(somearrayofobjects, function(index, someobject) { console.log(someobject); // 1 of properties of someobject 'null' }); } update: how array constructed: // constructor var people = []; var person = function (name, age, photo) { this.name = name; this.age = age; this.photo = null; }; then use ajax json , create objects success: function(data) { people.push(new person(data['name'], data['age']) } then iterate through each of people , make ajax request each of photos. callback looks this: function(person, photo) { person.photo = photo; }); i new javascript , async programming wrapping mind around callbacks tough. thought had figured out when console.lo...

Python Imaging Library vs layered windows -

i'm using python imaging library take screenshot , save it. i'm trying take screenshot of program uses layered windows, doesn't show on image. know way around or maybe other way image memory? thanks import imagegrab import os import time im = imagegrab.grab() im.save(os.getcwd() + "\\snap_" + str(time.strftime("%h-%m-%s")) + ".jpg","jpeg")

Link error with Xcode 7 beta, address sanitization and CocoaPods + adMob -

i converted ios project xcode 7 beta + swift 2 (it runs , tests work). however, when turn on new address sanitizer (option+run -> run -> diagnostics -> enable address sanitizer, following message linker: undefined symbols architecture x86_64: "___asan_init_v5", referenced from: _asan.module_ctor in libpods.a(pods-dummy.o) ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) seems reference cocoapods use admob pod. updated cocoapods latest version , updated admob pod latest version. any hints how address sanitizer work cocoapods or admob cocoapod whichever causes this?

node.js - Mongoose schema creation error -

i have problem mongoose schema creation when run mongoose+node.js when run application, getting following error: users/tyrant/workspace/myworkspace/nodeprojects/imooc/schemas/movie.js:3 var movieschema = new mongoose.scheme({ ^ typeerror: undefined not function @ object.<anonymous> (/users/tyrant/workspace/myworkspace/nodeprojects/imooc/schemas/movie.js:3:19) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) @ module.require (module.js:365:17) @ require (module.js:384:17) @ object.<anonymous> (/users/tyrant/workspace/myworkspace/nodeprojects/imooc/models/movie.js:2:19) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) @ module.require (module.js:365:17) @ require (module.js:384:17) @ object.<anonymous> (/users/tyra...

Array sorting in angularjs -

i have array of following structure -- the structure of array following - [ {key:12,value:[{e:1,c:2,d:3},{e:34,c:45,d:90},{e:23,c:89,d:34}]}, {key:25,value:‌​[{e:12,c:22,d:32},{e:34,c:45,d:90},{e:23,c:89,d:34}]} ] i have sort columns. how can go it? ng-repeat array looks following -- <tbody> <tr ng-repeat = "key in array track $index"> <td>key.key</td> <td>{{key.value[0].e}}</td> <td>{{key.value[1].e}}</td> <td>{{key.value[2].e}}</td> </tr> </tbody> you can use orderby filter component of ng module of angularjs. example, if want sort columns according key parameter of key variable, can following, <tbody> <tr ng-repeat = "key in array track $index | orderby:'key'"> <td>key.key</td> <td>{{key.value[0].e}}</td> <...

javascript - How to require .json file with module.exports in nodeJS -

im used creating .json files way module.exports = [ {"year":2007,"month":1,"startdate":"2007-01-01","enddate":"2007-01-31"}, {"year":2007,"month":2,"startdate":"2007-02-01","enddate":"2007-02-28"}, {"year":2007,"month":3,"startdate":"2007-03-01","enddate":"2007-03-31"}, ] i require them this. var dates = require('./json/dates.json'); this has worked in past when working nodejs , grunt build websites. im using nodejs create server app message syntaxerror: g:\navision reports\js reportserver\json\dates.json: unexpected token message. dont understand what's going on. working .js files. please knows why no longer works? know have json object if remove var dates = require('./json/dates.json'); , make file 1 json object, i'd rather not reorganise data. this isn'...

html - White Line Appears when using backface-visibility to make css transition effect to zoom image on hover -

im facing difficulty figure out small css issue causing seems backface-visibility property shows white line right of image of 2nd item in each row in grid. im here giving u link html have done far. cant figure out why showing white line. highly appreciated. here link - http://s194142.gridserver.com/webtest/ fyi - see line both chrome , ff. not tested in other browsers. style.css 163 #posts .col.span_sm_4 .post-content - remove - background-color: #fff; style.css 170 #posts .col.span_sm_4 .post-meta - add - background-color: #fff;

java - resource leak 'Nommy' is never closed error -

i'm new java please explain in full i'm going wrong thank you. import java.util.scanner; class apples { public static void main (string args[]){ scanner nommy = new scanner (system.in); system.out.println (nommy.nextline()); } } you should close scanner after using it. otherwise, you'll warning compiler. the simplest way add nommy.close() after last statement. you should, however, call in finally block or using try statement: see https://stackoverflow.com/a/15613676/1547337

c - Print the longest word of a string -

i wrote following code #include<stdio.h> int main(void) { int i, max = 0, count = 0, j; char str[] = "i'm programmer"; for(i = 0; < str[i]; i++) { if (str[i] != ' ') count++; else { if (max < count) { j = - count; max = count; } count = 0; } } for(i = j; < j + max; i++) printf("%c", str[i]); return 0; } with intention find , print longest word, not work when longest word in last i'm programmer printed i'm instead of programmer how solve problem, gives me hand the terminating condition of for loop wrong. should be: for(i = 0; < strlen(str) + 1; i++) and also, since @ end of string don't have ' ' , have '\0' , should change: if (str[i] != ' ') to: if (str[i] != ' ' && str[i] != ...

android - Using "window Translucent Status = true" and want to display Text View value just after action bar -

i want display text after "action bar". because using window translucent status therefore text appearing on "status bar". <style name="apptheme" parent="theme.appcompat.light"> <item name="android:windowtranslucentstatus">true</item> </style> i tried textview property layout:margin top = 100dp , working fine me.. think solution may not work on other mobile phones. would knew better way in proper way?

windows - Pycharm hangs building skeleton for Kivy environment -

i'm trying setup development environment kivy via pycharm in windows process seems hang when gets pil._imagingtk package , doesn't progress. i'm following following guide on how setup pycharm interpret kivy: https://github.com/kivy/kivy/wiki/setting-up-kivy-with-various-popular-ide 's any suggestions? nevermind, hung hour before continuing process.

hadoop - Use of core-site.xml in mapreduce program -

i have seen mapreduce programs using/adding core-site.xml resource in program. or how can core-site.xml used in mapreduce programs ? from documentation , unless explicitly turned off, hadoop default specifies 2 resources, loaded in-order classpath: core-default.xml : read-only defaults hadoop, core-site.xml: site-specific configuration given hadoop installation configuration config = new configuration(); config.addresource(new path("/user/hadoop/core-site.xml")); config.addresource(new path("/user/hadoop/hdfs-site.xml"));

Swift: Access tuples by subscript -

let's have code: let tuples = ("1", 2, "3", "4", "5", "6", "7", false) func tableview(tableview:nstableview, viewfortablecolumn tablecolumn:nstablecolumn?, row:int) -> nsview? { let valueforview = tuples[row] } is there way access tuples subscript? what want not possible tuples , if dont want cast later-on option struct or class. struct seems better choise :) struct mystruct { let opt1 = 0 let opt2 = 0 let opt3 = 0 ... let boolthing = false }

c# - How to Insert Data to the Database? - User Defined Classes -

i'm experimenting databases , i'm finding different methods optimize codes. here i'm using different class stop re writing same codes such add, delete , update use same executenonquery() method. far update delete methods worked except insert. compiler doesn't give errors values taken text boxes doesn't go variable string query. i'm new c# coding. can me? or advice? using dbconnectionexercise.dbconnection_components; namespace dbconnectionexercise { public partial class student_form : form { dbcomps dc = new dbcomps(); //public string constring; //public sqlconnection con = null; //public sqlcommand com = null; public string query; public student_form() { initializecomponent(); //constring = "data source=ashane-pc\\ashanesql;initial catalog=schooldb;integrated security=true"; //con = new sqlconnection(constring); dc.connectd...

c# - How to add items to ComboBox as tree list -

Image
i have problem: want show items in combobox categorized. shown in figure: i have 2 attributes in table , 1 vendorid , other vendortype . want show these vendor types in combobox how should this? combobox items contains objects, pretty dumb. the first thing should create class , maybe this: class comboitem { public string text { get; set; } public int level { get; set; } public comboitem (string text, int level) { text = text; level = level; } public override string tostring() { return "".padleft(level) + text; } } when add them, don't add string instances of new class: for (int = 0; i< 12; i++) { combobox1.items.add(new comboitem("item" + i, i%3)); } that all; trick add few spaces in tostring override. you would, of course pull texts database instead. , provide level of each entry!! here how result looks like, consolas font : if want use owner-drawing more refined looks,...