Posts

Showing posts from April, 2012

c# - undefined number of Or-operation on List -

i have list n-entries. list<myclass> result and have list n-filter options list<string> filters what want return result list filtered other list. for and-operation easy this: foreach (var filter in filters) { results = results.where(x => x.result == filter); } but how code or-operation? you can use where in combination any in case: results = results.where(x => filters.any(f => f == x.result)); https://msdn.microsoft.com/library/bb534972(v=vs.110).aspx others ways: //contains, see daxaholic's post results = results.where(x => filters.contains(x.result)); https://msdn.microsoft.com/library/bhkz42b3(v=vs.110).aspx //list extension method 'exists' results = results.where(x => filters.exists(f => f == x.result)); https://msdn.microsoft.com/library/bfed8bca(v=vs.110).aspx

internet explorer - Will this cause error for IE when using <!--[]>HTML GOES HERE<![]-->? -

Image
i notice can use condition-in-comment ie browsers , in ide such pycharm have code folding attached snapshot. so wonder if cause error ie when using syntax create collapsible code-region below snippet <!--your comment goes here--><!--[]> <script src="somesource"></script> <![]-->

Inserting weekends into SQL Server table -

Image
i'm trying insert yearly weekend details such date, dayname sql server table using following stored procedure alter procedure usp_addofficeholidays @paramname nvarchar(max) begin declare @year int, @firstdateofyear datetime, @lastdateofyear datetime -- can change @year year desire select @year = 2016 select @firstdateofyear = dateadd(yyyy, @year - 1900, 0) select @lastdateofyear = dateadd(yyyy, @year - 1900 + 1, 0) -- creating query prepare year data --declare dayn varchar(max) if (select count(*) tblweeksettings) < 1 begin ;with cte ( select 1 dayid, @firstdateofyear fromdate, datename(dw, @firstdateofyear) dayname union select cte.dayid + 1 dayid, dateadd(d, 1 ,cte.fromdate), datename(dw, dateadd(d, 1 ,cte.fromdate)) dayname cte date

ios - How to delete selected tables using persistentStoreCoordinator -

i'm working on ios app developed using objective-c. have added module users when login store details user. app having code, when press logout button deletes entities database. using code below. nsmanagedobjectcontext *managedobjectcontext = [self managedobjectcontext]; nserror *error = nil; // retrieve store url nsurl *storeurl = [[managedobjectcontext persistentstorecoordinator] urlforpersistentstore:[[[managedobjectcontext persistentstorecoordinator] persistentstores] lastobject]]; // lock current context [managedobjectcontext lock]; [managedobjectcontext reset];//to drop pending changes //delete store current managedobjectcontext if ([[managedobjectcontext persistentstorecoordinator] removepersistentstore:[[[managedobjectcontext persistentstorecoordinator] persistentstores] lastobject] error:&error]){ // remove file containing data [[nsfilemanager defaultmanager] removeitematurl:storeurl error:&error]; //recreate store in appdelegate method

java - How to edit custom message in log files while creation -

i using slf4j logging in application. have set 100 kb max size of log file. when, first time, application starts, log file created , modifying content user information. when next time, log file created in middle of application, user information not captured. there way enter own messages in log file whenever generated.

javascript - requestAnimationFrame not waiting for the next frame -

thanks checking in! so far know (it may wrong) javascript's requestanimationframe method works (a little bit) settimeout except doesn't wait amount of time next frame rendered. this can used lot of things, i'm trying achieve here css based javascript controlled fade effect. here code looks explanation: //this line makes element displayed block none //but @ point has opacity value of 0 this.addclass('element__displayed'); //here waiting frame added //display value takes effect window.requestanimationframe(function(){ //adding opacity: 1 fade effect this.addclass('element__visible'); }.bind(this)); my problem here though element has css transition set , waiting display value rendered, getting no transition, pops in. (it works if use settimeout(..., 1000/60), settimeout performance bottleneck compared requestanimationframe) please don't try give alternate solution fading effect because question not effect, why animationframe isn

codenameone - Can I turn off banner ads in code? -

i set app show banner ads @ bottom. there way turn off ads in code? want let users upgrade ad-free version of app. since presences of ads specified in build hints, there doesn't seem way turn them off once user buys ad-free version. need upload 2 versions of app? user need download ad-free version once make purchase? there no api exposure of banner ads builtin codename 1 there no way toggle them in code. can use interstitial ads or use code basis creating own banner ad support.

php - Double Quote and backslashes JSON reply -

using api provided supplier i've got json reply formatted : {"d":"{\"idproduct\":0,\"status\":0,\"errors\":[\"b_message_invalid_required_fields\"]}"} that causing in issue when trying deserialize jms (php) because content of d not considered object string. i have tried creating json php array , json_encode() , works great deserialize method : {"d":{"idproduct":123456,"status":1,"errors":["b_message_invalid_required_fields"]}} is possible remove useless backslashes , quotes side? seems supplier can not change format. it looks api returns a json string encoded json object . meaning, first need decode "outer" object, json-decode $obj['d'] , because it's json string. json_decode(json_decode($json)->d) obviously should fix api not return double-encoded json.

jquery - Html include another Html with onclick javascript is not working after page load -

for example, having 1st page html include header page html page 1 javascript <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script> $(function(){ $("#header").load("header.html"); }); </script> <div id="header"></div> header page <a href="#" data-toggle="dropdown" class="dropdown-toggle">booking <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a id="booking" href="#">new booking</a></li> <li id="cancel"><a href="url">cancellation</a></li> <li id="my_booking"><a href="url">my booking</a></li> </ul> </li> so problem is, in header page html having menu drop-down-list. during page loading, able click menu drop down list. once page

Android - Realm - Object delete - Object is no longer valid to operate on -

i'm trying delete item recyclerview populated realm database , i'm getting following error: java.lang.illegalstateexception: illegal state: object no longer valid operate on. deleted thread? assumptions guess i'm trying access when it's deleted, don't understand where. context: i'm showing list of cities , longclicking on item shows dialog asking confirm deletion. the item deleted in database since when relaunch app, it's not there anymore. realm arraylist public static arraylist<city> getstoredcities(){ realmquery<city> query = getrealminstance().where(city.class); final realmresults<city>results = realm.where(city.class) .findallsorted("timestamp", sort.descending); results.size(); arraylist<city> cityarraylist = new arraylist<>(); for(int = 0; i< results.size(); i++){ cityarraylist.add(results.get(

single sign on - SAML 2 (Ping Federate) Should the AssertionConsumerServiceURL be accessible by the IdP? -

we building website using sso, on sp side , don't have control on idp. have multiple environment including local development servers. the thing assertionconsumerserviceurl not accessible outside world (it 127.0.0.1/xyz) , told problem because idp needed make post request server. however understood of "double post" method , user needs able access sp , there no direct communication between sp , idp (since user relay). could please indicate if idp needs access sp "assertionconsumerserviceurl" directly ? if so, how should local development environment handled ? the acs url need accessible user of sp browser based sso (for both redirect , post bindings). long have credentials idp (unlikely in many situations, unless control both sides), , can test end-to-end on own (e.g., company's "test harness"), need make acs url/sp application available user.

android - How to show a "Clear button" after the first character pressed and hide it when the text is ""? -

i need show clear button @ right of edit text , hide when text is"". how can that. i need know how show , hide when text length>0 or =0, nothing more. try code field1.addtextchangedlistener(new textwatcher() { @override public void aftertextchanged(editable s) {} @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void ontextchanged(charsequence s, int start, int before, int count) { if(s.length() != 0) // set visibility } });

repository - How should I work with MELPA and MELPA-stable using Emacs? -

i run problem when install packages emacs: can if 1 of packages broken in melpa , other broken in melpa-stable ? example if use melpa-stable elscreen fails on startup: run-hooks: symbol's function definition void: elscreen-start but if run on melpa elscreen works cider-nrepl fails start up. checked github profile , build failing. there way work around this? you can use both melpa , melpa-stable , , pin packages repositories customizing package-pin-packages : (require 'package) (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (setq package-pinned-packages '((imenu-anywhere . "melpa-stable") (spaceline . "melpa-stable") (clj-refactor . "melpa-stable") (cider . "melpa-stable") (clojur

php - regepx - odd whitespaces in string -

i'm doing regexp on strings , in pattern match whitespaces \s but in strings experience strange spaces.. when converted hex a0 how convert strange spaces normal space can detected regexp , both , \s ? when string presented utf8 a0 chars represented � input in hex a03535a03832a03834a03135a02da053452e6e723aa0444ba03132a03638a03336a03933 input string  55 82 84 15 - se.nr: dk 12 68 36 93 a0 representation of &nbsp; - non-breaking space. you can match with: [\s\xa0]

bpm - How to Retrieve Form filled data in JBPM 6 -

i creating application using jbpm 6.4 . every user task has task form , completed them through jbpm console . want know how jbpm storing data .is there way retrieve these data's future purpose. yes, possible retrieve task data since jbpm 6.4. in previous versions, process instance variables persisted, version 6.4 introduced task variables auditing . task audit logs stored in taskvariableimpl table. those variables stored simple strings, every other audit log in jbpm. because of this, have implement custom tostring() methods custom classes used task variables. if want query of fields of complex classes, can implement own org.kie.internal.task.api.taskvariableindexer . there great example @ official documentation . although can access task variables in general way, complex queries , high usage suggest store required fields in own tables better handling.

python - Shodan. Get all open ports for a net -

i want open ports network shodan (i know can use nmap want carry out shodan). the problem website shows "top services", , given services. for example, net: 195.53.102.0/24 given following ports: top services http 15 https 2 dns 2 ftp 2 ike-nat-t 1 but if scan net: 195.53.0.0/16, given these ports: top services http 1,012 https 794 179 290 ike 238 ike-nat-t 227 so missing services dns , ftp . i trying api, python: import shodan shodan_api_key = "xxxxxxxxxxxxxxxxxxxxxxx" api = shodan.shodan(shodan_api_key) # wrap request in try/ except block catch errors try: # search shodan results = api.search('net:195.53.102.0/24') service in results['matches']: print service['ip_str'] print service['port'] except shodan.apierror, e: print 'error: %s' % e and results get: 195.53.102.193 80 195.53.102.138 80 195.53.102.148 80 195.53.102.136 80 195.53.102.157 80 195.53.102.226

c++ - Macro before class name -

i looking on code , i've stumble upon this: class idata_export idata { /* .... */ } where idata_export not more : #ifndef idata_export #define idata_export #endif what idata_export in case? (i mean, type int, char etc ... ?) most @ point in time, or under conditions defined (for example, under msvc): #define idata_export __declspec(dllexport) which used indicate classes publicly export library. using macro, developer alternate between exporting classes , not exporting anything, without having go on each individual class. this part of macro pattern alternates between importing , exporting classes, depending on whether code compiled library, or program dependent on library. like: #ifdef is_library // <--this defined when compiling library! #define idata_export __declspec(dllexport) #else #define idata_export __declspec(dllimport) #endif for more information, see dllexport, dllimport on msdn

node.js - Use Erlang + some other language on backend -

i want learn more erlang, , playground, want use core backend logic. i wonder, if connecting end users should choose stack, nodejs , connect somehow erlang? say, want make websocket connections users nodejs, it's suitable websockets, , create communication between nodejs , erlang pass data-crunching erlang, while keep nodejs middleman between backend , end users. should use middleman technology @ or solution put erlang + apache/nginx , implement whole system using erlang? erlang's main strength handling of client connections , routing requests workers. lightweight , isolated processes makes scale large number of connections while making error tolerant. erlang typically not right language heavy number crunching, should used request handling , routing. so instead of putting node.js connection handler , router use e.g. yaws or cowboy (more popular choice currently) websocket server , handle in erlang. in production system use nginx/haproxy load-balancer/pr

javascript - d3 getting invert value of Band Scales -

i writing gantt chart using d3 i have xscale time scale(time) this.xscale = d3.scaletime() .domain([this.startdate,this.enddate]) .range([0,this.getwidth()]); and yscale band scale (resources) this.yscale = d3.scaleband() .domain(resources.map(function(res){ return res.res_num; })) .rangeround([0,this.getheight()]) .paddinginner(.3) problem need drag , drop task( svg rect) 1 resource resources when drag using transfrom moving on svg _ondrag : function(d) { var x = d3.event.dx+d3.event.x; var y = d3.event.dy+d3.event.y; d3.select(this).raise().attr("transform","translate(" + [x,y] + ")"); }, but on drop have handle logic below: the rect should not in between resources, need transform band based on d3.event.y in xaxis time scale has invert yscale not have this. how this? solved below don't know standard way, if other way

database - How to get values from a table where value depends on another table? -

hi i'm using oracle database using oracle 10g. have 2 tables car , owns. create table car( "license" varchar(255) not null primary key, "year" varchar(255), "model" varchar(255) ); i inserted these values insert car values('12-3000', '2012', 'axio'); insert car values('11-3000', '2008', 'corolla'); insert car values('12-4000', '2013', 'axio'); insert car values('12-5000', '2013', 'premio'); insert car values('11-5000', '2010', 'nano'); insert car values('11-6000', '2011', 'alto'); insert car values('12-6000', '2015', 'nano twist'); this owns table create table owns ( "nid" varchar(20) not null, "license" varchar(255), primary key("nid", "license") ); also inserted values insert owns values('123451', '11-3000'); ins

extract data from javascript using Python -

i new user python, , have inherited python notebook predecessor want improve. purpose of grab product details website. how works: it scrapes script website using beautiful soup: source = urllib2.urlopen('http://www.testwebsite.html').read() soup = bs4.beautifulsoup(source) job_postings = soup.findall("script") job_postings = [jp jp in job_postings if not jp.get('type') none , ''.join(jp.get('type')) =="text/javascript" , ''.join(jp.get('type')) =="text/javascript"] it returns script in webpage: (1st part of data) window.wf=window.wf||{};wf.appdata=wf.appdata||{};wf.appdata.product_data_test123=wf.appdata.product_data_test123||{};wf.appdata.product_data_test123 = {"sku":"tes123","is_grid_view":false,,"default_img_display":0,"manufacturer_name":"supplier1","product_name":"product test&q

How do you reference a model in a laravel controller? -

this question exact duplicate of: troubleshooting referencing model in laravel controller 2 answers i'm finding distinction between "controller" , "model" in laravel 5.2 blurry. i use artisan create restful controller, , in store method, try create new object. // store in database $car = new app\models\carmodel; then error follows: class 'carfreak\http\controllers\app\models\carmodel' not found so seems come down namespace of controller, don't understand it. the name space describes controller, right? why reference model, being built on controllers path? shouldn't have it... right? edit: after trying various suggestions, i've concluded there 3 things at: each class has namespace set, correctly describing folder class located in controller, have statement "use app\models\carmodel" refer model in

jquery - What is the concept behind javascript parameters? -

let me try explain weird confusion i'm trying learn d3.js . i'm seeing lot of functions odd kind of parameters (they odd @ least me). d3.selectall("p").style("color", function(d, i) { return % 2 ? "#fff" : "#eee"; }); what d doing here? why passed when it's of no use? from i (along value ) getting passed? also following jan's tutorial , built fiddle . has odd function params: .attr("cy", function(d) { return y(d.y) }) .delay(function(d, i) { return * del(math.random()) }) from d (along value ) getting passed? what d doing here? why passed when it's of no use? the style function call callback specific set of arguments. fact callback doesn't happen need first of arguments doesn't change how style call it. callback has accept argument, ignore it. from i (along value) getting passed? the style function. it's calls callback, it's determ

php - display result of json data in textview of android -

i having 1 problem while displaying data in android app.this php.i have edited shorten code. if($imei_no!="" && $app_auid!="") { //chk query $chk_query=$db1->query("select * user imei_number='$imei_no'"); $chk_cnt=$chk_query->rowcount(); if($chk_cnt>0) { $search_qry=$db1->query("select * candidate_reception cr,candidate_counseling cc ,candidate_admission ca cr.candidate_id=cc.candidate_id , cr.candidate_id=ca.candidate_id , cr.auid=ca.auid , cr.counseling_id=cc.counseling_id , cr.auid='$app_auid'"); $ser_count=$search_qry->rowcount(); if($ser_count>0) { $stud_row=$search_qry->fetch(pdo::fetch_obj); $candidate_id=$stud_row->candidate_id; $auid = $stud_row->auid; $usn_no = $stud_row->usn_no; $sx = $stud_row->candidat

SQL Server check constraint logic -

i've got table has such kind of structure: create table #mine ( productid int , countryid int , applicationid int ); let's assume has data follows: productid countryid applicationid 1 2 -1 1 3 -1 1 3 2 i'd enforce such logic there's no other productid / countryid combination in entire table if exists applicationid = -1 . in example 2nd , 3rd row wouldn't pass this. i create custom function validate , make check constraint out of it. there perhaps more elegant way it? i split task. first, assign unique constraint (this can table key): create unique index ix_uq on mine(productid, countryid, applicationid) this trivial validations , improve trigger query. second, check requires many records involved (no check constraint possible). task trigger: create trigger trmine on mine insert,update if (exists( select mark ( select max(case whe

asp.net - How to create global dataTable in C#? -

i need use global datatable in .net project. however, cannot handle between 2 methods.. in example, dt1 global datatable , dt2 local, dt2 direct using call method. result: dt1: don't know how describe it, likes whole html page in excel. dt2: well! can tell me why dt1 wrong ? should perfect.. code: private datatable dt1;// same result public datatable dt1{ get; private set; }"" protected void page_load(object sender, eventargs e) { if (!page.ispostback) { datatable dt = new datatable(); dt.columns.addrange(new datacolumn[3] { new datacolumn("shorturl", typeof(int)), new datacolumn("longurl", typeof(string)), new datacolumn("creatingdate",typeof(string)) }); dt.rows.add(1, "john hammond", "united states"); dt.rows.add(2, "mudassar khan", "india");

Pass include path from variable with Twig? -

i need include child-1.twig , child-2.twig in component.twig, , include component.twig in page.twig. in page.twig: {% set items = [ '{% include "child-1.twig" %}', '{% include "child-2.twig" %}' ] %} {% include "component.twig" items %} in component.twig: <div class="component"> {% item in items %} {{ item }} {% endfor %} </div> the complexity comes fact cant modify component.twig, page.twig. code above work if {% include "child-1.twig" %} , {% include "child-2.twig" %} rendered instead printed onto page string of text. can similar approach make child include run? can suggest add empty block in file ( component.twig ) {% block includes %}{% endblock %} then able this: {% embed "component.twig" items %} {% block includes %} {% include "child-1.twig" %} {% include "child-2.twig" %} {% endblock %} {% en

javascript - ng-pattern allows '+' character when regex limits to digits -

am using regex /^[0-9]+$/ limit input of text box accept numbers. it's working fine when types +124 it's not setting text box invalid. <form name="myform" novalidate> <input type="number" ng-model="age" name="age" ng-pattern="/^[0-9]+$/" /> <h3>valid status : {{myform.age.$valid}}</h3> </form> input: 123 output: myform.age.$valid - true input: -123 output: myform.age.$valid - false input: +123 output: myform.age.$valid - true (shouldn't true) https://plnkr.co/edit/3ove6qiwgjozub3hyfq5?p=preview if want make pattern work, need set type attribute text . since want let users type only digits input field, add onkeypress validation: <input type="text" onkeypress="return (event.charcode == 8 || event.charcode == 0) ? null : event.charcode >= 48 && event.charcode <= 57" ng-model="age" name="age" ng-pattern=

javascript - How can I access json data inside array? -

i need json value. data - [ { "statuscode":200, "body":{ "token":"xxxxx" }, "headers":{ "date":"thu, 28 jul 2016 11:03:17 gmt", "server":"apache/2.2.15 (centos)", "x-powered-by":"php/5.6.22", "cache-control":"private, must-revalidate", "etag":"\"9517ef72d528ad7a3bc04c64d1cc1cc9\"", "set-cookie":[ "xsrf-token=xxx; expires=thu, 28-jul-2016 13:03:17 gmt; max-age=7200; path=/", "laravel_session=eyjpdii6ikzitxdytgtpzlrkc1hmqkptuwpzsee9psisinzhbhvlijoicgxlumjxrzlcl2dgttdvcvjiq1g2qth4enqxddi5nelcbgjkvllkyvr0mg1lqtljafhhufjsuvvxtytheuxqajzjv3fvukh2suhpk0ztelhiqjcxvk5npt0ilcjtywmioijkotg1mwfiyjy5ztdhnthkodk5n2y1mmrlowewzwmwywq4mge4zdvjmwrjmgmwnja0mtlmnjq1yznmndm3nwvkin0%3d; expires=thu

javascript - Remove table rows locally depending on ajax call -

i have table updating through reloading page i'm trying handle locally instead. render table below through php , update through ajax. when want remove rows want remove row when successful response ajax code have removal global , deletes anyway. there way me incapsulate js code in js function , perhaps call through onclick-event? my table: <table> <tr> <td>1</td> <td><a class="remove" href='#' onclick="remove()">remove</a></td> </tr> <tr> <td>2</td> <td><a class="remove" href='#'>remove</a></td> </tr> <tr> <td>3</td> <td><a class="remove" href='#'>remove</a></td> </tr> </table> my js removal $(document).on("click", "a.remove", function() { $(this).closest("tr").remove(); }); and want delet

solace - Disk rebuild speed low - Soalce Applinace -

after executing show disk details , able see "disk rebuild speed low "on solace appliance 3560. what mean of "disk rebuild speed low" in solace. the cli command disk rebuild speed <low | high > changes raid rebuild speed of physical appliance. higher rebuild speed, faster raid 1 mirroring completes more system resources consumed rebuild task. you can check disk rebuild status in support shell with: [support@solace ~]$ cat /proc/mdstat and corresponding speed limits set after changing speeds above cli command: [support@solace ~]$ cat /proc/sys/dev/raid/speed_limit_max [support@solace ~]$ cat /proc/sys/dev/raid/speed_limit_min

php - Access denied for user 'root'@'localhost' (using password: NO) error in Mysql -

i have worked on mysql database until yesterday, today when trying access mysql gave following error. error 1045 (28000): access denied user 'root'@'localhost' (using password: yes) i want existing databases since have not got backup. further, have followed step on following lnks , still haven't found solution problem. resetting permissions (mysql) error 1045 (28000): (stackoverflow)

xampp - Disable xDebug on phpMyAdmin -

i using xdebug first time. works well, when want go on localhost/phpmyadmin want start debug (i don't have breakpoints here). how can disable phpmyadmin? my config: [xdebug] zend_extension = "c:\xampp\php\ext\php_xdebug.dll" xdebug.profiler_append = 0 xdebug.profiler_enable = 1 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_dir = "c:\xampp\tmp" xdebug.profiler_output_name = "cachegrind.out.%t-%s" xdebug.remote_enable = on xdebug.remote_handler = "dbgp" xdebug.remote_host = localhost xdebug.remote_port = 9000 xdebug.trace_output_dir = "c:\xampp\tmp" xdebug.collect_return="0" i using xampp, phpstorm. you can turn off debug connection listener going run > stop listening php debug connections . phpstorm ignore connections xdebug. when want debug again go run > start listening php debug connections , it'll work again. you permanently ignore files using skipped paths : go prefer

Failing to import itertools in Python 3.5.2 -

i new python. trying import izip_longest itertools. not able find import "itertools" in preferences in python interpreter. using python 3.5.2. gives me below error- from itertools import izip_longest importerror: cannot import name 'izip_longest' please let me know right course of action. have tried python 2.7 , ended same problem. need use lower version python. izip_longest renamed zip_longest in python 3 (note, no i @ start), import instead: from itertools import zip_longest and use name in code. if need write code works both on python 2 , 3, catch importerror try other name, rename: try: # python 3 itertools import zip_longest except importerror: # python 2 itertools import izip_longest zip_longest # use name zip_longest

Gitlab Continuous Integration npm Background Process -

i have setup of gitlab ci want start local npm server testing in background. .gitlab-ci.yml like: stages: - setup - build - test cache: paths: - venv/ - node_modules/ setup_nvm: stage: setup script: - "echo installing npm , phantomjs via nvm" - "git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`" - ". ~/.nvm/nvm.sh" - "nvm install 5.0" - "nvm use 5.0" - "npm install" - "nohup npm run dev &" # here try run server in background setup_python: stage: setup script: - "echo installing python dependencies in virtual environment" - "[ ! -d venv ] && virtualenv -p python3 venv" - "source venv/bin/activate" - "pip3 install -r requirements.txt" build_multilang: stage: build script: - "[ ! -d tu9onlinekurst

mysql - Rails LHM migration - specify name of index -

using lhm ( large hadron migrator ) there syntax documentation add indexes: require 'lhm' class somemigration < activerecord::migration def self.up lhm.change_table :foos |m| m.add_unique_index [:bar_id, :baz] # add_index if don't want uniqueness end end def self.down lhm.change_table :foos |m| m.remove_index [:bar_id, :baz] end end end how can specific name index specified in lhm? adding , removing i concerned hit index name length limit using many columns m.add_unique_index([:long_column, :super_long_column], 'shortened_index_name') link lhm docs #add_unique_index

javascript - Regex extension and language -

i looking validating file names. cant figure out correct regex file names can anything, need check if filename ends with _ underscore en or ru or cy (country code 2 letters) . (dot) extensions (jpeg, jpg, mp4, png, gif) so file my_file_dummy_name.jpeg - not valid my_file_dummy_name_en.jpeg - valid for tried (and working maybe there better solution) /(\_\w.\.\w+)/g one more: /(\_[a-z]{2}\.[a-z]{3,4})/g the problem original regex that, while match filenames want allow, match things don't want. for example, following regex /(\_\w{2}\.\w+)/g would match file my_file_dummy_name_de.mpeg , video file germany. clearly, wouldn't want watch in first place. try regex: _(en|ru|cy)\.(jpeg|jpg|mp4|png|gif)$ demo here: regex101

parsing - sscanf in Python -

i'm looking equivalent sscanf() in python. want parse /proc/net/* files, in c this: int matches = sscanf( buffer, "%*d: %64[0-9a-fa-f]:%x %64[0-9a-fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %ld %*512s\n", local_addr, &local_port, rem_addr, &rem_port, &inode); i thought @ first use str.split , doesn't split on given characters, sep string whole: >>> lines = open("/proc/net/dev").readlines() >>> l in lines[2:]: >>> cols = l.split(string.whitespace + ":") >>> print len(cols) 1 which should returning 17, explained above. is there python equivalent sscanf (not re), or string splitting function in standard library splits on of range of characters i'm not aware of? python doesn't have sscanf equivalent built-in, , of time makes whole lot more sense parse input working string directly, using regexps, or using parsing tool. probably useful tra

bash - Execute simultaneous commands and quit when one finishes -

i hope question hasn't been asked many times couldn't find answer on google (i didn't know how specify it). does know how execute 2 parallel commands in bash but, when 1 finishes, other finish? for instance, have 2 different python scripts : while 1: pass : loop.py print(42) : print.py i python3 loop.py ** python3 print.py . 2 scripts must run in parallel , when print finishes, loop end automatically. my usage of command make like: tcpdump -i -w out.trace ** python3 network_script.py thank in advance what want is tcpdump ... & pid=$! python3 network_script.py kill $pid run first script in background, start second script. when second script ends, kill first one.

apache spark - Modify an existing RDD without replicating memory -

i trying implement distributed algorithm using spark. computer vision algorithm tens of thousands of images. images divided "partitions" processed in distributed fashion, of master process. pseudocode goes this: # iterate t = 1 ... t # each partition p = 1 ... p d[p] = f1(b[p], z[p], u[p]) # master y = f2(d) # each partition p = 1 ... p u[p] = f3(u[p], y) # each partition p = 1 ... p # iterate t = 1 ... t z[p] = f4(b[p], y, v[p]) v[p] = f5(z[p]) where b[p] contains pth partition of images numpy ndarray, z[p] contains function of b[p] , numpy ndarray, y computed on master knowing partitions of d , , u[p] updated on each partition knowing y . in attempted implementation, of b , z , , u separate rdds corresponding keys (e.g. (1, b[1]) , (1,z[1]) , (1, u[1]) correspond first partition, etc.). the problem using spark b , z extremely large, in order of gbs. since rdds immutable, whenever want "join" them (e.g. bring z[1

php - Linking Laravel project with MAMP database -

i following tutorial on creating social network laravel v5.2. person in tutorial uses vagrant/homestead life of me not working resorted mamp view site locally. have hit roadblock. i trying configure ".env" file connect mamp database migrations have been written can executed don't know how go this? this ".env" file. app_env=local app_debug=true app_key=base64:7dp18ga9x3wifp6wqguy6usmu+rrgru2qpkt4gydupi= app_url=http://localhost db_connection=mysql db_host=127.0.0.1 db_port=3306 db_database=unitedb db_username=root db_password=root cache_driver=file session_driver=file queue_driver=sync redis_host=127.0.0.1 redis_password=null redis_port=6379 mail_driver=smtp mail_host=mailtrap.io mail_port=2525 mail_username=null mail_password=null mail_encryption=null "unitedb" database created in mamp phpmy admin did not work , don't know go here. if try run "php artisan migrate" on command line within project file returns "[symfon

bash - csplit prefix as file context -

i wrote bash script in order split file. file looks this: @<tripos>molecule zinc32514653 .... .... @<tripos>molecule zinc982347645 .... .... here script wrote: #!/bin/bash #split file files named xx##.mol2 csplit -b %d.mol2 ./zincpharmer_ligprep_1.mol2 '/@<tripos>molecule/' '{*}' #rename files called xx##.mol2 2nd line zinc###### filename in ./xx*.mol2; newfilename=$(echo $filename | sed -n 2p $filename) if [ ! -e "./$newfilename.mol2" ]; mv -i $filename ./$newfilename.mol2 else num=2 while [ -e "./"$newfilename"_$num.mol2" ]; num=$((num+1)) done mv $filename "./"$newfilename"_$num.mol2" fi done i have 2 questions: 1) there way include prefix option csplit , telling csplit prefix line after seperator. 2) first line created csplit xx00 empty file, separator in first line. how can avoid this? the expected output files n

Calling methods with arrays in C++ -

my problem have trouble calling int computepattern method in int main(). able use insertnumber method. don't know how use computepattern method. method compute number of patterns , return count. pattern both adjacent numbers must greater 7. hence, there 5 pairs check there 10 numbers. output random arrays worked, need print out number of patterns too. need use methods required in question. int insertnumber(int b ) { int = rand()%10+1; return a; } int computepattern(int* inarray, int size ) { int patterns=0; for(int z=0;z<size;z=z+2) { if(inarray[z]+inarray[z+1]>7) { patterns ++ ; } } return patterns; } int main() { int arrays[10]; srand(time(0)); ( int b=0; b<10 ; b++) { arrays[b] = insertnumber(b); } cout << "arrays"; ( int c= 0; c<10; c++) { cout << " " ; cout << arrays[c]; } int patterns =computepattern(arrays,10); cout<<endl; cout << "patterns" <<patterns

rest - How to send push notification to ionic app from java server using MFP8.0? -

i have sample ionic application using service rest web service . now, want send push notification rest web service ionic application using mfp 8.0 . is there documentaion requirement. searched, unable found how through web service. anyone appreciated!!! i'm not convinced you've searched... here sending notifications via rest mentioned in sending push notifications tutorial: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-push-notifications/#rest-apis you did not specify if application requires authentication or not, best review entire notifications category of tutorials.

hadoop - How to convert csv to xml using Hive UDF or Pig UDF? -

i trying convert csv file xml using hive or pig. when google see lot of solutions parsing xml csv not other way around. can me? right doing using tool called talend, not solution because using execution server instead of cluster. eid,ename,sal 1,a,d1 2,b,d2 3,c,d3 to <?xml version="1.0"?> <employee_info <employee eid="1"> <name>a</name> <department>d1</department> </employee> <employee eid=2> <name>b</name> <department>d2</department> </employee> <employee eid=3> <name>c</name> <department>d3</department> </employee> </employee_info>

javascript - game.physics.arcade.overlap() is not working in phaser -

i want kill bullet overlap asteroid not working. please have of code. looked in code many times looking right. want perform collision on asteroid. game.js var bullets; var game = { preload: function() { // load needed image this(play) game screen. //load menu screen this.load.image('menu', './assets/images/menu.png'); // here load needed resources level. // background image screen this.load.image('playgame', './assets/images/back.png'); // globe image screen // this.load.image('playgame', './assets/images/back.png'); this.load.image('spaceship', './assets/images/spaceship.png'); // astroid image screen this.load.image('astroid1', 'assets/images/asteroid1.png'); this.load.image('astroid2', 'assets/images/asteroid2.png'); this.load.image('astroid

linux - git: can I issue commands from two computers mounted to same file system -

i hope can explain in simple way ... the files adding git on linux server. access these files various computers, depending on am. windows machine, drive mapped network drive. ssh server. i created git repository while working on windows machine network drive mapped appropriate file system, lets call w:. in w:\ when created repository. when ssh server directory like: \home\mydir\working_dir\ can now, while in ssh session, issue git commands update repository on linux macine? this not answer, long comments. i'm getting end of tether git. has messed everything. trying google solution fruitless. nothing specific enough , when try might relevant totally screws things further. i tried changing path in config file manually. didn't know change to. if should relative, relative what? i tried couple of things , ended /home/myname/myworkingdir/ however, deleted files again , set me unknown state. fortunately backed files beforehand. tried copy them place , add them

ruby on rails - Shrine gem - how to delete uploaded images from s3 -

apparently :remove_attachment plugin trick checking , submitting how can call method controller? all plugins allow set form fields ( remove_attachment , remote_url , data_uri , ...) work in way add getters , setters models, if have photo model "image" attachment, can photo.remove_image = true . however, removing attachments in ruby code don't need remove_attachment plugin, can assign attachment nil : photo.image = nil # or photo.update(image: nil)

c# - How to select the listviewitem, where a button was clicked -

i want select listviewitem, button clicked. here listview 2 llistviewitems i click x-button , want delete these item out of list. how item? have these code: private void delete_click(object sender, routedeventargs e) { var item = sender listviewitem; var obj = item.content object; list.remove(obj); } edit: binding of listview <listview x:name="listview"> <listview.itemtemplate> <datatemplate> <wrappanel> <textblock text="bild "/> <textblock text="{binding title}"/> <button x:name="change" content="change" margin="250,0,0,0" click="change_click"/> <button x:name="delete" content="x" margin="10,0,0,0" click="delete_click"/>

How do I create a function prototype in powershell? -

i can't find example. how make prototype powershell functions? function examplefunc(); //other stuff calls example function function examplefunc(){//stuff} powershell doesn't support prototype functions, forward declarations or whichever term want use this. in powershell, when use function keyword you're defining function. if call twice same function name, change function's definition. this question same issue bash lists common methods around issue. can same things in powershell. another option use begin {} process {} end {} advanced function construct, , put function declarations in begin {} portion.

Android InflateException Error in fragment layout with SupportMapFragment (recreated fragment) -

all more or less works. if locationfragment recreated, application falls. manifest <?xml version="1.0" encoding="utf-8"?> <manifest package="xx.xx.xxxxxxxx" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.get_accounts"/> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_fine_location"/> <uses-permission android:name="android.permission.camera"/> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.read_external_storage"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-feature android:glesversion="0x00020000" android:required="true"/> <uses-featur