Posts

Showing posts from January, 2012

Python reading url that requires logging in -

i use player_id = re.compile('<td><a href="(.+?)" onclick=') url = 'http://www.csfbl.com/freeagents.asp?leagueid=2237' sock = urllib.request.urlopen(url).read().decode("utf-8") or import pandas pd pd.read_html(url) the website in question displays 2 different values based on whether logged in or not. how can values if logged in? http://www.csfbl.com is website. thanks in advance! use requests module submit credentials on web-form at: http://www.csfbl.com/logon.asp . instructions submitting web forms using requests can found here: http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests other sites can more challenging. those, consider using selenium or mechanize .

vb.net - How do I update the textbox when it is change? -

i doing update use select statement grab database. display perspective textbox. did not update newly provided date use original date. can please help? need use textchanged or there other method? protected sub page_load(byval sender object, byval e system.eventargs) handles me.load dim sqlstr string = "select * card cardid='" & request.querystring("id") & "'" dim carddt datatable = dbadapter.getdatatable(sqlstr) dim count = 0 textbox1.text = carddt.rows.item(count).item("date") end sub protected sub button1_click(byval sender object, byval e eventargs) handles button1.click dim sqlstr2 string = "update card set date='" & textbox1.text & "' card_code=" & mm_recordid dim updatedt datatable = dbadapter.getdatatable(sqlstr2) end sub i use ispostback @ page load. if not ispostback code read data database end if

javascript - Pass function call as attribute in Polymer? -

my polymer element has array attribute anywhere 1-10,000 items, need generate when element instantiated. however, really pass in array using function call or reference: <script> function genarray(size){ var = []; for(var = 0, count = size - 1; < count; i++){ a.push("domain" + count + ".tld"); } return a; } </script> <my-element domains="genarray()"></my-element> or reference global object. <script> function genarray(size){ var = []; for(var = 0, count = size - 1; < count; i++){ a.push("domain" + count + ".tld"); } return a; } window.myarray = genarray(1000); </script> <my-element domains="window.myarray"></my-element> i've tried variations on quote style ( "" vs '' ) brackets ( "{{genarray}}" ) , '{"array":window.myarray}' . i understand pass in parame...

Showing Silverlight unit tests in VS2013 Test Explorer -

i have silverlight client project project.client employing strong use of mvvm caliburn micro, there's lots of calculations in viewmodels see fit unit test. i create project.client.test unit test project references project.client , have test results appear in test explorer (and not test results showing in web page) . i installed nunit 3 runners , adapters cannot see unit tests in visual studio 2013's test explorer. there way that?

Google analytics. Different platforms of same app. Same tracking code or different? -

i have same app in different platforms (myapp android , myapp ios). google suggests using different properties in case. here link google's suggestion. but go against google's recommendation , use same tracking property. using same tracking property, can view data multiple platforms in 1 place. if want view data 1 platform, can create multiple views , view separated data well. as going against google's recommended approach, worried little. did before? there problems face using setup. can give more information on why google recommends approach? this not cause issues url's different in platforms, yes easier manage data when separated in different properties. not requirement, requires lot more effort create views filter out data not want in there. with events/other data, make sure able keep them apart filtering. if can't filter them out, wrong setup! but in regard need follow google's advice keep 1 master view data unfiltered if wrong, not l...

Linking to Prefs in React Native iOS app -

i send user preferences/settings when button clicked. however, when try following, nothing happens: linkingios.openurl('prefs:root=general') i verified onpress working when following, redirected google linkingios.openurl(' http://google.com ') i spent way time trying figure out , found out url scheme has been redacted in late versions of ios... :( however can redirect own apps settings 'app-settings:'

c++ - How to vectorize loop operating on 3 channel OpenCV Mat? -

i'm trying improve performance in code operating on 3 channel opencv matrix. loop looks this: unsigned char *input = (unsigned char*)(img_input.data); // 3 channel rgb unsigned char *output = (unsigned char*)(img_output.data); // 1 channel for(int j = 0;j < img_input.rows;j++){ for(int = 0;i < img_input.cols;i++){ unsigned char b = input[numcols * j + 3 * ] ; unsigned char g = input[numcols * j + 3 * + 1]; unsigned char r = input[numcols * j + 3 * + 2]; output[numcols * j + i] = // operations r g , b here } } now gcc can't vectorise this complicated access pattern which isn't surprising. vectorises ok if have 2 channel, seems gcc looks multiples of 2 in loop index increment when vectorising. question: there way vectorise loop isn't separating input matrix 3 separate matrices ? thanks.

scala - akka Actor unit testing using testkit -

there many examples of using akka-testkit when actor being tested responding ask: //below code copied example link val actorref = testactorref(new myactor) // hypothetical message stimulating '42' answer val future = actorref ? say42 val success(result: int) = future.value.get result must be(42) but have actor not respond sender; instead sends message separate actor. simplified example being: class passthroughactor(sink : actorref) { def receive : receive = { case _ => sink ! 42 } } testkit has suite of expectmsg methods cannot find examples of creating test sink actor expect message within unit test. is possible test passthroughactor ? thank in advance consideration , response. as mentioned in comments can use testprobe solve this: val sink = testprobe() val actorref = testactorref(props(new passthroughactor(sink.ref))) actorref ! "message" sink.expectmsg(42)

Python pandas, how can I pass a colon ":" to an indexer through a variable -

i working through method working data slices large multi-index pandas dataframe. can generate masks use each indexer (essentially lists of values define slice): df.loc[idx[a_mask,b_mask],idx[c_mask,d_mask]] this fine in scenarios i'd select along of axes, equivalent to: df.loc[idx[a_mask,b_mask],idx[:,d_mask]] is there way me pass colon ":" replaces c_mask in second example in variable? ideally i'd set c_mask value ":", of course doesn't work (and shouldn't because if had column named that...). there way pass in value variable communicates "whole axis" along 1 of indexers? i realize generate mask select gathering values along appropriate axis, nontrivial , adds lot of code. likewise break dataframe access 5 scenarios (one each having : in , 1 4 masks) doesn't seem honor dry principle , still brittle because can't handle multiple direction whole slice selection. so, can pass in through variable select entire direction...

Define a Python class which can optionally use __slots__ according to a runtime variable -

a python module use has updated , classes use __slots__ , break functionality i've relied upon. there few solutions this: copy code own repo __slots__ hacked out. easiest, i'd prefer not to. remove __slots__ monkey patching. wrote gloriously hacky function searches classes in module, , __slots__ replaced cloned class __dict__ added , member descriptors , slots removed. solution 2 works, feels hack. i'd prefer build way allows module optionally turn use of __slots__ on or off , , issue pull request author. turns out pretty tricky. my first attempt: module.py: use_slots = true class someclass(object): if use_slots: __slots__ = () if can ensure use_slots set false before module.py imported anywhere (and therefore elaborated) works, delicate , breaks unexpectedly. a factory class ideal, return different classes based on use_slots library peppered if obj.__class__ == someclass rather isinstance(obj, someclass) won't work. i'v...

android - Running sample code: FATAL EXCEPTION: main...Unable to instantiate activity -

i'm trying run sample code provided andengine (the simplest sample code seen below, received here ). added andengine.jar file library received here . everything fine, unfortunately when want run sample, throws fatal exception: main unable instantiate activity error. registered activitiy on androidmanifest.xml file, still error. hints how resolve it? 06-02 15:44:48.699: e/androidruntime(19437): fatal exception: main 06-02 15:44:48.699: e/androidruntime(19437): process: com.example.t, pid: 19437 06-02 15:44:48.699: e/androidruntime(19437): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.t/com.example.t.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.example.t.mainactivity" on path: dexpathlist[[zip file "/data/app/com.example.t-1/base.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]] 06-02 15:44:48.699: e/androidruntime(19437): @ android.app.activitythread.performlaunchactivity(ac...

Serialization exception using C# -

i new c# , trying write information file. got program running when have car class in same .cs file, when remove class .cs file in project, runtime error of "serializationexception unhandled: objectmanager found invalid number of fixups. indicates problem in formatter". below code car class included. when move class own car.cs file error starts getting thrown. namespace consoleapplication2 { class program { [serializable()] public class car { public string make { get; set; } public string model { get; set; } public int year { get; set; } public car(string make, string model, int year) { make = make; model = model; year = year; } } /// <summary> /// deserializes list of cars , returns list user /// </summary> /// <returns>returns deserialized car list</returns> public list<car> readlist() { ...

Create and fill a list with duplicates of a data frame in R? -

i'm building naive bayes classifier in r, language not familiar with. i've got multiple csv files testing trained classifier, become data frames when read r. there 20 possible categories given document can classified into, , each test file contains many documents, need array of 20 copies of test file calculate probabilities 20 categories , choose best 1 each document in test file. so once i've read csv file r , have data frame, how create array or list 20 copies of data frame? df <- read.csv(text='a,b\n1,a\n2,b\n3,c\n'); df; ## b ## 1 1 ## 2 2 b ## 3 3 c rep(list(df),20); ## [[1]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## [[2]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## ... (snip) ... ## ## [[19]] ## b ## 1 1 ## 2 2 b ## 3 3 c ## ## [[20]] ## b ## 1 1 ## 2 2 b ## 3 3 c

Extracting lines from txt file with Python -

i'm downloading mtdna records off ncbi , trying extract lines them using python. lines i'm trying extract either start or contain keywords such 'haplotype' , 'nationality' or 'locality'. i've tried following code: import re infile = open('sequence.txt', 'r') #open in file 'infilename' read outfile = open('results.txt', 'a') #open out file 'outfilename' write line in infile: if re.findall("(.*)haplogroup(.*)", line): outfile.write(line) outfile.write(infile.readline()) infile.close() outfile.close() the output here contains first line containing 'haplogroup' , example not following line infile: /haplogroup="t2b20" i've tried following: keep_phrases = ["accession", "haplogroup"] line in infile: phrase in keep_phrases: if phrase in line: outfile.write(line) outfile.w...

grails - Spring Security Plugin Should Respond with 401 instead of 403 -

when web session expires, spring security responds 403 http status. ideally, respond 401. unauthorized , forbidden different. request secured resource should return 403 if there valid session, user doesn't have permissions said resource. if resource secured , there no authenticated session, spring security should return 401. my application needs specific distinguishing between these 2 error codes. my question is, how can customize behavior? reference argument on differences between 401 , 403, read this . here solution this: @configuration public class webctxconfig implements beanpostprocessor { @override public object postprocessbeforeinitialization(object bean, string beanname) throws beansexception { if (bean instanceof sessionmanagementfilter) { sessionmanagementfilter filter = (sessionmanagementfilter) bean; filter.setinvalidsessionstrategy(new invalidsessionstrategy() { @overr...

javascript - Disable event handler below a certain viewport width -

i'm trying disable script when window width less 700px. have looked @ advice on other posts nothing has work of yet. window.onresize = function () { if(window.innerwidth < 700) { $(window).bind('scroll', function() { if ($(window).scrolltop() > 100) { $('#projectinfo').hide(); } else { $('#projectinfo').show(); } }); } } the problem never unbind event handler once has been attached window. suggest not bind scroll event handler every time window.resize event triggers, because extremely costly event performance-wise. also, keep rebinding existing handler which, if works @ all, still horribly bad practice. what want decide on document.ready whether attach scroll handler or not. if resize use case relevant (web users don't ever resize browser window while viewing specific page, it's web frontend developers keep doing check responsivenes...

c++ - Calling const mutable lambdas -

to simplify testcase, suppose have following wrapper class: template <typename t> struct wrapper { decltype(auto) operator()() const { return m_t(); } decltype(auto) operator()() { return m_t(); } t m_t; }; template <typename t> auto make_wrapper(t t) { return wrapper<t>{t}; } and let’s wrapping following trivial functor returning references: struct foo { int& operator()() { return x; } const int& operator()() const { return x; } int x; }; in main function, trying wrap foo functor lambda closure. since want return non-const references, setting mutable , using decltype(auto) : int main() { foo foo; auto fun = [foo]() mutable -> decltype(auto) { return foo(); }; auto wfun = make_wrapper(fun); const auto& cwfun = wfun; wfun(); // <- ok cwfun(); // <- bad! } for second call, cwfun() , first const version of wrapper::operator() called, there m_t viewed const lambda, , can...

javascript - Replace forward slash with jQuery -

this string: hello/page/2/bye this have (please note "2" number, "page" "page": hello/bye how can str.replace() using jquery? this (without jquery): var str = 'hello/page/2/bye'; str = str.replace(/page\/\d+\//,''); the slashes need escaped (so become \/ ), \d+ number, 1 or more times (so matches e.g. page/12/ demo: http://jsfiddle.net/dd5aohbc/

javascript - MEAN.js Social Sharing? -

so built app using mean.js, , made updates articles (blog) section better seo, readability, design, etc. 1 problem can't seem figure out, though, how share articles using facebook, google+, twitter, etc. , have them populate right data using og meta tags. what want all want able share articles (blog posts) mean.js application, , have article content show when post link in social sites (e.g. facebook). what have tried i've tried creating separate server layout blog posts, breaks many other things realized amount of work wasn't worth - there has smarter way. i've tried updating og meta tag data angular on client side, these values must not updated before social sites grab tags...in other words, didn't wanted to. i've tried grabbing angular route url when index rendering can update og meta values before index rendered, can't find these values anywhere in req data. what think problem is conceptually, believe happening: the request hits se...

jsp - Java AEM Query Builder || -

i building simple meta-data table gets data query. want able query on 2 options 'type' variable. || not working however; when use page crashes. map<string, string> predicates = new hashmap<string, string>(); predicates.put("path", searchpath); predicates.put("type", "cq:page||dam:asset"); predicates.put("orderby", orderby); querybuilder qb = resourceresolver.adaptto(querybuilder.class); session session = resourceresolver.adaptto(session.class); query query = qb.createquery(predicategroup.create(predicates), session); query.sethitsperpage(0); you have use groups query or condition. code search should be predicates.put("path", searchpath); predicates.put("group.p.or", "true"); predicates.put("group.1_type", "cq:page"); predicates.put("group.2_type", "dam:asset"); predicates.put("orde...

How to clear the cache from entitymanager in Breeze -

how clear cache entitymanager in breeze, actually trying remove criteria , saving criteria, after saving criteria if error server trying remove criteria. function (error) { var changedentities = manager.getchanges([requesttype, requestitemtype, requestcriteriaitemtype]); //rollback entities (var w = 0; w < changedentities.length; w++) { changedentities[w].entityaspect.rejectchanges(); } ds.servicename = originalservicename; $rootscope.$broadcast("requestsavecomplete", { successful: false, saveresults: [], errors: error.entityerrors }); i wrote code that, if error removing criteria , saving remaing criteria here getting problem , in entitymanger not clearing cache not sure understand issue, but... you can clear entitymanager's cache calling entitymanager.clear ( see http://breeze.github.io/doc-js/ap...

haskell - Is there any non-recursive term that folds over a scott-encoded list? -

suppose have scott-encoded list such as: scott = (\ c n -> c 1 (\ c n -> c 2 (\ c n -> c 3 (\ c n -> n)))) i want function receives such kind of list , converts actual list ( [1,2,3] ), except such function can not recursive. is, must in eta-beta normal form. function exist? ok, give shot. feel free correct me, because i'm not expert on this. for arbitrary x , xs , must case tolist (\c n -> c x xs) reduces term convertible x : tolist xs . this possible if reduce left hand side c x xs applying (\c n -> c x xs) c , n . tolist ~ (\f -> f ? ?) . (btw, part couldn't think of nice rigorous argument; had ideas none nice. i'd happy hear tips). now must case c x xs ~ (x : tolist xs) . since x , xs distinct universal variables, , variables occurring in right hand side, equation in miller's pattern fragment , , therefore c ~ (\x xs -> x : tolist xs) general solution. so, tolist must reduce (\f -> f (\x xs -> x : toli...

Java error MySql Jersey -

this question has answer here: java resultset sql array failing 1 answer i getting exeption when trying run sql command: select * duplic dup_vencto < now() on java dynamic web application: jun 02, 2015 3:25:22 pm com.sun.jersey.server.impl.application.webapplicationimpl _initiate informações: initiating jersey application, version 'jersey: 1.18.1 02/19/2014 03:28 am' java.sql.sqlfeaturenotsupportedexception @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ java.lang.class.newinstance(class.java:374) @ com.mysql.jdbc.sqlerror.notimplemented(sqlerro...

wordpress - Callback in Twitter widget -

does know how include callback in twitter widget? input appreciated. <script>!function(d,s,id){var js,fjs=d.getelementsbytagname(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getelementbyid(id)){js=d.createelement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentnode.insertbefore(js,fjs);}}(document,"script","twitter-wjs"); </script> twitter’s widgets javascript fires events on initialization , after viewer interacts widget: https://dev.twitter.com/web/javascript/events . you have load javascript in <head> of page: <script src="http://platform.twitter.com/widgets.js" id="twitter-wjs"></script> then add javascript, like: twttr.ready(function (twttr) { twttr.events.bind( 'rendered', function (ev) { // callback code }); }); you can see example at end of js , result on "get direct" section of page ...

TDD at big technology companies - any evidence? -

does have evidence of tdd being used @ big technology companies - e.g. apple, microsoft, facebook? perhaps there's that's worked in 1 of these big companies can shed light on how tdd used there. check out paper "realizing quality improvement through test driven development: results , experiences of 4 industrial teams" http://www.msr-waypoint.net/en-us/groups/ese/nagappan_tdd.pdf

ios - Shadows slow up UIScrollView -

i have uiscrollview pretty functions facebook news feed . thought elements slowing scroll fps down. process of elimination, found out shadows slow down app. the uiview boxes inside scroll view have such configuration: self.layer.shadowcolor = uicolor.blackcolor().cgcolor self.layer.shadowoffset = cgsizemake(0, 2) self.layer.shadowradius = 2 self.layer.shadowopacity = 0.15 like news feed, scroll view has many boxes, therefore having uiview s own shadows. how go without slowing down app? there's bunch of stuff on speeding uiscrollviews: calayer - shadow causes performance hit? https://markpospesel.wordpress.com/2012/04/03/on-the-importance-of-setting-shadowpath/ if use custom calayer instances -- shadows -- stuff requires processing power, should use scrollview.layer.shouldrasterize = yes; scrollview.layer.rasterizationscale = [uiscreen mainscreen].scale; also shadowpath speed scrollview this: [scrollview.layer setshadowpath:[[uibezierpath bezierpa...

php - Making a MySQL database connection with a stored procedure -

all examples of using mysql stored procedures via php show script making connection php before calling procedure. possible define , use procedure make connection, , return connection handler used php? a stored procedure can have in, inout , out parameters, depending on mysql version. in passes value procedure. out passes value procedure caller. inout caller initializes inout parameter, procedure can modify value, , final value visible caller when procedure returns. you need connection database call stored procedure.. can't procedure call connection.

node.js - Webpack-dev-server and isomorphic react-node application -

i've managed use webpack dev server alongside node server (express), using plugin section inside webpack's config. it works fine i'm trying go isomorphic , use client-side components inside express application. so far problem i'm encountering without webpack 'parsing' server-side code situation require components paths not solved i.e. inside component 'use strict'; import react 'react'; import { routehandler, link } 'react-router'; import header 'components/header/main'; // <-- line causes error because webpack not working when parsing jsx server-side export default react.createclass({ displayname: 'app', render() { return ( // ... more code shall configure webpack in way or have change imports valid server-side? the codebase here in case want see actual state https://github.com/vshjxyz/es6-react-flux-node-quickstart i see 2 options: compile client code webpack well. if cl...

javascript - Show Bootstrap popover only once -

i've got jsfiddle: http://jsfiddle.net/jsfiddleplayer/vhg7csb7/3/ when load page , click on "blog" tab, should show popover 5.6 seconds , disappear. if user clicks on tab , returns "blog", should not show popover again. should once per user visit page. currently, shows popover every time visit "blog" tab. i've looked @ this post ( configuring bootstrap popover appear once? ), destroy method doesn't seem work me. here's html: <div class="r1 row" id="anch-story"> <div class="c1 col-md-12"> <ul class="nav nav-justified nav-tabs"> <li class="active"> <a class="btn-lg" data-toggle="tab" href="#story-tab-1">vision</a> </li> <li> <a class="btn-lg" data-toggle="tab" href="#story-tab-2">manufactu...

javascript - How to submit two forms at a time and store first form submit output value as 2nd form value? -

Image
using below form 1, i'm generating goo.gl short url inline in #shorturlinfo area. want use generated short url in 2nd form save in wordpress custom field. form 1: <form method="post" action=""> <input style="display:none;" type='text' id='longurl' value='<?php echo get_post_meta( get_the_id(), 'longurl', true ); ?>' /> <input name="shorturlinput" type="button" id="shortit" value="short it" /></form> <div class="info" id="shorturlinfo"></div> form 2: <?php global $post; if( isset($_post['submit_meta']) ) { if( ! empty($_post['change_meta']) ) { update_post_meta($post->id, 'shorturl', $_post['change_meta']); }} ?> <form method="post" action=""> <input type="text" name="change_meta" value="" /> <inpu...

javascript - jQuery combo box that fills the POST variable correctly -

i have tried several jquery combo boxes (for example the simple combobox plugin jquery ) , remarkably glorified selection widgets (i.e. can select item list autocomplete, animations , whatnot) not real comboboxes allow user select list enter value not in list . (for above mentioned plugin, if set variable invalidasvalue true sets value internally , not in field used in post in <form> , if have list of "a" "b" "c" , user enters "d", result "a" because use preselection if not match item.) the html5/ datalist feature (see demo ) not usable because buggy in browsers (in firefox autocomplete-feature , show whole list, in safari not supported @ all) altough working correctly in chrome. i want basic combobox, exists in pretty every graphics toolkit on earth since @ least 1990s: an item preselected the user may edit item or choose item drop-down list there many demos (including above mentioned jquery plugin) fullfill a...

How to move sections of XML with Ruby and Nokogiri between XML files -

i have program stores configuration data in single xml file. program installed on 2 servers, production , dev. want move piece of xml file git repository , push dev production. the xml file has section each project need section project i’m working on. here example: <?xml version="1.0" encoding="utf-8"?> <timers> <timer autostart="0" container="" container_pwd="" container_user="" log_active="info" log_size="25" maxjobs="10" maxlogsize="5000" name="orderimports" ownprocess="0" vmargs=""> <job date_repeat="0" day="0" description="send certainteed shipfile - once day" disable="0" fri="1" high_priority="0" hour="23" inthour="" intmin="" intsec="" jobid="66e6aa67-0ad0-4480-91ae-d17c3e769f4a" min="00" mon=...

Extract line from a file in shell script -

i have text file of 5000000 lines , want extract 1 line each 1000 , write them new text file. new text file should of 5000 line. can me? you can use either head or tail , depends line you'd extract. to extract first line each file (for instance *.txt files): head -n1 *.txt | grep -ve ^= -e ^$ > first.txt to extract last line each file, use tail instead of head . for extracting specific line, see: how use head , tail print specific lines of file .

angularjs - How to filter data from array and apply infinite scroll using angular js? -

i have requirement query records , push array. , since have 2000 records display, takes more time. implement infinite scroll. have filter feature along this. how can show records on scroll , show filtered records on scroll when search box contains search term? pls help. thanks in advance! this more complicated task since built in angular filter requires elements in local array before being able filter. cannot use it, , must move task of filtering server, example using sql %like% query. you need reuse both array of records, , pagination component. there 2 use cases: user viewing unfiltered list user has entered valid search query , viewing filtered list when user viewing unfiltered list, querying api endpoint ex: server.com/api/records?page=page_number when user viewing filtered list, querying api endpoint ex: server.com/api/records?page=page_number&query=mysearchquery so entire task becomes: user viewing unfiltered list user enters search term ...

c# - Why are IEnumerable Projections not Immutable? -

assuming awesome class has property bazinga , string default value of "default value", go: var enumerableofawesome = enumerable .range(1, 5) .select(n => new awesome()); foreach (var in enumerableofawesome) a.bazinga = "new value"; as may aware, enumerating enumerableofawesome again not make happy, if expect find "new value" strings safely tucked away in bazinga . instead, outputting them console render: default value default value default value default value default value (.net fiddle here) this , dandy deferred execution point-of-view, , issue has been discussed before, here , here . question why enumerator implementations not return immutable objects; if persistence on several enumerations not guaranteed, use there of ability set values, save making people confused? maybe isn't question, i'm sure answers enlightening. my question why enumerator implementations no...

extjs - Webstorm not ignoring directories marked "excluded" -

Image
i have marked webcontent/desktop/build directory excluded, webstorm still trying index it. annoying whenever build, , have wait webstorm finish indexing before can anything. how make not index in folder? here's project directories like i've set project exclude build directory yet still... folders marked javascript libraries can't excluded indexing. , webcontent directory library folder. remove folder javascript libraries (settings/languages & frameworks/javascript/libraries, select library , press remove...). can create new library , add subfolders of webcontent directory need being indexed

javascript - Detect hover on selected text -

Image
i building wysiwyg rich text editor. when user selects portion of his/her text, present menu in tooltip. presenting menu works fine show if user hovers on selected text. as illustrated: i haven't decided on positioning (i way it's illustrated) clarify, that's not point of question. the question is: how filter hover event happens on selected text? the problems: i can't listen text selection event or test hover events see whether on elements have selected text inside them. left image generate false positive that. i know how selected text don't know how selected region . to mind, the ideal solution somehow calculate region of selected text , test whether mouseover events happen in region. on mouseup , use range.getclientrects grab bounding rectangles of each line of selection. you can test if mouse on selection this: var cr= []; $(document).on({ 'mouseup': function() { cr= window.getselection().getrangeat(0).getclie...

javascript - Angularjs directive not working with img tag -

i replace img tag independent of ng-src. if remove ng-src feature not working , if ng-src='/avatars/original/missing.png' feature not working. if ng-src="http://s3.amazonaws.com/avatars/xxxxxxxxxxxxx.xxx" works. <img error-img object="target" data-color="#f37a5e" data-width="65px" data-height="65px" data-font-size="24px" ng-src="{{target.avatar_url}}" > directive code auditionuprofessor.directive 'errorimg', -> restrict: 'a' scope: object: '=' link: (scope, element, attrs) -> chars = "no-image" element.bind('error', -> element.replacewith($("<div class='missing-image' href='javascript:;'>#{chars}</div>") ) ) can help.

ios - self.view.frame/bounds of UIViewController changed between viewDidLoad and viewWillAppear iOS8 -

Image
i have strange problem view in iphone app. i have 2 uiviewcontroller subclasses a , b . a uiviewcontroller of class b (let´s call b ) called method inside of uiviewcontroller of a ( a ). when b displayed, frame , bounds of "root" view of b changed magically between calls of viewdidload , viewwillappear . have no idea, why happens. far know, other views not have problem. these frames , bounds: in viewdidload : self.view.frame: {0, 0}, {375, 667} self.view.bounds: {0, 0}, {375, 667} in viewwillappear: : self.view.frame: {0, 64}, {375, 554} self.view.bounds: {0, 0}, {375, 554} i made screenshot demonstrate problem. yellow area self.view of b . red , green ones subviews of self.view . there layouting. don´t think have effects on self.view frame or bounds. does have idea causes problem? okay, after hours (literally!) of debugging found error: forgot call self = [super init]; in custom init method. caused weird behaviour. thanks hel...

latex - How do I set up mirror margins in R markdown using knitr -

i know how adjust margins in r markdown pdf file following: --- title: "model 1 coefficients" output: pdf_document geometry: margin=1in --- but make margin sizes switch between , odd pages inner margin 1.25 in , outer .25 in. i able find latex info on website http://texdoc.net/texmf-dist/doc/latex/geometry/geometry.pdf , seems want use twoside option i'm not sure right or how call it. tried following: --- title: "model 1 coefficients" output: pdf_document twoside: inner=1.25in, outer=0.25in --- but didn't margins

asp.net mvc 4 - IIS 7.5 URL Rewrite: Redirect Rule does not appear to work from old domain to new domain -

i trying understand why following rule created in iis not working when person tries enter site. basically have old domain , new domain. going old domain redirected landing page on our new domain. i using asp mvc4 site , have added bindings domains , updated dns well. my rule is: <rule name="http://www.olddomain.com landing page" patternsyntax="wildcard" stopprocessing="true"> <match url="*" /> <action type="redirect" url="http://www.new-domain.co.uk/landingpage" /> <conditions logicalgrouping="matchany"> <add input="{http_host}" pattern="http://www.olddomain.com" /> <add input="{http_host}" pattern="http://olddomain.com" /> <add input="{http_host}" pattern="http://www.olddomain.com/" /...

bash - Logical OR in GLOB during grep --include/--exclude -

in ubuntu terminal, grep files (or excluding) extension .foo , .bar phrase 'foobar' . i've read this advice creating glob logical or, , tried few combinations none seem work: rgrep "foobar" --include "*.foo|*.bar" rgrep "foobar" --include "*.{foo,bar}" rgrep "foobar" --exclude "(*.foo|*.bar)" what's secret recipe? you can use extglob pattern here: shopt -s extglob grep 'foobar' *.@(foo|bar) for using recursive grep --include have use glob patterns only: grep -r 'foobar' --include=*.{foo,bar} .

skip some iteration in ruby for loop -

how can achieve in loop in ruby: for(int = 1;i<=10;i++){ if (i == 7){ i=9; } #some code here } i meant it's okay use "next" skip if want jump uncertain iteration via changing variable value itself. far know loop works enumerable type. want loop via index variable, way in c++ there few things can do: incase want skip few iterations based on defined logic, can use: next if condition if intention randomly iterate on whole range, can try this: (1..10).to_a.shuffle.each { |i| # code } incase want randomly iterate on chunk of given range, try this: (1..10).to_a.shuffle.first(n).each { |i| # n number within 1 10 # code }

Cannot select input jquery -

it's simple question, dont know how . <div> <input> </div> <p id="pepe"></p> the following : $("#pepe").prev() gives me div, how first child (input) as you've seen prev() gets previous sibling element. input there need use find() , along :first assuming there multiple within actual working html: $("#pepe").prev().find('input:first');

csv - UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 7240: character maps to <undefined> -

i student doing master thesis. part of thesis, working python . reading log file of .csv format , writing extracted data .csv file in formatted way. however, when file read, getting error: traceback (most recent call last): file "c:\users\sgadi\workspace\dab_trace\my_code\trace_parcer.py", line 19, in row in reader: file "c:\users\sgadi\desktop\python-32bit-3.4.3.2\python-3.4.3\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] unicodedecodeerror: 'charmap' codec can't decode byte 0x8d in position 7240: character maps <undefined> import csv import re #import matplotlib #import matplotlib.pyplot plt import datetime #import pandas #from dateutil.parser import parse #def parse_csv_file(): timestamp = datetime.datetime.strptime('00:00:00.000', '%h:%m:%s.%f') timestamp_list = [] snr_list = [] freq_list = [] rssi_list = [] dab_present_list = ...