Posts

Showing posts from January, 2011

Editing a file does not seem to refresh Django pycache -

i trying create own user auth model in django removing username field , replacing email field. the model stored in it's own file in app.user . i keep getting error: app.user: (auth.e003) 'user.email' must unique because named 'username_field'. now, changed line email field be: email = models.emailfield(unique = true) but reason cannot seem bite, or edit in file. in fact can delete file , runserver , on full restart, same error. as make edit settings.py or bites , works, without refreshing cache user model though (only updating cache detects edited). this has led me believe edits file not correctly updating it's pycache. how can file scanned , updated django? move custom user model app.models , set auth_user_model='app.user' . django parses auth_user_model value 'app_name.model_name' , attempts from app_name.models import model_name , if model not in models.py not found. here doc link reference: https://docs.dj...

How can I save a GUI window in Matlab(e.g. as png)? -

Image
i created gui inside matlab; to make easy understandable let's there static , non static textfield , 1 push button in nonstatic text field 1 can enter number , pressing push button answer in static text field, let's 2*a answer; now want have screenshot of gui there can see number in non static field , result in static text field; how shown after pressing button... how can achieve that? thanks in advance.. :) ok it's more simple thought , the screencapture option might overkill in situation. what need getframe function, captures content of axes or figure of choice, here gui. here code simple example can copy , paste. upon pressing button, new window appears content of gui. can replace part of code call imwrite save image in png format. useful code is: %// capture content of current figure f = getframe(gcf); the image data stored in cdata property of structure f , can save eg with. %// imwrite(f.cdata,...) so whole code following: func...

c# - Using Asp.net mvc identity in multiple projects -

we have project in multiple layer ( containing data access layer , service layer , web .... ) have entity person , user , customer , employee going use asp.net identity in our website user register , authentication if want register user in 1 of layers ( not website ) how can according asp.net identity , , authentication ? (my first idea add user database , use passwordhasher class of microsoft.aspnet.identity hash password , there better way ? example move asp.net identity new class library project or other ways ) another thing : i want know how can use entities customer , employee ... in design ? if want register user in 1 of layers ( not website ) how can according asp.net identity you not want bring asp.net identity business logic layer . should @ presentation layer only. (my first idea add user database , use passwordhasher class of microsoft.aspnet.identity hash password , there better way ? example move asp.net identity new class library p...

android - FragmentTransaction, Frame Container, Freeing Fragments and Memory Management -

i have frame layout use swapping fragments. use navigation drawer , every menu item opens fragment. sure in app cycle there only 1 fragment on screen @ same time (and 1 activity). below can find fragment start method public void startfragment(fragment f) { fragmentmanager manager = getsupportfragmentmanager(); fragmenttransaction transaction = manager.begintransaction(); transaction.settransition(fragmenttransaction.transit_fragment_close); transaction.replace(r.id.fragment_container, f); transaction.commit(); } so when checked on android studio, everytime replace fragment above method, memory usage increases . fragmenttransaction.remove not free fragments , replace not free too. after while if click every menu item , open fragments on again , again, memory usage increases lot. so question how can free old-replaced fragments? want 1 in memory. or can say; want destroy them until activity dies, references fragments exist in memory. rega...

php - How can I match characters in a string and place a dot next to each character using regex -

please see code below. this returns john doe l. r t i want return john doe l. r. t. $string = "john doe l r t"; $matches = null; preg_match('/\b\s[a-za-z]{1}\b/i', $string, $matches); foreach ($matches $match) { $string = str_replace($match, $match.'.',$string); } echo $string; you can use preg_replace that preg_replace('/\b\s[a-za-z]{1}\b/i', '$0.', $string); the result john doe l. r. t. and you'll want replace uppercase-letters (since names), should not use i flag. preg_replace('/\b\s[a-z]{1}\b/', '$0.', $string);

linux - Install Java 1.7 OpenJDK in another directory -

i need install java 1.7 openjdk in /opt/java1.7 directory. when run whereis java still shows it's installed in /usr/bin/java , need /opt/java1.7/ . let system's package manager ( yum , apt-get ; assuming running linux distro) install wherever defaults to. then create symlink with: sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64 /opt/java1.7 (using paths indicated in comment question).

javascript - Tray Menu Slides Down After Content -

i've been looking @ menu, having weird issue can't seem figure out--and feeling kind of stupid over! want slide down tray menu on existing content. however, slides down underneath content. can't seem figure out why happening. help? https://jsfiddle.net/ticklishoctopus/gdfv4wzn/ $(window).on('resize', function() { $('ul.sub-menu').each(function() { var width = 0; $(this).children('li').each(function() { width += $(this).width(); console.log('inner width' + $(this).width()); }); console.log('total width' + width); $(this).css('padding-left', $(window).width() / 2 - width / 2); }); }); $(window).trigger('resize'); @import url(https://fonts.googleapis.com/css?family=cabin); html, body { margin: 0; padding: 0; font-family: cabin, sans-serif; text-transform: uppercase; backgrou...

javascript - what improvements do i need to make to my form submission (for email) to stop the spam i am receiving and make my form more secure? -

every morning @ 10:53am hit 1-2 blank emails sort of entity using send.php file. i know result of php send file on website, dont have knowledge of php. spent lot of time several weeks ago looking clear cut information telling me how setup input form php send , got far. know there absolutely glaringly obvious security holes in code. i know doing wrong on form lock down dont hit spam anymore. i have javascript honeypot, input field if hidden field gets selected changes value true false , form no longer submit form instead give user alert saying have submitted form, , page reloads (probably not great of solution). i went ahead , replaced email some@email.com <?php $sname = $_post['name']; $slastname = $_post['last-name']; $semail = $_post['email']; $semailconfirm = $_post['confirm-email']; $sphone = $_post['phone-number']; $smessage = filter_var($_post['message'], filter_sanitize_string ); $formerrors = fals...

swing - How to draw timelines in a tree table -

Image
i writing analyzer visually see application spending time. interface trying achieve (see below) similar tree table lines or boxes denote response time. be collapsible tree graph the ability display metrics in table columns (e.g., start time, cost, etc) the ability display labels or description , metrics on left , lines on right i create following diagram (see below) in r -- unfortunately, although graph production automated, approach not interactive. wondering if suggest better way -- maybe tree table. looked @ many swing, javafx tree table examples. have not seen example has lines (time lines) in tree table. any suggestions appreciated. in advance. you can show node in treetablecell using grahic property in javafx. includes rectangle s. this simple example of showing bars in column using rectangles : // arrays in treeitems contain {startvalue, endvalue} (both positive) treeitem<int[]> root = new treeitem<>(new int[]{0, 10}); root.getchildren...

java - At what point can I trust that data has been saved to mysql? -

after create new object 'order', generated id , put on amqp queue, worker can other stuff it. worker takes generated id (message) , looks order complains no record exists, though created one. trying figure out either how long wait after call .persist() before put message (generated id) on queue (which dont think idea); have worker loop on , on until mysql return record (which dont either); or find point can put message on queue after know data safe in mysql (this sounds best). im thinking needs done outside of @transactional method. the worker going read data out of mysql part of different system on different server. when can tell worker data in mysql can started task? is true after @transactional method finishes data done being written mysql, having trouble understanding this. million in advanced. is true after @transactional method finishes data done being written mysql, having trouble understanding this. million in advanced. so first, kayamann , ra...

angularjs - ng-file-drop does not work with 7zip -

when drag file within 7zip drag , drop area, filename appears if successful upload fails upload on submit. prevent having filename appear if it's 7zip or similar. when use demo on https://angular-file-upload.appspot.com/ works expect to. i'm running version 3.2.5 how can prevent filename appearing if it's coming 7zip? <div data-ng-file-drop class="document-drop-area" data-ng-model="additionaldocumentfiles" data-ng-multiple="true" drag-over-class="{accept:'document-drop-accept', reject:'document-drop-reject', delay:100}"> drag/drop files here </div>

python - Peewee: change "Id" field with another name -

is there way on peewee model change default primary key named "id" name? a couple ways... auto-incrementing integer field named "pk": class mymodel(model): pk = primarykeyfield() other_field = textfield() varchar primary key: class mymodel(model): data = charfield(primary_key=true) multi-column primary key: class mymodel(model): key = charfield() value = charfield() class meta: primary_key = compositekey('key', 'value')

How to unserialize PHP Serialized array/variable/class and return suitable object in C# -

the goal unserialize php serialized string , sutable object in c# is there way make possible in c#(.net)? to more specific: need make application comunicates (via http) specific website returns needed information. fortunately/unfortunately dont have permission website data ( array mostly) returned website php serialized . found solution: sharp serialization library

c# - Left join Lists with Linq and detect multiple matches -

my goal compare lists , update values on list values list b. along that, want work left join , keep values list if didn't updated , detect multiple matches. what have tried far below. the setup public class person { public string firstname { get; set; } public string lastname { get; set; } public string updateme { get; set; } public static list<person> createlist() { return new list<person> { new person { lastname = "barton", firstname = "clint" }, new person { lastname = "stark", firstname = "tony" }, new person { lastname = "parker", firstname = "peter" } }; } public static list<person> createlisttwo() { return new list<person> { new person { lastname = "barton", firstname = "clint", updateme = "updated"}, new person { last...

vectorization - Applying vectorized subsetting across multiple columns in R -

i try find straight-forward way vectorize/generalize subsetting of data.frame. let's assume have data.frame: df <- data.frame(a = 1:5, b = 10 * 1:5, c = 100 * 1:5) every column has own condition , goal subset df rows remain condition met @ least 1 column. want find vectorized subset mechanism generalizes df <- subset(df, df[,1]<2 | df[,2]< 30 | df[,3]<100) so formulate this crit <- c(2,30,100) df <- subset(df, df$header < crit[1:3]) and down road want to. df <- subset(df, df$header < crit[1:n]) i know multi-step loop workaround, there must way. grateful help. given: x <- c(1:5) y <- c(10,20,30,40,50) z <- c(100,200,300,400,500) # df base function mydf <- data.frame(a = x, b = y, c = z) crit <- c(2,30,100) then let see values in column less crit value: > sweep(mydf, 2, crit, "<") b c [1,] true true false [2,] false true false [3,] false false false [4,] false false f...

Perl programatically modify POD at runtime -

i've written convenience library scripts i'm working on. wraps getopt::long little simpler, in addition providing mandatory arguments. such, library adds number of arguments script's list of required/possible command line arguments. since script calls pod2usage on --help flag, i'd way library provide definitions of each of these flags provides individual script, can rendered when pod2usage called. for instance, --dosomething flag added library, there anyway, when run a.pl --help , include both definitions provided a.pl , definitions provided library, of --dosomething a.pl may not know about? is there way accomplish this—to have library modify script's pod @ runtime? unfortunately pod2usage static purpose. might @ app::cmd or getopt::long::descriptive (used app::cmd) functionality closer this. that said don't need use pod2usage print usage statements, helpful way dump scripts own pod.

olap - Specify a particular foreign key field as a link between two tables in the SSAS data source -

i quite new sql server analysis services , try build first cube (the first except adventure works tutorial) the problem how specify particular field in table serve link table, when several options (several keys pointing same second table) present. in data source have department table: (irrelevant fields omitted) | department_key (pk) | ... and discipline table this: | discipline_key (pk) | title | department_for_key (fk) | department_of_key (fk) | ... both foreign keys in discipline table point department table , both constraints specified in db. still meaning quite different. when constructing discipline dimension in sql server data tools specify of foreign keys should used link between levels of particular hierarchy in dimension (or in whole dimension), haven't found way explicitly . interestingly, happens ssdt (or ssas) uses column want ( department_of_key ) relate levels. nevertheless, use second key in separate dimension (or in new hierarchy in same dimen...

html - Button with icon labelled with aria-label still an 'Empty Button' error -

a button aria-label : <button type="button" class="btn btn-default dropdown-toggle" aria-expanded="false" aria-label="sort"> <i class="fa fa-arrows"></i> </button> is still identified accessibility error ('empty button') wave . ideas? older screenreaders/browsers dont make use of aria. using visually-hidden text more robust method, in link cbroe left in comment above.

excel - How can I grade a quiz in Google Spreadsheets? -

let's have data in spreadsheet so: correct bob alice true true false true true true false false false true false false xxx yyy as can see bob got 3 questions correct, file alice got 2. formala can put in locations xxx , yyy have spreadsheet compute me? assuming example begins in cell a1, put in cell b6 replace xxx: =arrayformula(sum(if(b2:b5=$a2:$a5,1,0)))

r - Random function not working when used with vectors -

i using r. have made random function (using monte carlo integration) approximates arctan function (equal integral of 1/(1+x^2)). seems work , gives accurate approximations. example 3*arctan(sqrt(3)) should give pi, , below close approximation. > f=function(x) + {y=runif(10^6,0,x); return(x*mean((1/(1+y^2))))} > f(sqrt(3))*3 [1] 3.140515 however, when use function on sequence of numbers, answers seem come out wrong. below correct values given atan function, f function gives wrong values when used on same vector. > atan(c(1,1.5,2)) [1] 0.7853982 0.9827937 1.1071487 > f(c(1,1.5,2)) [1] 0.6648275 0.9972412 1.3296550 > f(1) [1] 0.7852855 > f(1.5) [1] 0.9828134 > f(2) [1] 1.107888 notice how when use f on 1, 1.5 , 2 individually, works, not in vector form? what's going on here? have tried running f few times on vector , wrong values pretty consistent 2 decimal places. using mean() inside function interferes vectorization. can wrap function in ve...

How to implement random sampling of a set of vectors in java? -

i have huge number of context vectors , want find average cosine similarity of them. however, it's not efficient calculate through whole set. that's why, want take random sample set. the problem each context vector explains degree of meaning word want make balanced selection(according vector values). searched , found can use monte carlo method. found gibbs sampler example here: https://darrenjw.wordpress.com/2011/07/16/gibbs-sampler-in-various-languages-revisited/ however, confused little bit. understand, method provides normal distribution , generates double numbers. did not understand how implement method in case. explain me how can solve problem? thanks in advance. you don't want random sample, want representative sample. 1 relatively efficient way sort elements in "strength" order, take every nth element, give representative sample of size/n elements. try this: // given set<vector> myset; int reductionfactor = 200; // eg sample 0...

css - Flexbox children don't always expand as wide as they could/should -

two of link buttons in nav have long-ish names, , they're text-wrapping , becoming 2 lines tall though (as far can tell) there's nothing stopping them or nav growing wider. have missed something? the code quite long, you'll happier viewing codepen reading here. it's long because i'm afraid i've overlooked in global styling or media query changes blame bug. edit: 1 easy answer. misunderstood selector precedence. thought media queries took precedence on (except inline). didn't realize nav a rule in media query not overwriting nav > section > a in base css. lesson respecting css selector precedence. html <section> <nav> <a id="nsfw_deactivatefilter" onclick="worksafeoff()" href="#">worksafe mode: on</a> <h2 onclick="showmenu()">category filters</h2> <div></div> <section id="nav_orientation"> ...

sql - Difference between selecting multiple tables with JOIN and plain select -

Image
how sql server execute these 2 queries, there difference: select join select * aspnetusers left join aspnetuserroles on aspnetusers.id = aspnetuserroles.userid left join aspnetroles on aspnetuserroles.roleid = aspnetroles.id select without join select * aspnetuserroles, aspnetusers, aspnetroles aspnetusers.id = aspnetuserroles.userid , aspnetuserroles.roleid = aspnetroles.id the results same, except order of columns. you have use sql server "actual execution plan" (press down actual execution plan button in sql server management studio) find difference of how sql server execute them. if "inner join" vs "without join" sql server smart enough make them identical. but "left join" vs "without join" has different results , has different execution plan check attached photo :

javascript - Where to set cookie in Isomorphic Redux Application? -

i have 3 general questions redux , isomorphic application: what best way share 'runtime' data between client , server? instance, when user logged in distant api, store session object in cookies. in way, next time client requests front-end, front-end server can read cookies , initialize redux store it's previous session. downside of client has validate/invalidate session on boot (eg in componentdidmount of root component). should request session server side rather read cookies? where should execute operation of cookie storing, in action creators or in reducers? should store cookie in reducer handle user session? where should execute operation of redirect user (via react-router)? mean when user logged in, should dispatch redirect action (from loginactioncreator once login promise resolved?, somewhere else? ) thanks in advance. i managed neat app structure. here's found each questions: i share between client , front-end server api server token ...

perl - DBIx::Class Perimeter Search -

i trying perimeter search working dbix::class have not succeeded far. the sql generate looks this: select zip, 6371 * acos( cos(radians(lat)) * cos(radians(userlat)) * cos(radians(userlng) - radians(lng)) + sin(radians(lat)) * sin(radians(userlat)) ) distance geopc 6371 * acos( cos(radians(lat)) * cos(radians(userlat)) * cos(radians(userlng) - radians(lng)) + sin(radians(lat)) * sin(radians(userlat)) ) <= distance order distance where userlat, userlng, , distance should variables, come in thru webrequest. my dbix::class result: use utf8; package myapp::models::schema::result::geopc; use strict; use warnings; use base 'dbix::class::core'; __package__->table("geopc"); __package__->add_columns( "id", { data_type => "bigint", is_nullable => 0, is_auto_increment => 1 }, "country", { data_type => "varchar", is_nullable => 0, size => 2 }, "language...

sql - Join when exact match other other wise join with default value -

i have 2 table , b table a id b c table b id value 1 b 2 default 0 so want join 2 tables on id when matching, otherwise use default value desired results id value 1 b 2 c 0 use left outer join purpose like select t1.id, coalesce(t2.value, 0) value tablea t1 left join tableb t2 on t1.id = t2.id;

sql - Can you run an UPDATE and WITH together? -

i trying run update on table, error error: syntax error @ or near "update" the query is: with first_users ( select min(created_at) first_at, company_id company_id users group company_id ) update companies set first_seen_at = least(first_seen_at, (select first_at first_users id = first_users.company_id) ); can not run updates , withs together? seems weird. my query more complex, why using syntax. when run select * first_users instead of update, works, there's wrong update keyword or something. i suggest changing update . . . from in case. there no reason update records not match. so: update companies set first_seen_at = u.first_at (select company_id, min(created_at) first_at users group company_id ) u companies.id = u.company_id , u.first_seen_at < companies.first_seen_at; postgres started supporting ctes updates in version 9.1 ( http://www.postgresql.org/docs/9.1/stat...

sdl - When coding a game, what am I supposed to use as units? -

i've been using pixels units aspects of game such movement, i've been told bad practice. however, i've never seen explanation on i'm supposed instead. can provide explanation on how handle units in games? it doesn't matter units use; can arbitrary. thing need make sure not fixed screen pixels , because later find out want change scale of things displayed. it's ok if conversion factor happens 1; make sure conversion exists , can change if have reason later. (and, practical matter, don't make conversion 1 because hides bugs if forgot convert in 1 place.) for 3d realistic games, common unit "1 meter". real world units don't matter, idea use unit similar size of objects in world. for tile-based or voxel-based games, common unit width of 1 tile. allows omit conversions, you're less have problem tying tiles pixels because tiles affect game rules anyway.

jquery - onclick with javascript and animate.css -

i don't why won't work. i did animation on div class header (fadeindownbig); want when click on link (a href) header fadeoutupbig. <script> $(function(){ $("a").click(function(){ $("#header1").addclass('animated fadeoutupbig'); }); }); </script> .header{ margin-left:10px; height:350px; background:url(../img/background_header2.jpg); background-repeat:no-repeat; } <div class="header animated fadeindownbig" id="header1" > <div class="menu"> <a class="wow animated fadein hvr-grow-shadow transition" data-wow-delay="0.5s" href="../index.html" >home </a> what doing wrong ? (does not include animate.css) like comment above mentioned clicking on anchor redirect before animations can take place. javascript can make not default action @ on cl...

php - SQL Server Update & Replace Spam in "text" and "ntext" fields -

first , foremost, thank time taking @ issue. an old database table has on 14k spam links injected it, many of in text , ntext fields. have written sql query runs , updates fields not "text" or "ntext" type, unfortunately not update "text" or "ntext" fields @ all. brief information database: running on iis7, sql server 2008, , php enabled (version 5.3). unfortunately have limited capability update database directly or control panel (otherwise have been handled swiftly) writing script in php automatically update compromised tables. script in form runs without error, not have updates in text or ntext fields. the script follows: //basic db connection $conn = database_info; $sql = "select * pages_test_only"; $result = sqlsrv_query($conn, $sql); //loop scrub each table foreach(sqlsrv_field_metadata($result) $fieldmetadata) { //the loop here updates each section of spam (starting </title>) "" (empty/null)...

python - Why does sys.path have "c:\\windows\\system\python34.zip"? -

when imported sys, >>> import sys >>> sys.path ['', 'c:\\program files\\python 3.5\\lib\\site-packages\\pyinstaller-3.0-py3.5.egg', **'c:\\program files\\python 3.5\\python35.zip'**, 'c:\\program files\\python 3.5\\dlls', 'c:\\program files\\python 3.5\\lib', 'c:\\program files\\python 3.5', 'c:\\program files\\python 3.5\\lib\\site-packages', 'c:\\program files\\python 3.5\\lib\\site-packages\\win32', 'c:\\program files\\python 3.5\\lib\\site-packages\\win32\\lib', 'c:\\program files\\python 3.5\\lib\\site-packages\\pythonwin']` i checked whether there file python34.zip in directory, answer no. why showing?

html - how to change styling on the same line within a <div> -

i have part of web page (incorporating bootstrap css) contains <div> id "drop-zone" pick later in javascript implement drag-and-drop functionality: <div id="drop_zone"> <p style="color: darkgray">drop</p> <p style="color: black">test.txt</p> <p style="color: darkgray"> here</p> </div> i have <p> s in there because want vary styling across single line, if use code above, or if swap <p> s <div> s, code renders on multiple lines so: drop test.txt here when want like: drop test.txt here i'm sure easy fix, thoughts here? use <span> instead of <p> .

c++ - Floating Point, how much can I trust less than / greater than comparisons? -

let's have 2 floating point numbers, , want compare them. if 1 greater other, program should take 1 fork. if opposite true, should take path. , should same thing, if value being compared nudged in direction should still make compare true. it's difficult question phrase, wrote demonstrate - float = random(); float b = random(); // returns number (no infinity or nans) if(a < b){ if( !(a < b + float_episilon) ) launchthemissiles(); buildhospitals(); }else if(a >= b){ if( !(a >= b - float_episilon) ) launchthemissiles(); buildorphanages(); }else{ launchthemissiles(); // should never called, in branch } given code, launchthemissiles() guaranteed never called? if can guarantee a , b not nans or infinities, can do: if (a<b) { … } else { … } the set of floating point values except infinities , nans comprise total ordering (with glitch 2 representations of zero, shouldn't matter you), not unlike working normal...

c# - Format datetime from string "20151210T11:25:11123" -

i have string format "20151210t11:25:11123" , can't convert type datetime in c# me? string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "dd/mm/yyyy hh:mm tt", cultureinfo.invariantculture); you using time of 20151210t11:25:11123 telling parse if formatted dd/mm/yyyy hh:mm tt . format not match string, formatexception. need provide format matches string have. isn't clear me last 5 digits format yyyymmddthh:mm:ssfff parse string 12/10/2015 11:25:11 am . may need adjust last part of format match whatever encoded there in string. string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "yyyymmddthh:mm:ssfff", cultureinfo.invariantculture) console.writeline(datea); // 12/10/2015 11:25:11

java - How to implement a ClickListener for a button from a custom layout to use in a FragmentDialog -

i'm try set action imagebutton. when dialgofragment called , shown on screen, want preess button , action. when put action inside onclick in code below didn't work. i'm sure that's not right way of doing it. i'm using class fragment: public class generaldialogfragment extends dialogfragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout use dialog or embedded fragment view v = inflater.inflate(r.layout.activity_dialog, container, false); imagebutton mimagebutton = (imagebutton) v.findviewbyid(r.id.image_button); mimagebutton.setonclicklistener(new view.onclicklistener(){ @override public void onclick(view v) { string name = ""; sharedpreferences prefs = getactivity().getsharedpreferences("my_prefs_name", context.mode_private); ...

css - Single Stylesheet Multiple Pages Dreamweaver CS6 -

i have 2 pages share same stylesheet. how make changes one, without affecting other? new coding, please specific possible. for instance: have main image on home page , want delete on practice areas page whenever deletes on pages. help please, , thank in advance! a practice styling pages differently have class name applied body or enclosing div corresponds page, e.g.: <body class="home"> <div>content here</div> </body> this gives greater specificity, in css, writing: .home div { background-image: url('your-image.jpg') no-repeat left top; } ... or such. but, sounds image on home page content , rather presentation. in case should including in html rather css. <body class="home"> <div><img src="your-image.jpg"> content here</div> </body> does help?

Python Pandas returns different output for the same code -

i have 10,000 row csv data file, read , wish manipulate data. want loop through, , compute results in matrix form, involves taking specific columns , doing computations. everytime run same program, different results. doing wrong here? there exceptions need know? use python 3.5. also,suggest if there's better way of doing this, i'm new analyzing data pandas. # import important stuff import numpy np # imports fast numerical programming library import scipy sp #imports stats functions, amongst other things import matplotlib mpl # imports matplotlib import matplotlib.cm cm #allows easy access colormaps import matplotlib.pyplot plt #sets plotting under plt import pandas pd #lets handle data dataframes #sets pandas table display pd.set_option('display.width', 500) pd.set_option('display.max_columns', 100) pd.set_option('display.notebook_repr_html', true) import seaborn sb #sets styles , gives more plotting options %matplotlib inline # read da...

javascript - Redirect all pages except a few specific ones -

i need use javascript on this, , place in header site pages. //.mysite.com - redirect pages within domain //.mysite.com/home except these 3 page examples, don't want these redirected. www.mysite.com/page2 www.mysite.com/article/sat www.mysite.com/home/message any ideas? i've never had request this. if (['/page2', 'article/sat', 'home/message', '/home'].indexof(window.location.pathname) < 0) window.location = 'www.mysite.com/home' no need jquery

javascript - jQuery set focus on selected item of a select list -

i have select list size="10" - shows 10 of 100 options available. when page loads, 1st 10 options displayed, if option value 50 selected . i have read adding focus selected item of select list work when page loads option 50 displayed in select list, instead of 1st 10 options. however, after reading many threads , searching google, unable work out how set focus selected item. i wanting set both selected , focus applied item of select list. here have tried , not work: $('#id_preview_style_select option:selected').prop('selected', true); //set selected value. $('#id_preview_style_select option:selected').prop('focus', true); //does not work. $('#id_preview_style_select option:selected').focus(); //does not work this seeking achieve: <select id="id_preview_style_select" size="10" autofocus> <option value="0">style 0</option> <option value="1">s...

How to write "decToBin" in Swift? -

i have been looking equivalent javascripts dectobin in swift 2. have not been able find anything. replicate following javascript code code: var max = 511; var maxlength = dectobin(max).tostring().length; you can use string achieve this: let max = 511 let maxlength = string(max, radix: 2).characters.count you can find more in apple string documentation

drag and drop - Adding new axis to Parallel Coordinates visualization in d3.js -

Image
i have hosted parallel coordinates code here: http://bl.ocks.org/aditeyapandey/d416c90c99e19f7c9209 upon clicking paragraph element can add new axis visualization. however, new axis not interacting other axes.so if drag newly added "shipping" axis on other axes not throw problem. but, if drop other axes "shipping" interaction not work. attaching screenshots reference. fig1 before adding axis: fig2 new axis "shipping" fig3 error when dragging axis on shipping ps. sorry bad code, work in progress , gist has blocked me, considers me robot. so, not able modify it. lot. i found solution. apparently drag behaviour still being called earlier code. therefore have override previous drag behaviour , add new 1 data fields , axes. updated code reference : http://bl.ocks.org/aditeyapandey/d416c90c99e19f7c9209

javascript - Styling 2 different classes of jQuery UI selectmenus -

i'd have 2 different styles (classes) select menus on site. don't want use ids since there can numerous drop downs on same page. so example: <div class="row"> <select class="style1"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> <select class="style1"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> <select class="style2"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> </div> however, when create selectmenus javascript call: $("select").selectmenu(); it doesn't transfer class name selectmenu creates (it creates id based on original 1 plus "-button"). is there...

ruby on rails - ActiveRecord Eager Load model that isn't belongs_to -

i'm running issue n+1 queries , want eager load relationship, except i'm having trouble defining relationship. it's complicated, haha, hear me out. i have 2 models. class pokemon < activerecord::base belongs_to :pokemon_detail, primary_key: "level", foreign_key: "level" end class pokemondetail < activerecord::base has_one :pokemons, primary_ley: "level", foreign_key: "level" end let's say, have following record: <pokemon id: 1, name: "squirtle", level: 1> which correspond following pokemondetail <pokemondetail id: 1, name: "squirtle", level: 1, health: 150> and can eager loaded pokemon.all.includes(:pokemon_detail) , however, want eager load information 1 level higher. <pokemondetail id: 2, name: "squirtle", level: 2, health: 300> i find information 1 level higher following method within pokemon model. def next_level_info pokemondetail.where(leve...

arrays - filling matrix with user's input in C# -

i wanna fill matrix in c# user's inputs,but have trouble it.when enter rows , cols equal each other,it work; when enter rows , cols different each other program stop . code is int row = 0; int col = 0; int[,] matrix1; row = convert.toint16(console.readline()); col = convert.toint16(console.readline()); matrix1=new int[row,col]; console.writeline("enter numbers"); (int = 0; < row; i++) { (int j = 0; j < col; j++) { matrix1[i, j] = convert.toint16(console.readline());// have problem line,... plz show me correct form } } you allocate memory before input array size. correct code: int row = 0; int col = 0; int[ , ] matrix1; row = convert.toint16( console.readline( ) ); col = convert.toint16( console.readline( ) ); matrix1 = new int[ row, col ]; console.writeline( "enter numbers" ); ( int = 0; < col; i++ ) {...

javascript - how to work with Tagged URL [VBA] -

i new in field. my problem url when visited gives me nice webpage in web browser when try extract information using winhttp[vba] or internet explorer method, fails. my url https://search.rpxcorp.com/lit/txedce-165478?utm_campaign=rpxs_daily_lit_alert&utm_medium=email&utm_source=rpxsearch similarly when try download pdf same, link in website https://search.rpxcorp.com/litigation_documents/11809340 when use adodb.stream download pdf url fails. when visited pdf url in browser directs link: https://rpx-docs.s3.amazonaws.com/lits/043/90811/txedce-165478.pdf?signature=iw62rbsiciyar7gnyjianyunjdo%3d&expires=1452925167&awsaccesskeyid=akiai2uwkalieybvokda my problem is, how work type of websites html work with. edit think contains javascript, impossible solve problem without use of java script.

Overriding start_requests is Scrapy not synchronous -

i'm trying override scrapy's start_requests method, unsuccessful. i'm fine iterate through pages. problem have iterate firstly through cities , pages. my code looks this: url = "https://example.com/%s/?page=%d" starting_number = 1 number_of_pages = 3 cities = [] # there array of cities selected_city = "..." def start_requests(self): city in cities: selected_city = city print "####################" print "##### city: " + selected_city + " #####" in range(self.page_number, number_of_pages, +1): print "##### page: " + str(i) + " #####" yield scrapy.request(url=(url % (selected_city, i)), callback = self.parse) print "####################" in console see when crawler starts working prints cities , pages, , start requests. therefore result crawler parses first city. work asynchronously, while need synchronous. what r...

serialization - Django Rest Framework Serializer format -

i have 2 serializers: 1 restaurant model, mainmenu model: class restaurantserializer(serializers.modelserializer): class meta: model = restaurant class mainmenuserializer(serializers.modelserializer): restaurant = restaurantserializer() main_menu_items = serializers.stringrelatedfield(many=true) class meta: model = menumain fields = ('id', 'restaurant', 'main_menu_items') the current output of mainmenuserializer is [ { "id": 1, "restaurant": { "id": 1, "name": "restaurant a", "location": "street b" }, "main_menu_items": [ "fried rice" ] }, { "id": 2, "restaurant": { "id": 1, "name": "restaurant a", "location":...

go - Is it possible to recover from a panic inside a panic? -

it looks it's not possible recover panic inside panic? func testerror(t *testing.t) { e := &myerr{p: false} fmt.println(e.error()) // prints "returned" panic(e) // prints "panic: returned" e1 := &myerr{p: true} fmt.println(e1.error()) // prints "recovered" panic(e1) // prints "panic: panic: paniced // fatal error: panic holding locks // panic during panic" } type myerr struct { p bool } func (m *myerr) error() (out string) { defer func() { if r := recover(); r != nil { out = "recovered" } }() if m.p { panic("paniced") } return "returned" } backstory: error error() function uses os.getwd, seems panic when inside panic, i'd handle gracefully. i think solves problem replace this panic(e1)...

java - Implementing class embedded in an interface -

assume have interface class embedded in (the purpose being interface must provide 'type'. interface has methods using 'type'. so, in file s.java, have public interface s { public class stype { } public abstract void f( stype ); } i want implement interface, , try this, in file ss.java: public final class ss implements s { public class stype extends java.util.hashset<integer> { } public void f( stype ) { // ... } } however, when try compile these files ("javac s.java ss.java"), usual error message "ss not abstract , not override abstract method f(stype) in s" indicating "f()" in concrete class not proper implementation of "f()" in interface. why? try with: public final class ss implements s{ public class stype extends java.util.hashset<integer> { } public void f(s.stype a) { // .. } } edit: perhaps, need this:...

xml - xslt function to separate a string with delimiter -

i have string. want xslt function can separate every 2 characters of string delimiter '|'. e.g.: input abadferewq output ab|ad|fe|re|wq. if you're using xslt 2.0, can use replace() ... xml input <root> <string>abadferewq</string> </root> xslt 2.0 ( working example ) <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="string"> <xsl:copy> <!-- inner replace() adds '|' after every 2 characters. outer replace() strips off trailing '|'. --> <xsl:value-of select="replace( ...