Posts

Showing posts from June, 2011

python - How to to split a list at a certain value -

given unique valued list such [5,4,9,2,1,7,'dog',9] there way split a value? ie [5,4,9,2,7,'dog'].split(4) = [5,4],[9,2,7,'dog'] [5,4,9,2,7,'dog'].split(2) = [5,4,9,2], [7,'dog'] ? >>> mylist = [5,4,9,2,7,'dog'] >>> def list_split(l, element): ... if l[-1] == element: ... return l, [] ... delimiter = l.index(element)+1 ... return l[:delimiter], l[delimiter:] ... >>> list_split(mylist, 4) ([5, 4], [9, 2, 7, 'dog']) >>> list_split(mylist, 2) ([5, 4, 9, 2], [7, 'dog']) >>> list_split(mylist, 'dog') ([5, 4, 9, 2, 7, 'dog'], [])

asp.net - Telerik Skin Change Dynamically -

i need change entire web application skin dynamically when user changes theme radskinmanager drop down menu. below code changes page theme doesn't change entire application skin. how can achieve such functionality? radskinmanager change skin of telerik controls in current page (including master/content pages , user controls) if not have explicit setting skin property. perhaps should storing desired skin somewhere (file, database, whatever) , set skinmanager's skin desired value (e.g., in page_init).

java - Validate non or max. 1 checkbox is enabled in wicket listview -

how can validate not more 1 checkbox selected in listview (repeater)? i have form listview in wicket following structure: line 1 n: ajaxcheckbox , textfield both elements connected compoundpropertymodel<simpletype> . pojo simpletype looks like: public class simpletype { private boolean enabled; private string value; getter/setter... } if more 1 checkbox selected, form should reject changes. user must deselect selected checkbox first before can choose checkbox. tried surrounded checkgroup ivalidator<collection<simpletype>> , need change ajaxcheckbox component check . in case check seems not updated state enabled compoundpropertymodel . do need validator or visitor case? how implement them? since radio not option here simple solution should work: for validation use iformvalidator visits ajaxcheckbox-es. for immediate ui response i'd use plain js unchecks previous checked checkbox. fire wicket ajax call unselect @ server s...

invoke command - Powershell passing arguments in ScriptBlock -

i'm trying last write time on file remote server. this doesn not work: $server = "myservername" $lastwrite = invoke-command -computername $server -scriptblock {get-childitem "\\$args[0]\hot.war" } -argumentlist $server | select -property lastwritetime this work: $lastwrite = invoke-command -computername $server -scriptblock {get-childitem "\\myservername\hot.war" } -argumentlist $server | select -property lastwritetime can make first set work? another way, if using powershell 3. can this: $lastwrite = invoke-command -computername $server -scriptblock { get-childitem "\\$using:server\hot.war" } | select -property lastwritetime

php - Sending Bulk Email Without SMTP Server -

i have server , have emailing software. want send mass/bulk email customers list.(there around 100k people, trying gather list 10 years) , want send them email. can send mass email without using smtp? there couple of ways send email without need of own smtp server. there addition php can called phpmailer simplify process. or, can send php's built in mail() function , must sure to format header information correctly. for php, question has been asked before. see link details . however, sending mail without using verified smtp server result in email being sent customers junk mail folder. if emails destined corporate addresses, corporations firewall may drop email entirely. typically if email provider detects enough emails of kind, may blacklist ip / server time.

javascript - How to identify Ellipsis is being applied so that some links(more) can be suffixed to toggle the ellipsis -

how identify ellipsis being applied links(more) can suffixed toggle ellipsis. is there detect ellipsis being applied using css or javascript. here need apply ellipsis after 3 lines. css below: .test-ellipsis { color: #6f6f6f; font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } you implement using jquery. idea clone , render element , see if rendered width greater original. instead of giving working code, redirect another similar question implements working version.

html - Disabling sorting on nested DOM Element -

i'm working datatables , have th nested checkbox: <th class="sku-checkbox-wrapper sorting_desc" rowspan="1" colspan="1" aria-label="select all">select all<br> <input type="checkbox" id="sku_select_all" class="checkbox"></th> currently, th has sorting event handler attached it. de-couple nested checkbox event. i have th set 'bsortable':'true'. there way 'bsortable' :' false' nested checkbox , keep parent th element sortable? you need add click event handler checkbox , prevent event propagation parent element. $("#sku_select_all").on('click', function(e){ e.stoppropagation(); }); see this jsfiddle demonstration.

javascript - FullCalendar not showing events using ko.observablearray as event souce -

i'm trying fill jquery fullcalendar ko.observablearray function calevent(data) { this.id = ko.observable(data.id); this.title = ko.observable(data.title); this.start = ko.observable(data.start); this.end = ko.observable(data.end); this.color = ko.observable(data.color); this.allday = ko.observable(data.allday); } function fulleventsviewmodel() { var self = this; self.calevents = ko.observablearray([]); //get data calendar $.getjson("/journalentries/getsummaryevents?id=" + journalid, function (data) { var mappedcalevents = $.map(data, function (item) { return new calevent(item) }); self.calevents(mappedcalevents); }); $('#calendar').fullcalendar({ events: self.calevents, header: { left: 'prev,next today', center: 'title', ...

asp.net mvc - Entity Framework using Identity - Trying to update a user in the AspNetUsers table -

i having hard time figuring out how update/modify user in aspnetusers table using entity framework , identity. getting error says: "the entity type manageruserviewmodel not part of model current context." this make sense, because not mention manageruserviewmodel in applicationdbcontext using. should create new context similar applicationdbcontext , use one? or somehow add manageruserviewmodel applicationdbcontext ? here controller method doing updating when 'save' clicked: public actionresult edituser([bind(include = "userid, email, username, roles, roleid, rolename")] manageruserviewmodel model) { if (modelstate.isvalid) { using (var context = new applicationdbcontext()) { var store = new userstore<applicationuser>(context); var manager = new usermanager<applicationuser>(store); applicationuser user = new applicationuser(); ...

how to convert range of values in matlab? -

i want these values converted range of 1-100 a= [0 -24 14 34 8 41 55...] with minimum value of -30 , maximum value of 57 you can standard normalization, this: a = [0 -24 14 34 8 41 55 -30 57]; minimum = -30; maximum = 57; b = 1 + 99 * (a - minimum) / (maximum - minimum); after running, b = [35.1379 7.8276 51.0690 73.8276 44.2414 81.7931 97.7241 1.0000 100.0000]

jsf 2 - Navigating to another page JSF -

i wrote jsf application, app inserts data mysql database , shows of inserted details in page. i successful in inserting values database, unable redirect other page after writing navigation rule. my action code <div align="center"><p:commandbutton label="submit" action="#{userdata.add}" align="center" ajax="false" /></div> navigation rule <managed-bean> <managed-bean-name>userdata</managed-bean-name> <managed-bean-class>userdata.userdata</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <navigation-rule> <display-name>home.xhtml</display-name> <from-view-id>/home.xhtml</from-view-id> <navigation-case> <to-view-id>/badge.xhtml</to-view-id> </navigation-case> </navigation-rule> if wr...

javascript - React components render correctly in browser, but Jest test errors when rendering: "Only a ReactOwner can have refs" -

i have 2 components in react render fine , produce expected behavior in browser, can't seem rendered when running test via jest. descriptions.js var react = require('react/addons'); var $ = require('jquery'); var description = require('./description.js'); var descriptions = react.createclass({ getinitialstate: function () { //container starts @ least 1 description field empty, or whatever contained in props var descriptions = []; if (this.props.info == null) { descriptions.push({num: 0, data: ''}); } else { $.each(this.props.info, function (i, string) { descriptions.push({num: i, data: string}); }); if (descriptions.length == 0) { //we want @ least 1 description field @ times descriptions.push({num: 0, data: ''}); } } return {descriptions: descriptions, focus: -1}; }, componentwillreceiveprop...

Java - Pass Class as Parameter for Comparison -

essentially want pass class parameter can preform instanceof comparison. public class myclass { object o = something; public void mymethod(class c) { if(o instanceof c) { } } } where parameter class c class choose pass in else where. want able pass in class , make comparison. any appreciated. thanks you can call class#isinstance(object obj) : if(c.isinstance(o)) { determines if specified object assignment-compatible object represented class . this method dynamic equivalent of java language instanceof operator .

Django m2m relation of the model with itself with extra attributes -

i tried create model many many self relation, put in code: class person(models.model): name = models.charfield(max_length=50) shape_clm = models.manytomanyfield("self", through='friend', symmetrical=false) def __str__(self): return self.name class friend(models.model): pers_one = models.foreignkey(person) pers_two = models.foreignkey(person) type = models.charfield(max_length=150) but when tried migrate model db following error raised: friend.pers_one: reverse accessor friend.pers_one clashes reverse accessor friend.pers_two i'm using postgres db server, how can make m2m relation? you need add related_name keyword argument, otherwise orm can't tell how refer either of fields. class friend(models.model): pers_one = models.foreignkey(person, related_name='pers_ones') pers_two = models.foreignkey(person, related_name='pers...

c++ - Sublime Text3 the same snippets repeats -

Image
i'm using sublime c++ package. found when trying use auto completes, it came 2 options whole same snippets! i'm pretty sure snippets define "c++ starting kit" package i've reinstall nothing change. any idea appreciated!

javascript - Strange Progress Bar Behavior offsetwidth -

i started developing simple progress bar using vanilla javascript. far grabbing width set in css way found js use .offsetwidth - following code functionality demo beginning setup. fiddle link @ bottom of question. html: <section id="box"></section> <p> <section id="box2"></section> css: #box, #box2 { height: 10px; width: 5px; background-color: lightblue; } #box2 { width: 4px; } javascript (onload) : var savedwidth = document.getelementbyid("box").offsetwidth; alert("box 1 width " + savedwidth); savedwidth = document.getelementbyid("box2").offsetwidth; alert("box 2 width " + savedwidth); while testing out see if grabbed property accurately noticed when width set 5px returned 6px . else seems fine. 4px = 4px, 6px = 6px. i curious if knew why happened? it's minimal enough won't affect i'm trying seemingly, more know better off you'll be. fiddle : http://jsfidd...

Number of observations by two variables in R -

how find number of observation meeting both criteria bf between 10-15 , p between 20-24? bf = rnorm(50,10,2) p = rnorm(50,20,4) es = rnorm(50,40,8) evidence = data.frame(bf,p,es) nrow(evidence[with(evidence,bf > 10 & bf < 15 & p > 20 & p < 24),])

python - matplotlib fill_between does not cycle through colours -

most plotting methods plot() , errorbar automatically change next colour in color_palette when plot multiple things on same graph. reason not case fill_between(). know hard-code done in loop makes annoying. there way around this? import numpy np import matplotlib.pyplot plt x = np.asarray([1.0, 2.0, 3.0, 4.0, 5.0]) y = np.asarray([1.0, 2.0, 3.0, 4.0, 5.0]) xerr = np.asarray([0.2, 0.4, 0.6, 0.8, 1.0]) yerr = np.asarray([0.1, 0.2, 0.3, 0.4, 0.5]) plt.fill_between(x, y-yerr, y+yerr,alpha=0.5) plt.fill_between(y,x-xerr,x+xerr,alpha=0.5) plt.show() maybe current position in palette , iterate next enough. strange, seems calling ax._get_patches_for_fill.set_color_cycle(clist) or ax.set_color_cycle(np.roll(clist, -1)) explicitly doesn't reinstate color cycle (see answer ). may because fill between doesn't create conventional patch or line object (or may bug?). anyway, manually call cycle on colors in axis function ax.set_color_cycle , import numpy np import m...

Django : intercept authentication to store session variable or cookie -

i working on project that's running on django. authenticate in multiple places. first, maintain standard authentication mechanism , continue using site administration. second, intercept login request in addition standard authentication, , check if user has authenticated on system , store session variable or cookie used later if authenticated. on logout remove session variable or cookie. second authentication mechanism should not affect first. in addition, if first succeeds , second fails, should have no affect on standard administration. i have looked declaring custom authentication backend in settings authentication_backends tuple. understand, authenticates in order , stop authenticating once match made. any guidance in regards appreciated. if need set , unset cookie or session var can use signals sent authentication module ( docs ) example: from django.contrib.auth.signals import user_logged_in, user_logged_out def user_logged_in_hook(sender, **kw...

Android Studio KVM Setting? -

put in kvm (kernel-based virtual machine) 64 bit ubuntu 14.04 lts per: https://help.ubuntu.com/community/kvm/installation in terminal: kvm-ok info: /dev/kvm exists kvm acceleration can used ok kvm in. when run android emulator no change way emulator ran before put in kvm. looked in various setting within android studio found nothing obvious kvm. does android studio have setting somewhere enable kvm? android studio 1.5 , 2.0 not have such option more. update: because team has made kvm mandatory . , see comments google employees claiming new 2.0 emulator kvm-based.

css - Ionic Framework How to place a div or buttons below ion-content map -

i'm working on ionic project , in tab placed google map following this tutorial. want put buttons (inside div?) trigger actions on map. how can achieve that? i'm newbie framework, i'll appreciate help. my index.html <body> <ion-nav-bar class="bar-positive" animation="nav-title-slide-ios7"> <ion-nav-back-button class="button-clear"> <i class="ion-arrow-left-a"></i> </ion-nav-back-button> <ion-nav-buttons side="right"> <a class="button" href="#/tab/twitter"> <i class="icon ion-social-twitter"></i> </a> </ion-nav-buttons> </ion-nav-bar> <ion-nav-view animation="slide-left-right-ios7"> </ion-nav-view> </body> my maps.html <ion-view title="ubicación...

PanDoc: How to assign level-one Atx-style header (markdown) to the contents of html title tag -

i using pandoc convert large number of markdown (.md) files html. i'm using following windows command-line: for %%i in (*.md) pandoc -f markdown -s %%~ni.md > html/%%~ni.html on test run, html looks ok, except title tag - it's empty. here example of beginning of .md file: #topic title - [anchor 1](#anchor1) - [anchor 2](#anchor2) <a name="anchor1"></a> ## anchor 1 is there way can tell pandoc parse the #topic title so that, in html output files, get: <title>topic title</title> ? there other .md tags i'd parse, , think solving me solve rest of it. i don't believe pandoc supports out-of-the-box. relevant part of pandoc documentation states: templates may contain variables. variable names sequences of alphanumerics, - , , _ , starting letter. variable name surrounded $ signs replaced value. example, string $title$ in <title>$title$</title> will replaced document title. it con...

PHP - Sorting ArrayObject -

i'm having problem sorting items in php class extends arrayobject. i creating classes, , way i've figured out add cmp() function put in same file, outside of class. can't seem put anyplace else because of way uasort requires function name string. so i'm doing this: class test extends arrayobject{ public function __construct(){ $this[] = array( 'test' => 'b' ); $this[] = array( 'test' => 'a' ); $this[] = array( 'test' => 'd' ); $this[] = array( 'test' => 'c' ); } public function sort(){ $this->uasort('cmp'); } } function cmp($a, $b) { if ($a['test'] == $b['test']) { return 0; } else { return $a['test'] < $b['test'] ? -1 : 1; } } which fine if i'm using 1 class this, if use 2 (either autoloading or require) breaks on trying invoke cmp() twice. i g...

spring - SubProtocolWebSocketHandler - No handlers -

i have ugly error during deploying spring app on jboss. 18:11:16,025 error [org.apache.catalina.core.containerbase.[jboss.web].[default-host].[/consumer]] (msc service thread 1-7) exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener: org.springframework.context.applicationcontextexception: failed start bean 'subprotocolwebsockethandler'; nested exception java.lang.illegalargumentexception: no handlers @ org.springframework.context.support.defaultlifecycleprocessor.dostart(defaultlifecycleprocessor.java:176) [spring-context-4.1.3.release.jar:4.1.3.release] @ org.springframework.context.support.defaultlifecycleprocessor.access$200(defaultlifecycleprocessor.java:51) [spring-context-4.1.3.release.jar:4.1.3.release] @ org.springframework.context.support.defaultlifecycleprocessor$lifecyclegroup.start(defaultlifecycleprocessor.java:346) [spring-context-4.1.3.release.jar:4.1.3.release] @ org.s...

Read from database Android, query -

i'm trying read database i've created , in logcat appears: "style contains key bad entry: 0x01010479" , "(1) no such table: feedreader". have been testing lot of hours , don't know problem context contexto = this; database dbhelper=new database(contexto); sqlitedatabase db=dbhelper.getwritabledatabase(); string[] columns={"columnname","columnimage","columnsound"}; cursor c=db.query("feedreader", null, null, null, null, null, null); if (c.movetofirst()) { //recorremos el cursor hasta que no haya más registros for(c.movetofirst(); !c.isafterlast(); c.movetonext()){ namec[c.getcount()]= c.getstring(1); //imagec[c.getcount()]= c.getstring(2); //soundc[c.getcount()]= c.getstring(3); } } c.close(); db.close(); }catch(sqliteexception e) { system.out.println(e.get...

html - Pure css gradually change text on hover -

i'm trying gradually change element's text while hovering, it's not working me. i have css: .author-details > div { display: inline-block; width: 30%; float: none !important; background-color: #1abc9c; color: #fff; padding: 2% 3% 2% 3%; border-radius: 7%; font-weight: normal; font-size: 16px; -webkit-transition: background 0.35s linear; -moz-transition: background 0.35s linear; -ms-transition: background 0.35s linear; -o-transition: background 0.35s linear; transition: background 0.35s linear; -webkit-box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); -moz-box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); } .author-details > div a:after { content: 'others'; } .author-details > div a:hover { background-color: #5dade2; } .author-details > div a:hover:after { -webkit-animation:fade-in 0.35s ease-in; } @-webkit-keyframes fade...

php - OpenCart RESTful API for Android Application -

i new opencart, , in process of creating opencart restful apis android application. have created api login customer. no issue. don't know how can handle session cart each customer logged in through android app. is there token maintained opencart or cart session variable can use. i saw somewhere in source "$this->session->data['cart']" couldn't understand function properly. thanks help

javascript - Unity3D WWW get HTML displayed in browser -

i have in web page, on localhost server, information want use in unity. problem information stored in js variables. i tried use www class in coroutine, html source code. there way value of variables inside unity editor ? thanks !

php - failed prepared statement and img file upload -

i attempting create first prepared statement , use see i'm doing wrong. had of query working before doing this, told me should way prevent sql injection. i'm trying send product info database. included in data, trying send img file , have moved db. before attempting prepared statement doing simple mysqli insert statement , part of query did not work getting file name of img show in database actual file name. way uploading "array" or "1". changed things around try make work procedure statement best could. i'm not sure if attempt upload img file correct in prepared statement or not. reason being none of being sent data base now. not getting errors database connection. i start off validation. not have validation img file yet. add later once can send. i process form info. i'm not sure if $file variable structured right sending file name db i'm getting error. i error php error info on.. notice: undefined index: img in /home4/pfarley1/pub...

Portable SQL with Group By and Joins -

i have following 2 tables: table1: id devicename devicelocation additionalcolumn1 additionalcolumn2 1 xyz africa somecoltext1 sometext1 2 abc usa somecoltext2 sometext2 table2: id name externalid devicename devicelocation version 1 yyy 10 xyz africa 1 2 bbb 11 xyz africa 1 3 uuu 10 abc usa 2 i'm trying come sq l me values out of table2 joins table1 , fetch me additional fields table1(additionalcolumn1, additionalcolumn2) . additionally, want elements table2 has maximum version . expected result should be: id name externalid devicename devicelocation version additionalcolumn1 2 bbb 11 xyz africa 1 somecoltext1 3 uuu 10 abc usa 2 somecoltext2 i have basic version setup, portable version works across databases? i think 1 of possible solutions: select t2.id, ...

libs - Removing an Android library -

i using library in android project. need replace new one. removed , added new 1 libs/ folder. but eclipse keeps saying : project missing required library:'libs/old-lib.jar' how can ? thanks helping go project → build path → configure build path. under libraries tab, make sure jar not in list, otherwise remote it. then click order & export tab, , ensure jar unchecked.

ios - How to compare two strings ignoring case in Swift language? -

how can compare 2 strings in swift ignoring case ? eg : var = "cash" var b = "cash" is there method return true if compare var & var b try : var : string = "cash" var b : string = "cash" if(a.caseinsensitivecompare(b) == nscomparisonresult.orderedsame){ println("voila") } swift 3.0 if(a.caseinsensitivecompare(b) == comparisonresult.orderedsame){ println("voila") }

opengl - How to change background at runtime on openscenegraph -

i try add 3d object on viewer , change background dynamically. capture webcam using opencv videocapture . i did below steps : open video capture , frame create openscenegraph root add child root ( read .osg file 3d object) create texture2d object background set image of background create camera view background add camera root set data of viewer ( viewer.setscenedat(root) ) run viewer.run() these steps add first frame background , add 3d object scene. can't change background each frame. how can it? code : cv::videocapture cap(0); cv::mat frame; if(!cap.isopened()) { std::cout << "webcam cannot open!\n"; return; } osgviewer::viewer viewer; osg::ref_ptr<osg::group> root = new osg::group(); osg::ref_ptr<osg::texture2d> bg = new osg::texture2d(); root->addchild(osgdb::readnodefile("object.osg")); bg->setfilter(osg::texture::filterparameter::min_filter, osg::texture::filtermode::linear); bg->setfilte...

javascript - Can't add controller to Yeoman generated angular project -

i using yeoman scaffolding create angular app , having trouble adding controller. , main controllers added automatically , work fine. when try add own controller new view, shows {{name}}. help!here's code: user.js (the 1 i'm trying add) 'use strict'; /** * @ngdoc function * @name classsiteapp.controller:usercontroller * @description * # usercontroller * controller of classsiteapp */ angular.module('classsiteapp') .controller('usercontroller', function ($scope) { $scope.name='hello'; }); app.js 'use strict'; /** * @ngdoc overview * @name classsiteapp * @description * # classsiteapp * * main module of application. */ angular .module('classsiteapp', [ 'nganimate', 'ngcookies', 'ngresource', 'ngroute', 'ngsanitize', 'ngtouch' ]) .config(function ($routeprovider) { $routeprovider .when('/', { ...

linux - What is meant by "compiler helps implement the C standard?" -

i reading / studying book: linux system programming: talking directly kernel , c library , quoting book: the compiler used in unix system—linux included—is highly relevant system programming, compiler helps implement c standard , system abi. what meant compiler helps implement c standard ? disclaimer: have not read relevant paragraph. compiler helps implement c standard in general sense, c standard set of rules and/or guidelines, how language syntax , semantics used. create , run binary (executable), or better say, have implementation of rules mentioned in standard, need have compiler. if may, can say, in other words, compiler uses c standards generate exectable c source code, c standard compilant.

css configuration for map template -

hi i'm using bootstrap template display map tools been having problems css of div containing map-canvas when collapse side panel map moves proper place live blank space on opposite side , there big issue height of map. i'm looking place map full extend when sidepanel collapsed or extended tried without success, appreciate stackoverflow community. thanks in advance. here link page https://secure.cevamhn.net/airaid/maptoolsair.php css code here: /*! * start bootstrap - simple sidebar html template (http://startbootstrap.com) * code licensed under apache license v2.0. * details, see http://www.apache.org/licenses/license-2.0. */ /* toggle styles */ #wrapper { padding-left: 0px; -webkit-transition: 0.5s ease; -moz-transition: 0.5s ease; -o-transition: 0.5s ease; transition: 0.5s ease; } #wrapper.toggled { padding-left: 0px; } #sidebar-wrapper { z-index: 1000; position: fixed; left: 250px; width: 0; /* disini agar ketika ...

jquery - Maintaining submenu visible -

i'm trying display submenu when mouse on parent li when move mouse submenu disappears , not making sense me. i'm using jquery so. here's code (shortened): function showsub(id) { $('#' + id).slidedown('fast'); } function hidesub(id) { $('#' + id).slideup('fast'); } .menu li { display: inline-block; height: 100%; margin: 0; padding: 0; } .menu li { text-decoration: none; color: #9b9a98; font-weight: 700; font-size: 13px; } .menu li span { line-height: 100px; display: block; padding: 0 15px; } .menu li ul { margin: 0; padding: 0; background: rgba(3, 3, 3, 0.85); display: none; position: absolute; } .menu li ul li { margin: 0; padding: 10px 15px; list-style: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <ul class="me...

How do I parse a URL into hostname and path in javascript? -

i take string var = "http://example.com/aa/bb/" and process object such that a.hostname == "example.com" and a.pathname == "/aa/bb" var getlocation = function(href) { var l = document.createelement("a"); l.href = href; return l; }; var l = getlocation("http://example.com/path"); console.debug(l.hostname) >> "example.com" console.debug(l.pathname) >> "/path"

netsh show rules filtered by local port -

the commande here allow show rules, netsh advfirewall firewall show rule dir=in name=all i filter rules related port 445. currently enabled rules. i read documentation , see example, optional option [dir=in|out] not documented. how can achieved? documentation undocumented possibilities i may use vb script or powershell 2.0 if required. these 2 undocumented options know of: dir (direction) - in or out status - enabled or disabled we can build netsh query gets close , missing port part: netsh advfirewall firewall show rule status=enabled name=all we can port requirement using powershell's select-string (disclaimer i'm not @ regex there might better one, seems work) select-string -pattern "(localport.*445)|(localport.*any)" -context 9,4 the select-string matches specific rule 445, , rules apply port. context argument display rest of rule (otherwise we'll localport line) the final command ends being netsh advfirewall...

c# - HttpResponseMessage parameters received after constructor is called -

i have api controller when called client passes database credentials. public class foremancontroller : apicontroller { static sqlconnectionstringbuilder connectionstring = new sqlconnectionstringbuilder (); public foremancontroller() { //database calls connection string } public void get(string datasource, string initialcatalog, string userid, string password) { connectionstring.datasource = datasource; connectionstring.initialcatalog = initialcatalog; connectionstring.userid = userid; connectionstring.password = password; } } the method working fine , can see credentials being passed via client code: static httpclient client = new httpclient(); httpresponsemessage resp = client.getasync("api/foreman?datasource=dxdv&initialcatalog=q19410&userid=tunld&password=did").result; my problem constructor in apicontroller runs before method database calls fail because of null connection string....

php - Updating subscribers in a list using cURL and Mailchimp API v3 -

i have code below adds user pre-existing list in mailchimp. $apikey = '<api_key>'; $auth = base64_encode( 'user:'.$apikey ); $data = array( 'apikey' => $apikey, 'email_address' => $email, 'status' => 'subscribed', 'merge_fields' => array( 'fname' => $name ) ); $json_data = json_encode($data); $ch = curl_init(); curl_setopt($ch, curlopt_url, 'https://us2.api.mailchimp.com/3.0/lists/<list_id>/members/'); curl_setopt($ch, curlopt_httpheader, array('content-type: application/json', 'authorization: basic '.$auth)); curl_setopt($ch, curlopt_useragent, 'php-mcapi/2.0'); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_tim...

plot - Laying 2 different legends in one axis in matplotlib's gridspec module -

Image
i'm working on plot using matplotlib's gridspec module. want add 2 different legends on specific axis, 1 mentioned in matplotlib: 2 different legends on same graph . however, gridspec , 1 legend laid on other axis , 1 lost. here code: import matplotlib.pyplot plt import matplotlib.gridspec gridspec fig = plt.figure() gs1 = gridspec.gridspec(8, 4) gs1.update(left=0.1, right=0.65, bottom=0.06, top=1, hspace=0) axf = plt.subplot(gs1[0, :]) axe = plt.subplot(gs1[1, :],sharex=axf) axpa = plt.subplot(gs1[2, :],sharex=axf) axmiu = plt.subplot(gs1[3:7, :],sharex=axf) axres = plt.subplot(gs1[7, :],sharex=axf) hd1=axmiu.errorbar(range(5),map(lambda x:x+1,range(5)), fmt='o', color='black', mfc='none',markersize=5, label='hehe') hd2=axmiu.errorbar(range(5),map(lambda x:x+2,range(5)), fmt='-', color='fuchsia',markersize=5, linewidth=2, label='heihei') first_legend=plt.legend(prop={'size':12},labelspac...

apache - htaccess if parameter doesn't exists -

i have problem htaccess redirection. on site use url language parameters (yes there 2 - lang , country) this www.domain.com/en/spain/ i trying redirect [301] default language if user come direct link www.domain.com => www.domain.com/en/global example i use redirecting none www link. rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/en/global/$1 [r=301,l] thank you. try this: rewritecond %{http_host} !^www\. rewriterule ^/?$ http://www.example.com/en/global/ [r=301,l] this redirects example.com to www.example.com/en/global/

.net - How can I remotely install (and uninstall) ClickOnce applications? -

i need deploy multiple clickonce applications 100+ windows (7) machines. is there "lazy" way accomplish without having leave comfort of desk...? clickonce installed on each user account on each computer... if have way remotely connect each user session , install app, yes can! methods know, time expensive, if have 100 machines. i don't think possible push clickonce gpo or other kind of script: clickonce application, must click "install" button! here, split jobs in three: sysadmin, technician , myself (the developper), , visit every computers... have 80 computers. it's take few hours... (luckily, did process once)

linux - Xenomai resources -

i have started familiarize myself linux, , wondering if guys me find resources (easy enough understand) instructions on running xenomai linux. thanks how this one? it's up-to-date course material course called design of embedded systems (des) dutch university , found helpful started (e.g. following exercises ). ;)

javascript - Given a list of links, how do I click and validate each one using C# or Protractor, with Selenium? -

code below in c#, know javascript/protractor. looking pattern works. var links = driver.findelements(by.tagname("a")); foreach (var ele in links) { if (ele.displayed == false) continue; if (ele.enabled) ele.click(); system.threading.thread.sleep(3000); driver.navigate().back(); system.threading.thread.sleep(3000); } without sleep above (which don't like) page hasn't settled down enough navigate back. sleep values in, can click link, , go 1 time! error on 2nd iteration tells me the page stale . question: using selenium c# or protractor how go through entire list of links? if these links regular links href attributes, can use map() array of href s, , navigate each of them 1 one. protractor -specific solution: element.all(by.tagname("a")).map(function (a) { return a.getattribute("href"); }).then(function (links) { (i = 0; < links.length; i++) { browser.get(links[i]); ...

c# - Read appended information in text file -

i have text file have information appended, , want read information list. here design of text file. ------->26/05/2015 17:15:52<------------------ index :0-0 index :1-0 index :2-20150527 index :3-182431 ------->27/05/2015 17:15:52<------------------ index :0-0 index :1-0 index :2-20150527 index :3-182431 ------->28/05/2015 17:15:52<------------------ index :0-0 index :1-0 index :2-20150527 index :3-182431 my question how can read information list, know can use line line how can know reading new item? first should define word "new" if means: not read far in previous iterations new section in file assuming mean new section in file can define such class representing item: class item { public list<string> indexes; public string header; public item() { indexes= new list<string>(); } } and parse file using simple loop this: list<item> items = new list<item>(); var lines = f...

Maven variables precedence: how to make env variable being more important than hardcoded value in pom.xml? -

i'd implement, in maven, way of passing variables pom via env variable using default value if not provided. i created minimalitic pom.xml prints foo , foobar vars. foobar has default value: <project> <groupid>com.example</groupid> <artifactid>test</artifactid> <version>sprint-snapshot</version> <modelversion>4.0.0</modelversion> <properties> <foobar>1111111</foobar> </properties> <build><plugins><plugin><groupid>org.apache.maven.plugins</groupid><artifactid>maven-antrun-plugin</artifactid><version>1.1</version> <executions><execution> <phase>validate</phase><goals><goal>run</goal></goals> <configuration><tasks> <echo>foo = ${foo}</echo> <echo...

python - How to def a method with passing it a bool function? -

i have task should program in python. should have class named tasks. can class tasks: code. class should have 4 method, 1 method needed pass logical function it, go on of elements in inf named file , count appropriate values in inf file, , should write out. question how can define function parameter should defined logical function? here example: there file should call tasks class, example name "test". has following code: def odd(x): if x % 2 != 0 : return true else: return false task = tasks("in") //here have problem don't know how can open file tasks' constructor. print task.count(odd) could please provide me solution this? edit1: if inf file have following values: 30 25 30 21 19 then task.count(odd) should print 3 there's nothing magical function's name, can pass function argument, invoke argument name in function. for example, part of solution might include class task: def count(self, fun...

c# - Get Method by CustomAttribute and then Invoke -

with massive learning curve custom attributes , reflection, still seem struggling. me out one? basically want invoke method based on it's attribute. this customattribute decorates method (it ever 1 method): [controllername(name="blog")] public static string getcontent(string controllername, string singleitemname = "") { string returnval = null; //get class type type thistype = typeof(contentfacade); //get member info system.reflection.memberinfo info = typeof(contentfacade); loop through attributes foreach (object attrib in info.getcustomattributes(true)) { //if attribute matches param controller name //then invoke if (attrib == controllername) { //get method attribute not method name //i dont want method methodname methodinfo themethod = thistype.getmethod(controllername); //return value html end user returnval = (string)th...