Posts

Showing posts from January, 2015

javascript - Function to change the image onload -

i wondering how possible specific image on page , replace other image on page load. for example, have on site : <img src="/content/public/1472.png"> i want find image , change below value on page load : <img src="/content/public/1473.png"> use attr() or prop() in ready function : $(function(){ $('img[src="/content/public/1472.png"]').attr('src', '/content/public/1473.png'); //$('img[src="/content/public/1472.png"]').prop('src', '/content/public/1473.png'); }) hope helps. $(function(){ console.log('before : '+$("img").attr('src')); $('img[src="http://www.drodd.com/images15/1-4.png"]').attr('src', 'http://www.drodd.com/images15/2-4.png'); console.log('after : '+$("img").attr('src')); }) <script src="https://ajax.googleapis.com/ajax/libs/jque

Spark 1.6.2's RDD caching seems do to weird things with filters in some cases -

i have rdd: avrorecord: org.apache.spark.rdd.rdd[com.rr.eventdata.viewrecord] = mappartitionsrdd[75] i filter rdd single matching value: val sitefiltered = avrorecord.filter(_.getsiteid == 1200) i count how many distinct values siteid. given filter should "1". here's 2 ways without cache , cache: val basic = sitefiltered.map(_.getsiteid).distinct.count val cached = sitefiltered.cache.map(_.getsiteid).distinct.count the result indicates cached version isn't filtered @ all: basic: long = 1 cached: long = 93 "93" isn't expected value if filter ignored (that answer "522"). isn't problem "distinct" values real ones. seems cached rdd has odd partial version of filter. anyone know what's going on here? i supposed problem have cache result of rdd before doing action on it. spark build dag represents execution of program. each node transformation or action on rdd . without cache ing rdd , each action

javascript - Localstorage keeps resetting -

i calling data mysql in rows, , each id placed in seperate div. once customer clicks on 1 of these div's (url) div should remove , place in "seen" tab. removing , adding class. this works perfectly, if going example id 15 1 removing new 'seen'. first 1 resetting , moves 'new' again. how can make sure every time click on new url in row collects 1 in 'seen' tab? php: <?php while($row = mysql_fetch_array($result, mysql_assoc)) { // output data of each row $idselection = $row["entryid"]; echo "<div class='one-block-info' style='width: 33%; float: left; margin-top: 10px; margin-bottom: 10px; text-align: center; border: 1px solid black;'><div class='hide_div' style='font-size: 17px; color: #6a8f3b;'><br /><a class='tag-link new' style='color: rgb(106, 143, 59);' href='/offerte-formulier?id=". $idselection ."' target='_self'>id

java - Spring Boot Upload BootRepackage Executable Jar -

i using spring-boot develop new project. in build.gradle file, using 'bootrepackage.classifier', can separately generate default jar of project , executable jar generated using spring boot. publish both jars, running issues. using uploadarchives task upload jars nexus maven repository. can default jar upload. here part of build.gradle file pertains uploading archive: bootrepackage.classifier = 'exec' jar { basename='default' version = '1.0.0' } uploadarchives { repositories { mavendeployer { repository(url: "repositoryurl") { authentication(username: "username", password: "password") } pom.groupid = 'groupid' pom.version = "1.0.0" } } } am missing something? there couple solutions elsewhere on so: publishing spring boot executable jar artifact : artifact(file("$builddir/$pr

python - Using conditional expressions and incrementing/decrementing a variable -

how put if statement conditional expression , how increment/ decrement variable? num_users = 8 update_direction = 3 num_users = if update_direction ==3: num_users= num_users + 1 else: num_users= num_users - 1 print('new value is:', num_users) the correct statement be: num_users = num_users + 1 if update_direction == 3 else num_users - 1 for reference, see conditional expressions .

python - Blob detection using OpenCV -

Image
i trying white blob detection using opencv. script failed detect big white block goal while small blobs detected. new opencv, , doing wrong when using simpleblobdetection in opencv? [solved partially, please read below] and here script: #!/usr/bin/python # standard imports import cv2 import numpy np; matplotlib import pyplot plt # read image im = cv2.imread('whiteborder.jpg', cv2.imread_grayscale) imfiltered = cv2.inrange(im,255,255) #opening kernel = np.ones((5,5)) opening = cv2.morphologyex(imfiltered,cv2.morph_open,kernel) #write out filtered image cv2.imwrite('colorfiltered.jpg',opening) # setup simpleblobdetector parameters. params = cv2.simpleblobdetector_params() params.blobcolor= 255 params.filterbycolor = true # create detector parameters ver = (cv2.__version__).split('.') if int(ver[0]) < 3 : detector = cv2.simpleblobdetector(params) else : detector = cv2.simpleblobdetector_create(params) # detect blobs. keypoints = de

css3 - facing animation issue while creating typing cursor effect in CSS steps() -

i want create typing cursor effect in css using steps() after playing quite while couldn't find why behaving abnormally, want cursor appear , disappear after specified time period. appears , fades half way. causing behavior? please have @ fiddle. https://jsfiddle.net/jl1f4rzc/ i preffer not use steps this, instead use percents in animation this: .blink { animation : blink 1s 0s infinite; animation-direction: alternate; } @keyframes blink { 0% { border-right:2px solid #000; } 70% { border-right:2px solid #000; } 75% { border-right: 2px solid transparent; } 100% { border-right: 2px solid transparent; } } fiddle updated

python 3.x - How to create a sub frames with a specific layout? -

Image
i'm aiming make login program part confuses me how make frames.i need 3 different frames neither know how make frame other this: mainframe = ttk.frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(n, w, e, s)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) and can make labels , widgets using single mainframe. far making one, beyond me. need know place widets inside of each frame , after creating frames don't know how place stuff on grid. go overall grid, or change after making grid. i'm using following layout making frame. i'm hoping crash course in frames. information i've gathered doesn't make sense me, after tried put code. i've got coding part down not frame part. #import tkinter make gui tkinter import * tkinter import ttk import codecs def login(*args ): file = open("rot13.txt", "r") lines = file.readlines() uname = user.get() pword =

python - Pandas: how to compute the rolling sum of a variable over the last few days but only at a given hour? -

i have dataframe follows df = pd.dataframe({ 'x' : np.random.randn(50000)}, index=pd.date_range('1/1/2000', periods=50000, freq='t')) df.head(10) out[37]: x 2000-01-01 00:00:00 -0.699565 2000-01-01 00:01:00 -0.646129 2000-01-01 00:02:00 1.339314 2000-01-01 00:03:00 0.559563 2000-01-01 00:04:00 1.529063 2000-01-01 00:05:00 0.131740 2000-01-01 00:06:00 1.282263 2000-01-01 00:07:00 -1.003991 2000-01-01 00:08:00 -1.594918 2000-01-01 00:09:00 -0.775230 i create variable contains sum of x over last 5 days ( not including current observation ) only considering observations fall @ exact same hour current observation. in other words: at index 2000-01-01 00:00:00 , df['rolling_sum_same_hour'] contains sum values of x observed @ 00:00:00 during last 5 days in data (not including 2000-01-01 of course). at index 2000-01-01 00:01:00 , df['rolling_sum_same_hour'] contains sum of of x observed @ 00:00:0

java - Why when you call method of parent from a second inheritance is from first inheritance? -

i confused: i run example , results 2. i can't find explication: so have f object. called x.fun(x) here , copy of f object sent fun method. here have fun(d d) have copy of x in d object. d.method() calling me d method return 1; however result 2...what wrong? import java.util.*; import java.lang.*; import java.io.*; class d {int method() {return 1;}} class e extends d { int method() { return 2; } } class f extends e { int fun(d d){ return d.method(); } } /* name of class has "main" if class public. */ class test2 { public static void main (string[] args) { f x = new f(); system.out.println(x.fun(x)); } } the d.method() method call executes method fits runtime type of d . in case, runtime type of d f (since create in main instance of f , pass fun() method). f extends e , , e overrides method() . therefore d.method() calls e 's implementation of method() , returns 2.

python - Field content not always visible in kivy Textinput -

Image
i encountering strange/unexpected behaviour when displaying content in textinput field (initially used new record input - subsequently show record data). data available in dictionary , assigned textinput fields. short data characters hidden sometimes: it seems cursor @ end of string , characters @ left side , 'hidden'(?) behind label. after mouseclick in field , arrow left, characters appear. what wrong in kv definitions? : boxlayout: orientation: "horizontal" height: 25 size_hint_y: none label: id: _socialsource_label size_hint: 0.35,1 text: "social access token:" size: self.texture_size halign: 'left' valign: 'middle' font_size: 14 color: .3,.3,.3,1 textinput: id: socialsource padding: 4,2,4,0 size_hint: 0.65,1 font_size: 14 multiline: false readonly: false text_size: self.width, none

xcode8 - How do you download the iOS 10 Documentation in Xcode 8 GM Release? -

cannot seem find documentation location or download if that's possible. you don't need download anymore. it's included in sdks. source: wwdc 2016 - platforms state of union

node.js - Webpack not found, deploying to Heroku -

very new node , deploying heroku. have basic react app set , attempting deploy heroku. have pushed, app failing. when @ logs see sh: 1: webpack: not found (full log here ) i'm not what's going on, believe has package.json? starter template using such: { "name": "express-react-redux-starter", "version": "1.0.0", "description": "starter express, react, redux, scss applications", "scripts": { "dev": "webpack-dev-server --config ./webpack/webpack-dev.config.js --watch --colors", "build": "rm -rf dist && webpack --config ./webpack/webpack-prod.config.js --colors", "start": "port=8080 node start ./server.js", "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test", "test:watch": "npm run test -- --watch",

linux - In tar compressed file is there a way to add comment or description -

is way add comment or description in tar file? idea add information without need of extracting whole archive - super fast, such "this archive blah blah" example: tar --comment "this tar blah blah" -cjvf mytarfile.tar.bz2 directory_that_i_want_to_compress update found want using zip , unzip instead. can store comment in file within zip archive , retrieve file without need of extracting whole archive. fast. zip -r my.zip my_dir unzip -p my.zip my_dir/mycomment.txt there no comment field in tar format. you have add file tar archive (e.g. readme or comment file). adding file compressed tar archive (.tar.bz2 in example), not fast. straightforward way decompress, remove terminating last 1024 bytes of zeros, append tar header , contents final file add, , append 1024 bytes of zeros terminate. recompress. for .tar.gz, possible reduce work decompressing find last deflate block or blocks containing last 1024 bytes (and some), , recompressing when appe

Selenium Best Practice: One Long Test or Several Successively Long Tests? -

in selenium find myself making tests ... // test #1 login(); // test #2 login(); gotopagefoo(); // test #3 login(); gotopagefoo(); dosomethingonpagefoo(); // ... in unit testing environment, you'd want separate tests each piece (ie. 1 login , 1 gotopagefoo , etc.) when test fails know went wrong. however, i'm not sure practice in selenium. it seems result in lot of redundant tests, , "know went wrong" problem doesn't seem bad since it's clear went wrong looking @ step test on. , takes longer run bunch of "build up" tests takes run last ("built up") test. am missing anything, or should have single long test , skip shorter ones building it? i have built large test suite in selenium using lot of smaller tests (like in code example). did same reasons did. know "what went wrong" on test failure. this common best practice standard unit tests, if had on again, go second approach. larger built-up tests smaller

swift - How do I unsubscribe from an observable? -

if have looks this: func foo() -> observable<foo> { return observable.create { observer in // ... } } func bar() { foo().observeon(mainscheduler.instance) .subscribenext { // ... } .adddisposableto(disposebag) } if want unsubscribe observable later on in bar , how that? update i'm aware can call dispose , according rxswift docs : note not want manually call dispose; educational example. calling dispose manually bad code smell. so unsubscribe not implemented? i've gone spelunking through rxswift code, , extent can understand what's going on, doesn't disposable returned subscribe methods ever useful functionality (other disposing). you add observable returned foo disposebag . disposes subscription when it's deallocated. can "manually" release disposebag calling disposebag = nil somewhere in class. after question edit: want selectively unsubscribe observab

Is it possible to start the OrientDb server without using reflection? -

i'm running orientdb 2.2.6 in embedded mode. have grant security permissions code securitymanager allows run. 1 permission particularly prefer not grant ("java.lang.reflect.reflectpermission" "suppressaccesschecks"). instead of granting permissions, rather start server without requiring reflection. there way start orientdb server in embedded mode without reflection? here configuration: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <orient-server> <network> <protocols> <protocol implementation="com.orientechnologies.orient.server.network.protocol.binary.onetworkprotocolbinary" name="binary"/> </protocols> <listeners> <listener protocol="binary" socket="default" port-range="2424-2430" ip-address="0.0.0.0"/> </listeners> </network> <users> <user resources=

angular 2 npm start - how to proxy API requests to another server? -

how can proxy ajax calls different server using npm start. npm start --proxy http://localhost:8080 doesn't work i did ... 1 option add file: bs-config.js : var proxymiddleware = require('http-proxy-middleware'); module.exports = { server: { middleware: { 1: proxymiddleware('/api', { target: 'http://localhost:8081/', changeorigin: true }) } } }; also run: npm install --save-dev http-proxy-middleware

ruby on rails - How to create extension in PostgreSQL db -

i want create extension, called unaccent , when create database. i know can achieved database command: create extension unaccent however, don't know put this. db postgresql, , working on rails application. you can use postgresql client, example, default psql connect database , should able run create extension if user has enough privileges.

javascript - Nodejs error: unable to get local issuer certificate -

i trying use exchange api (send mails, , create events) nodejs program. i started trying node-ews npm package, when attempted make request, got exception: "unable local issuer certificate" "unable_to_get_issuer_cert_local". i tried figure out while, when failed thought i'd try different approach - sending soap request. i installed npm package easysoap when tried make request got same error. it seems i'm going through troubles in order make work. simple task perform, using .net library in c#. missing? is there better method of doing that? thank in advance. **edit: i have tried use fiddler try , see response exchange server, don't see request.

c# - How do you automate the creation of a dataset within the .NET SDK for Azure Data Factory? -

i using microsoft azure data factory .net sdk in order automate dataset creation large number of tables. a method within .net console application provides me ability create input , output datasets, based on specified table name: createinputdataset(string table_name, datafactorymanagementclient client) { client.datasets.createorupdate(resourcegroupname, datafactoryname, new datasetcreateorupdateparameters() { dataset = new dataset() { properties = new datasetproperties() { structure = new list<dataelement>() { //todo: autogenerate columns , types new dataelement() {name = "name", type = "string" }, new dataelement() {name = "date", type = "datetime" } } }... currently, dataset creation accomplished through stored p

c# - Dynamic Property Binding in EF? -

apparently, same columns value-type differs across environments same database entity (table) & refuse update common type - don't ask why! i using entity framework (version 6.1.3) alongside unit of work data-access. and, can guess, getting errors because dev & qa database definitions not match same column. the news: not save these particular tables - query particular tables. sample model: there more columns this. public partial class transactions { [key] public int transactionid { get; set; } public float amount { get; set; } //<-- type differs between database environments } my question: is there way dynamically bind value column in entity framework? or, can treat dynamic under-the-hood...and transform expected type constant model? optimally - , clear: define property concretely, , have entity framework "convert" unknown type & concrete type - under-the-hood. any appreciated. if types of columns compatible (i

javascript - Change the URL with a GET method -

is there way submit selected fields url method ? by clicking on button, want put string on url, using method. expected result: test.html?test=11,13,21,34&somewords=1,2,3&demo=2 yes! example : function submit() { var test = document.getelementbyid('test').value; var demo = document.getelementbyid('demo').value; var somewords = document.getelementbyid('somewords').value; var url = 'test.html?test=' +test + '&somewords=' + somewords + '&demo=' + demo; console.log(url); // test.html?test=1,2,3,4&somewords=noting&demo=2 // code request } html <input type="text" value="1,2,3,4" id="test"> <input type="text" value="noting" id="somewords"> <input type="text" value="noting" id="dummy"> <input type="text" value="2" id="demo"> <b

java - Override eclipse project name? -

it appears sbteclipse plugin generates name in .project playframework project name (also folder name). is there way override this? have 2 apps i'm developing, both named 'web' (but in different nested project/trunk/etc folders). going default, end 2 projects named 'web' in eclipse, doesn't work. if there's no way override eclipse project name, suggestions on better project structure/management avoids issue? duh, realized playframework project name first line in build.sbt file (name := """web"""). changing line resulted in sbteclipse outputting different project name. thanks comments.

android - Firebase and Admob package name not updated -

Image
yesterday updated app package name "com.example.xxx" "com.stable.xxx" , uploaded app on google play. seems work fine saw on firebase , admob package name old one: "com.example.xxx". should change it? , how? should recreate new firebase , admobs project? seems risky me.... firebase: admob: i had same problem , way change contacting firebase service. by way work fine if there 2 different package name can leave have.

.htaccess - Unable to get rid of 302 redirect -

i have following in htaccess file: # use front controller index file. serves fallback solution when # every other rewrite/redirect fails (e.g. in aliased environment without # mod_rewrite). additionally, reduces matching process # start page (path "/") because otherwise apache apply rewriting rules # each configured directoryindex file (e.g. index.php, index.html, index.pl). directoryindex app.php <ifmodule mod_rewrite.c> rewriteengine on # determine rewritebase automatically , set environment variable. # if using apache aliases mass virtual hosting or installed # project in subdirectory, base path prepended allow proper # resolution of app.php file , redirect correct uri. # work in environments without path prefix well, providing safe, one-size # fits solution. not need in case, can comment # following 2 lines eliminate overhead. rewritecond %{request_uri}::$1 ^(/.+)/(.*)::\2$ rewriterule ^(.*) - [e=base:%1] # sets h

javascript - I can't seem to figure out how to manipulate the browser history -

so trying change data based on navigation of user. have 6 main category pages. 6 main category pages, have 12 sub categories user can select. what trying achieve: let's user selects category one. the user selects sub-category 1 category 1. the sub-category page shown , removes data not related category 1. the user selects sub-category 2 sub-category 1 , removes data not related category 1. the user selects sub-category 3 sub-category 2 , removes data not related category 1. so can category 1 sub-category 1 how lets says sub-category 1 2 , 2 3...n times....? each sub-category has know main category last selected. i have looked @ can't seem find solution. window.location.hash history.pushstate("","",""); document.referrer typically bad design , understand limited can on server side. trying develop work around.... after trying work these , not getting desired behavior, able find best solution through several hours of r

javascript - Redirect html when fill the input sucess -

i using form connector server in order when put correct user , password connects form of web , redirects ip when put wrong password or wrong user dont want redirect stay in same page. <div class="container"><!-- container --> <div class="row"><!-- row --> <div class="col-md-4"></div> <div class="col-md-4"><!-- col 3 --> <form class="login" autocomplete="off" method="post" action="http://139.59.200.233:8080/track/track"> <h5>servidor 1</h5> <h2 class="title">acceso plataforma gps</h2> <input id="accountloginfield" type="hidden" value="occidentegps" name="account" required> <input type="text" name="user" placeholder="usuario" autofocus required/> <i class

vb.net - ExecuteNonQuery returns -1 (incorrectly) -

i inherited old vb website uses executenonquery modify passwords. in our production environment, sql server 2008 r2, i've had recent reports of broken functionality. turns out executenonquery returning -1 when in fact data getting updated (a single row). when copied data our dev environment, rows affected 1 expected. have different service packs applied (4xxx vs 6xxx) , wonder if issue? modified code use executescalar inspect rowcount, , working. shouldn't have so. insight? have idea how long has been broken. here's original code, returns -1 erroneously. not calling stored procedure , there no triggers involved. dim cmd sqlcommand = new sqlcommand("update usermaster " & _ " set password = @password, lastpasswordchangeddate = @lastpasswordchangeddate " & _ " username = @username , applicationname = @applicationname ", conn) cmd.parameters.add("@password", sqldbtype.varchar, 255).value

ssh - Docker alpine image's basic commands are not working -

docker started produce weird bugs when using few simple alpine based containers. 2 of these problems are: rc-update not found when trying use it after installing openssh package, there nothing in /etc/ssh or there no /etc/init.d/sshd start/restart service to avoid confusion checked out used container serves simple ssh server. can executing: git clone https://github.com/chamunks/alpine-openssh.git after go alpine-openssh directory , build container with: docker build -t alpine-openssh . mine produces following: sending build context docker daemon 125.4 kb step 1 : alpine ---> 4e38e38c8ce0 step 2 : maintainer chamunks <chamunks@gmail.com> ---> running in c21d3fa28903 ---> f32322a2871a removing intermediate container c21d3fa28903 step 3 : copy sshd_config /etc/ssh/sshd_config ---> 392364fc35ce removing intermediate container 4176ae093cb8 step 4 : add https://gist.githubusercontent.com/chamunks/38c807435ffed53583f0/raw/ec868d1b45e248eb517a134

parsing - Invalid Json web token in Go -

i trying make json web token authentication system go cant seem parsing of web token working. error occurs in following function. func requiretokenauthentication(rw http.responsewriter, req *http.request, next http.handlerfunc) { authbackend := initjwtauthenticationbackend() jwtstring := req.header.get("authorization") token, err := jwt.parse(jwtstring, func(token *jwt.token) (interface{}, error) { if _, ok := token.method.(*jwt.signingmethodrsa); !ok { log.println("unexpected signing method") return nil, fmt.errorf("unexpected signing method: %v", token.header["alg"]) } else { log.println("the token has been returned") return authbackend.publickey, nil } }) log.println(token) log.println(token.valid) if err == nil && token.valid && !authbackend.isinblacklist(req.header.get("authorization")) { next(rw, req) } else { rw.writeheader(http.statusunautho

Hosting RESTFul api on sub-subdomain in heroku? -

i developing app on ruby on rails created restful json api hosted on subdomain "api". when testing locally prax on linux machine, able test endpoints routing various endpoints "api.app_name.dev/resources" "api.app_name.dev/resources/1". now, have been instructed host rails application on free heroku account time being other developers can test api. however,i can't work. main application subdomain heroku app itself.the url main application "app_name.herokuapp.com". can't connect "api.app_name.herokuapp.com" sub-subdomain of application. is there way can test api heroku? or possibly workaround ?? it sounds need set correct subdomain constraint in routes, namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api.app_name' }, path: '/' ... thing end also, if helps, check this if of help

sql server - How to properly connect to database in vb -

i need on codes and/or connection.i'm getting error says: an unhandled exception of type 'system.invalidoperationexception' occurred in system.data.dll additional information: executereader requires open , available connection. connection's current state closed. in code:(line 4) cmd.connection = cn cmd.commandtext = "select id, lastname, firstname tblmembers id = @id" cmd.parameters.add(new sqlclient.sqlparameter("@id", sqldbtype.int)).value = dg1.item(0, e.rowindex).value dr = cmd.executereader if dr.hasrows() dr .read() txtlname.text = dr("lastname") txtfname.text = dr("firstname") end end if but if try open connection. happens. an unhandled exception of type 'system.invalidoperationexception' occurred in system.data.dll additional information: connection not closed. connection's current state open. with code:(line 1) cn.op

wireless - MIMO system Channel Information H Matrix in Ideal and purely theoretical case -

in mimo system , channel information stored in h matrix. example : symbol sent first antenna in, , response noted 3 receivers. other 2 antennas same thing , new column developed 3 new responses. enter image description here here in output variations because of many constraints fading , multi-path , . if channel ideal time invariant;signal paths independent; signals uncorrelated. how h-matrix (channel matrix ) looks ? there theoretical approach .

c# - Naudio and Syn speech null reference error when reading from memory stream -

i'm pretty sure i'm doing right can't seem figure out causing error or how fix it. appreciated. code below error below that. code. posted of since not know relevant error. public class voicestuff { public waveinevent waveinstream; private static streamspeechrecognizer _recognizer; wavefilewriter writer; private memorystream mem; public void record() { waveinstream.numberofbuffers = 2; waveinstream.startrecording(); recognize(); } public void recognize() { console.readkey(); waveinstream.stoprecording(); } public voicestuff() { logger.logreceived += logger_logreceived; waveinstream = new waveinevent(); waveinstream.numberofbuffers =2; waveinstream.waveformat = new waveformat(16000, 1); mem = new memorystream(); writer = new wavefilewriter(mem, waveinstream.waveformat); waveinstream.dataavailable += ondataavailable; var modelpath = pat

Finding the index of an item given a list containing it in Python -

for list ["foo", "bar", "baz"] , item in list "bar" , what's cleanest way index (1) in python? >>> ["foo", "bar", "baz"].index("bar") 1 reference: data structures > more on lists

windows - Search for specific lines from a file -

i have array contains data text file. i want filter array , copy information array. grep seems not work. here's have $file = 'files.txt'; open (fh, "< $file") or die "can't open $file read: $!"; @lines = <fh>; close fh or die "cannot close $file: $!"; chomp(@lines); foreach $y (@lines){ if ( $y =~ /(?:[^\\]*\\|^)[^\\]*$/g ) { print $1, pos $y, "\n"; } } files.txt public_html trainings , events general office\resources general office\travel general office\office opperations\contacts general office\office opperations\coordinator operations public_html\accordion\dependencies\.svn\tmp\prop-base public_html\accordion\dependencies\.svn\tmp\props public_html\accordion\dependencies\.svn\tmp\text-base the regular expression should take last 1 or 2 folders , put them own array printing. a regex can picky this. far easier split path components , count off many need. , there tool fits ex

angular - How to load resolve router in main component? -

can me please resolve router question. i have 1 main module "app.module" consists of few submodules. app.module has app.routers file describes lazy loading submodules. the file app.routers looks this: .. { path: "sign-up", // sing new users loadchildren: "app/signup/sign-up.module" }, { path: "home", // see home page loadchildren: "app/home/home.module" }, .. etc .. i want use resolve router load data server , want in app.component when app.component loading , before submodules load. for example if www.myapp.com/home loads want data resolve router in app.component (in ngoninit guess) no in submodule.component. is possible describe path in app.routers load before statments in app.routers? thanks in advance! updated export const routes: routes = [ { path: "login", // sign in or see information current logged user loadchildren: "app/login/login.module" },

c# - Dapper For MySQL Query<T>(string sql) sql has a custom variables(@rowNum) contains a special character @ -

here question.i want user page list , not want use limit.then use sql this: select * (select @rownum:=@rownum+1 rownum,user (select @rownum:=0) r,user user.name=@name order user.name) rownum>=1 , rownum<=10 .net code this: connection.query<t>(sql, new{name="name"}, transaction, true,commandtimeout); and when run program,it throw exception: message: "object reference not set instance of object.", data: { }, innerexception: null, stacktrace: " @ mysql.data.mysqlclient.mysqlconnection.get_serverthread() @ mysql.data.mysqlclient.mysqlconnection.abort() @ mysql.data.mysqlclient.mysqlcommand.executereader(commandbehavior behavior) @ dapper.sqlmapper.executereaderwithflagsfallback(idbcommand cmd, boolean wasclosed, commandbehavior behavior) @ dapper.sqlmapper.<queryimpl>d__124`1.movenext() @ system.collections.generic.list`1..ctor(ienumerable`1 collection) @ system.linq.enumerable.tolist[tsource](ienumerable`1 source) @ dapper.sqlmappe

algorithm - finding 10 largest integers in an array in O(n) time -

let s set of n integers stored in array (not sorted). design algorithm find 10 largest integers in s (by creating separate array of length 10 storing integers). algorithm must finish in o(n) time. i thought maybe answer using count sort , adding last 10 elements new array. apparently wrong. know better way? method 1: can use findmax() algorithm find max number in o(n) , if use 10 time : 10 * o(n) =o(n) each time find max num put in new array , ignore next time use findmax(); method 2: you can use bubble 10 times: 1) modify bubble sort run outer loop @ 10 times. 2) save last 10 elements of array obtained in step 1 new array. 10 * o(n) =o(n) method 3: you can use max heap : 1) build max heap in o(n) 2) use extract max 10 times 10 maximum elements max heap 10 * o(logn) o(n) + 10 * o(logn) = o(n)

apache - htaccess If...Else always selects Else -

i set environment variable in httpd-vhosts.conf setenv early_var 1 i try setting special rules based on value in .htaccess <if "%{env:early_var} == '1'"> setenv test_var if_branch </if> <else> setenv test_var else_branch </else> i expect test_var environment var equal if_branch . in php var_dump(getenv('early_var')); // string '1' var_dump(getenv('test_var')); // string 'else_branch' i tried setting early_var in .htaccess above if/else, both using setenv , setenvif . else branch executed. why this? apache 2.4 without using expression i.e. if/else directives can this: # set early_var 1 setenvif host ^ early_var=1 # if early_var 1 set test_var if_branch setenvif early_var ^1$ test_var=if_branch # if early_var not 1 set test_var else_branch setenvif early_var ^(?!1$) test_var=else_branch this work older apache versions i.e. <2.4 edit: in apache config or v

Rename local GIT branch breaks Git Flow in SourceTree -

while using sourcetree renamed 2 main local branches (master , develop). however, when click on git flow icon start new feature, tells me repository needs initialized (even though has been been initialized). additionally, repository -> git flow -> initialize repository menu item greyed out. i tried putting names of branches , git flow works again! so, how rename branches , keep git flow working? shut sourcetree, , edit file .git/config (within repository) updating [gitflow "branch"] section. .git directory hidden within file explorer. the default this: [gitflow "branch"] master = master develop = develop and should change match new branch names, i.e.: [gitflow "branch"] master = yournewmasterbranchname develop = yournewdevelopbranchname then restart sourcetree

webpack - rebuild by updating files under node_modules with #module-source-map makes heap out of memory -

node@6.2.2 webpack@1.12.15 devtool: #module-source-map when update files under project, rebuild fast but when update files under node_modules, takes lot of time(even display 1/1 build modules) , makes heap out of memory here's logs <--- last few gcs ---> 277985 ms: mark-sweep 1218.5 (1435.0) -> 1213.7 (1435.0) mb, 1232.2 / 0 ms [allocation failure] [gc in old space requested]. 279006 ms: mark-sweep 1213.7 (1435.0) -> 1213.7 (1435.0) mb, 1020.8 / 0 ms [allocation failure] [gc in old space requested]. 280087 ms: mark-sweep 1213.7 (1435.0) -> 1213.6 (1435.0) mb, 1080.4 / 0 ms [last resort gc]. 281358 ms: mark-sweep 1213.6 (1435.0) -> 1213.6 (1435.0) mb, 1271.5 / 0 ms [last resort gc]. <--- js stacktrace ---> ==== js stack trace ========================================= security context: 0xc3785fc9e59 <js object> 1: node [/users/jared/project/module-name/node_modules/.npminstall/webpack-core/0.6.8/webpack-core/lib/originals

Python Stack without using Pop function -

i learning python , have assignment better understanding of "class" , using "stack." the requirements follows: -define class implements stack numerical values. -cannot use built-in pop function -function push should check if value numerical -function print_stack should print values in stack, recent (on top) first -function isempty should return true if stack empty, false otherwise here work far: class stack(): def __init__(self): self.items = [] def push(self, item): self.items.append(item) def isempty(self): return (self.items == []) #can use return not self think? def print_stack(self): print self.items this first class in programming i'm sorry if understanding poor. i'm not looking outright write me. want understand how go , receive pointers on need lacking in understanding if obvious. my questions follows: 1) how can test if pushing numerical value? on first thought, use try/

c++ - How can I make a function that prints out all repeated integers in an array? -

i have been trying make function prints out integers represented multiple times in array. following made print out first repeated integer(5), can't seem edit recognize second pair(6). #include <iostream> #include <ctime> #include <cstdlib> using namespace std; const int size = 5; struct pair{int one,two;}; pair get(int hand[]); int main() { int hand[size] = {5,6,5,2,6}; // input pair number = get(hand); cout << "pairs: " << number.one << ' ' << number.two << endl; // should output: pairs: 5 6 return 0; } pair get(int hand[]) { int = 0, b = 0; (int i=0;i<size;i++) { (int j=0;j<size;j++) { if (hand[i] == hand[j]) { = hand[i]; } } } pair temp = {a,b}; return temp; } your code has 3 issues: you never print number of matches num . instead of return hand[i]; should either p

javascript - Coffee Script not fire on page change, but works on page load. [Rails 5] -

i using coffee script in rails project, problem works when load(refresh) page instead when page renders, should work on page view change. here script using: facebook.js.coffee jquery -> $('body').prepend('<div id="fb-root"></div>') $.ajax url: "#{window.location.protocol}//connect.facebook.net/en_us/all.js" datatype: 'script' cache: true window.fbasyncinit = -> fb.init(appid: env["app_id"], cookie: true) $('#sign_in').click (e) -> e.preventdefault() fb.login (response) -> window.location = '/auth/facebook/callback' if response.authresponse $('#sign_out').click (e) -> fb.getloginstatus (response) -> fb.logout() if response.authresponse true you can try "turoblinks:load" ready = -> $('body').prepend('<div id="fb-root"></div>') $.ajax url: "#

git log - How to use git to see changes to all files since their initial creation? -

i'm trying see edits i've made since initial commit. this happens lot when import , control code vendor. so workflow this: git add/commit original make edits git commit go 2 i'd see record of of my changes files since first created. git log -p -- <file> doesn't quite work because file's initial creation shows 1 giant additional of lines. so: commit 82abdc4cc52d70dcabdec4b987632f226a1e8bc4 author: greg bell <greg@> date: fri aug 26 07:13:22 2016 +1000 initial import vendor diff --git a/vendor/source.h b/vendor/source.h new file mode 100644 index 0000000..baf6d8a --- /dev/null +++ b/vendor/source.h @@ -0,0 +1,221 @@ +/* + * error codes returned blah. + * + * copyright (c) 1998-2000 blah blah + * + * program free software; can redistribute and/or modify + * under terms of gnu general public license published + * free software foundation; either version 3 of license, or + * (at option) later version. + * + * program distribut

sql server - MSSQL + Laravel: "Error by converting varchar to bigint" -

actually, can't insert data table big number. primary key has type of bigint, when try insert row i'm getting error. same thing happens when try manually heidisql. it seems going insert string/varchar/nvarchar data bigint type column. please check data.

java - Add properties file for custom plugin in Nutch -

i'm beginner in nutch. have done crawling, created custom plugin based on different tutorials. particular task, java class have use properties file named sample.properties tasks. i've getting nullpointerexception on following code. properties property = new properties(); inputstream input = getclass().getresourceasstream("sample.properties"); property.load(input); i don't know place properties file, because doesn't moves compiled jar after compiling ant. i'm placing @ same directory of java class. appreciated. i solved adding copy task in plugin's build.xml : <copy todir="${build.classes}"> <fileset dir="${src.dir}" includes="**/*.properties"/> </copy> it copies properties file compiled jar , issue solved. cheers !! edit : i used method also. moved properties file conf directory , input in parsefilter by, properties property = new properties(); inputstrea

How to prevent other access to my firebase -

how prevent other users can use firebase url? must secure domain? first of all, understand cannot secure url on internet according origin domain--malicious users can lie. securing origin domains useful in preventing cross-site spoofing attacks (where malicious source pretends site , dupes users logging in on behalf). the news users prevented authenticating unauthorized domains start. can set authorized domains in forge: type firebase url browser (e.g. https://instance.firebaseio.com/ ) log in click on auth tab add domain list of authorized requests origins select "provider" want use , configure accordingly now secure data, go security tab , add security rules. starting point follows: { "rules": { // authenticated users can read or write firebase ".read": "auth !== null", ".write": "auth !== null" } } security rules big topic. want get speed reading overview , watching vid

php - Twilio Programmable SMS from number behaving incorrectly -

i using twilio programmable sms api in php. during testing sms, sometime received sms number , sometime receiving sms short code have passed number in api. my code is $client = new services_twilio($account_sid, $auth_token); $client->account->messages->create(array( 'to' => "+xxxxxxxxxxx", 'from' => "+xxxxxxxxxxx", 'body' => "tomorrow's forecast in financial district, san francisco clear.", )); so there anyway receiver receive sms passed number receiver can reply sms on number.

javascript - Changing values with jQuery -

i have following: <span class="label-info">3</span> i have following jquery var replaceit = $(this).closest(':has(.label-info)').find('.label-info').text(); the value of variable single whole number not 3: ie: 1, 2, 3, 4, 5. i have tried numerous ways , cannot value change. latest attempt was: return $(this).closest(':has(.label-info)').html().replace(replaceit, (replaceit - 1)); my end result, subtract 1 whatever current value of "lable-info" is, , switch new result. new span based on value of 3 become. <span class="label-info">2</span> how achieve this? updated code more clarity html: <div> <span class="lable-info">3</span> </div> <div> <a class="accept_friend">accept</a> </div> javascript: $(document).on("click", "a.accept_friend", function() { var checkvalue = $(this)

javascript - Saving remote image with PhantomJS -

i'm using phantomjs 2.1.1 on ubuntu without node or casper. fs.write('images/products/image.jpg', 'http://example.com/folder/someimage.jpg', 'w'); .. although creates 1xx byte jpeg files aren't images. there way download type of (jpeg, jpg, png) file phantomjs? a simpler way this, in phantomjs saves image itself: var page = require('webpage').create(); page.viewportsize = { width: 1280, height: 800 }; page.settings.useragent = 'mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.106 safari/537.36'; var url = "http://stackoverflow.com"; var selector = "#hlogo a"; page.open(url, function(){ settimeout(function(){ var cliprect = page.evaluate(function (selector) { return document.queryselector(selector).getboundingclientrect(); }, selector); page.cliprect = { top: cliprect.top, left: cliprect

compilation - Compile C source file using Command Prompt -

i having trouble while using codeblocks-16.01mingw-setup.exe - installed in file path not contain spaces - when trying compile @ comand prompt. beginner's guide recommended using following line in command prompt: gcc cards.c -o cards for source file named cards.c (on desktop). gives error 'gcc' not recognised internal or external command, operable program or batch file. when trying figure out, have found out can drag , drop files in command prompt , specifies path. doing gcc.exe taken f:\programare\codeblocks\mingw\bin\gcc.exe , adding c source file c:\users\dream\desktop\cards.c gives error as.exe - system error: program can't start because libintl-8.dll missing computer. try reinstalling program fix problem. i've reinstated codeblocks no avail. i've tried matching paths of compiler source file, bringing source code compiler was, again no avail. please me understand issue. must file named libintl-8.dll right there gcc.exe is, trying add in com