Posts

Showing posts from January, 2015

logging - Collecting logs from hardware devices and application software using syslog-ng -

i need collect logs devices firewall, printers, routers, switches, proxy-servers, mail-servers, db-server, anti-virus software , other softwares both linux , windows platform. able single open-source tools syslog-ng ? there other similar or different open-source logging tool can serve purpose single-handedly? mostly depends on other devices. if can send logs in standard syslog (rfc3164 or rfc5454), syslog-ng can receive them. depending on devices, can install syslog-ng client , collect logs files if needed. for windows, need other tool can collect logs windows eventlog , forward syslog logserver syslog-ng can receive them. there both free , commercial tools can (for example, commercial version of syslog-ng).

objective c - Can I get video clip/edit function as iOS Photos app? -

like picture uploaded, have app want use same function photos app provided. it should have these: edit saved video, resize area,such cut top half of it's view. drag resize new time interval video, such 30 second video ,clip 16 second. thanks lot! screen shot just try this if uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.photolibrary) { let imagepicker = uiimagepickercontroller() imagepicker.delegate = self imagepicker.sourcetype = .photolibrary imagepicker.mediatypes = [kuttypemovie string] imagepicker.videomaximumduration = 300 imagepicker.videoquality = .type640x480 imagepicker.allowsediting = true presentviewcontroller(imagepicker, animated: true, completion: nil) }

python - adding spaces inside string using regex sub -

i have string want split 2-digit pieces. tried using regex so: import re s = "123456789" t = re.sub('..', ".. ", s) print(t) i expected 12 34 56 78 9 instead got '.. .. .. .. 9' . 9 not bother me, because know have number of digits, how can tell re.sub not replace actual digit dot? using python shell 3.5.1 edit checked 3 answers, , work, findall seems faster (and more elegant imo ;p ): import time import re s = "43256711233214432" = 10000 start = time.time() while i: -= 1 re.sub('(..)', r"\1 ", s) end = time.time() elapsed = end - start print("using r\"\\1 \" : ", elapsed) = 10000 start = time.time() while i: re.sub('..', r"\g<0> ", s) -= 1 end = time.time() elapsed = end - start print("using r\"\g<0> \" : ", elapsed) = 10000 start = time.time() while i: ' '.join(re.findall(r'..|.', s))

PHP Mysql - create previous and next link from current customer -

i have page listing customers: /customers/ the order of customers on page not sequential: 1st: id 111 2nd: id 567 3rd: id 345 etc that's because sql query lets user select customer order based on first name, last name, or nickname. "select customer_id customers status = 1 order " . $customer_order so when on 2nd customer in example above: /customer/567/ so problem want display previous , next button this, can't figure out how: <a href="111">prev</a> <a href="567">current</a> <a href="345">next</a> i managed previous link working in while loop it's ugly. tried using current(), prev(), , next() failed. most solutions i've seen on stackoverflow sequential ids either -1 or 1 current id, or "limit 1" in query i'm sure doesn't work in situation after testing this. any ideas? you can assign row number query , use row number identify previous , next

Start Java Class from embedded library inside Spring Boot executable jar -

is possible start different java class (with main method) in spring boot executable jar declared mainclass ? speciality : class should started located in library embedded in executable jar (inside lib folder). background information: the executable jar contains library class call gracefully shutdown application. library embedded inside executable jars lib folder , not accessible default java classpath parameter. see reply: https://stackoverflow.com/a/2023544/1499549 . need specify class after defining jar file on classpath. java -cp myapp.jar com.example.main1

jquery - PHP get real time date without page reload -

i have code gets server date , time in php works well. need work time rather on page load... code below: <?php if(date('w') !== 0) { if((current_time('hi')<1800 && current_time('hi')>=1400) || (current_time('hi')<1300 && current_time('hi')>=700)) { echo 'we open'; } else { echo 'we closed'; } } else if(intval(current_time('hi'))<1230 && current_time('hi')>=700) { echo 'we open'; } else { echo 'we closed'; } ?> <p>we close @ <strong> <?php if (date('l') != "sunday") { echo '18:00'; } else if (date('l') == "sunday") { echo '12:30'; } ?> </strong> today</p> is possible make work poll server / work after page loads - example, if on monday page loaded @ 17:58 , user views page 3 minutes, code should change sign showing open closed wi

How do I convert this query into LINQ? -

select * procedurelookup proclookup inner join (select patientprocedures.pp_procedureid, count(*) proccount (patientprocedures inner join treatments on patientprocedures.pp_treatmentid = treatments.ts_treatmentid) year(treatments.ts_date) = year(getdate()) group patientprocedures.pp_procedureid) cyearproc on proclookup.pl_procedureid = cyearproc.pp_procedureid order proccount desc; here procedurelookup , treatments , patientprocedures tables. here linq query. var result = (from proclookup in db.procedurelookup join cyearproc in ( p in db.patientprocedures join t in db.treatments on p.pp_treatmentid equals t.ts_treatmentid t.ts_date.year == datetime.now.year group p p.pp_procedurei

ios - How can I find the next weekend Swift -

i have app in want show data when it's saturday or sunday. have segmented control , if press 1 of option (which weekend) want check if saturday or sunday first weekend. this i've done first option in segmented control take current date dateevent variable take check if currentdate currentdate declared currentdate if dateevent.earlierdate(self.currentdate).isequaltodate(self.currentdate){ if nscalendar.currentcalendar().isdate(dateevent, equaltodate: self.currentdate, tounitgranularity: .day){ //do } } first find number of days add nsdatecomponents weekday property , can use datebyaddingcomponents(_:todate:options:) . let today = nsdate() let calendar = nscalendar.currentcalendar() let todayweekday = calendar.component(.weekday, fromdate: today) let addweekdays = 7 - todayweekday // 7: saturday number var components = nsdatecomponents() components.weekday = addwee

How to return only one variable in multi return function in GO? -

hi have function want return docker.apicontainer , error (nil if no errors), in case of error should return in docker.apicontainer ? this code func getcontainersrunningimage(imagename string, tag string) ([]docker.container,string) { logfields := log.fields{ "handler": "get service", } client, err := docker.newtlsclient(sconf.dockconf.endpoint, sconf.dockconf.cert, sconf.dockconf.key, sconf.dockconf.ca) if err != nil { log.withfields(logfields).errorf("tlsclient not created: %s", err) return _,err.error() } } what should add instead of _? obliged create var contarray []docker.container , return it? or there way return nil, err.error() goreturns automatically - 0 int , "" string etc.

c++11 - Should I be passing unique_ptr<T> by reference here? -

i found (nasty) code update pointer pointer, doing this: void func(x** ptr2ptr, x* oldx){ x* x2 = new x(); x2->a(oldx->a); // etc delete *ptr2ptr; *ptr2ptr = x2; oldx = *ptr2ptr; } as can imagine, horrible. i refactored above method , called outside wrapper, followed method uses updated pointer (see below). however, seems update memory getting deleted prior call anothermethod() because seg fault: void wrapper(std::unique_ptr<x>& x){ func(x); anothermethod(x); } void func(std::unique_ptr<x>& x){ std::unique_ptr<x> x2(new x()); // same assignment before x = std::move(x2); } void anothermethod(std::unique_ptr<x>& x){ // seg fault occurs here whilst accessing x class member } can please help? thought doing correct thing using std::move() , passing unique_ptr reference. the old code wasn't "moving" pointers: keeped a member inside structure. try this: void

c - Public flags are not applied to libraries (cmake) -

with cmake, apply general flags both executable , libraries. well, thought use target_compile_options using public keyword. tested on small example executable , static library, both having 1 file (main.c & mylib.c), not work expected. the root cmakelists.txt looks this: cmake_minimum_required(version 3.0) # add library add_subdirectory(mylib) # create executable add_executable(mytest main.c) # link library target_link_libraries(mytest mylib) # add public flags target_compile_options(mytest public -wall) and library's cmakelists.txt: cmake_minimum_required(version 3.0) add_library(mylib static mylib.c) the flag -wall applied on main.c , not on library file (mylib.c): [ 25%] building c object mylib/cmakefiles/mylib.dir/mylib.c.o cd /patsux/programmation/repositories/test-cmake-public/build/mylib && /usr/lib/hardening-wrapper/bin/cc -o cmakefiles/mylib.dir/mylib.c.o -c /patsux/programmation/repositories/test-cmake-public/mylib/mylib.c [ 50%]

python - how to paging from top 99 rows in sqlalchemy? -

select *from (select *from new_count_goods_details limit 99) sub limit 10 offset 90; how achieve mysql statement sqlalchemy? this code: limit_subquery = q.filter(stylelist.add_time >= yesterday_18).\ filter(stylelist.add_time <= today_18).\ order_by(stylelist.rank_num.desc()).\ limit(99).\ subquery("limit_subquery") q = limit_subquery.offset((p-1)*ps).limit(ps) it error code, error info: attributeerror: 'alias' object has no attribute 'offset' you need select subquery q = session.query(limit_subquery).offset((p-1)*ps).limit(ps)

node.js - Could you help me about Websocket and Real Live Data Strem for Grid -

i have no experience node.js , websocket. i checked socket.io , did example chat . it's working . now wonder how can socket.io chat sample need data stream grid. for example; have forex data feed , want real live update on html5 web site . there example ? socket.io chat , looks powerfully don't know how ot them data table. i checked jquery plugins not working chat example. not real live data can say. i want css manipalation on html side , when price down or when price up. please me if know these things . thank you. if need transform data on stream, perhaps use node.js module called scramjet . allow modify data on fly, before pushing them page via socket.io. example if compress data little const io = require('socket.io').listen(8080); yourforexstream.pipe(new scramjet.datastream) .filter((forexitem) => typeof forexitem.tick !== "undefined") // don't send heartbeats, ticks .map((forexitem) => forexitem.t

jsf - Nested b:repeat - second repeat always the same -

i want render nested 2-level navigation using model file. navigation can change. there simple bean navigationitem contains title, target, icon , list of possible sub items. the navigation created simple: @viewscoped @named public class navigation implements serializable { private list<navigationitem> navigation = new arraylist<>(); public list<navigationitem> getvalues() { if (navigation == null || navigation.size() <= 0) { navigationitem nava = new navigationitem("a", "icon-gauge", "site_a"); { list<navigationitem> subnav = new arraylist<>(); subnav.add(new navigationitem("1", "", "subsite_1")); subnav.add(new navigationitem("2", "", "subsite_2")); subnav.add(new navigationitem("3", "", "subsite_3")); na

Android image slider -

i want create image slider in application. slider contain around 6 images , user can swipe through them. if user not interact swipe on own in time interval.. want create 3 of such sliders in single fragment. what's best approach such design? 3 independent sliders. , of course have use less memory possible.. is there library should use.. please suggest optimized approach. thank you can use viewpager views rather fragments. check out tutorial on how use viewpager views: https://www.bignerdranch.com/blog/viewpager-without-fragments/ to scroll automatically use timer , call: viewpager.setcurrentitem(1) where 1 second item etc...

zend framework - Unable to use custom validators in ZF2 when creating form using factory -

was wondering if has come across problem previously. using preconfigured form spec create form using zend\form\factory, injecting formelementmanager factory can find custom elements etc. my question is: even tho custom validators registered form, not trigger isvalid() method. there need isvalid() triggered creating form factory. my source looks following: $spec = [ 'hydrator' => '...', 'fieldset' => [ ..., ..., ..., ], 'input_filter' => [ ..., .... ...., //contains custom validator in here ], ]; $factory = new factory(); $factory->setformelementmanager($formelementmanager); $form = $factory->createform($spec); but when trigger: $form->isvalid() it doesn't isvalid call in custom validator. the input filter factory, zend\inputfilter\factory , dependency of form factory . factory used form factory create inputs should filtered , v

php - Uncaught TypeError: array_key_exists() -

i want modify array of samples&lables , pass predict() function. must because want samples , labels other.xls file , store in array can fit in code. original code: $samples = [[5, 1, 1], [1, 5, 1], [1, 1, 5]];// array() form? $labels = ['a', 'b', 'c']; $classifier = new naivebayes(); $classifier->train($samples, $labels); $classifier->predict([3, 1, 1]) //return //other file.php predict(array $sample){ $predictions = []; foreach ($this->targets $index => $label) { $predictions[$label] = 0; foreach ($sample $token => $count) { if (array_key_exists($token, $this->samples[$index])) { $predictions[$label] += $count * $this->samples[$index][$token]; } } } then modified code to: $samples = array("samples1","samples2", "samples3",...,"samplesn"); $labels = array("a","

plsql - Oracle, Execute immediate Insert -

i'm trying insert random generating data table, here's code" begin x in 1..300 loop execute immediate 'insert emp values ('||prac_seq.nextval||','''||'name'||x||''','||trunc(dbms_random.value(1,300))||');'; end loop; / table emp has 3 columns - id , name , idmgr ; above query in execute immediate statement looks like: insert emp values (13,'name25',193); this block did not run. when tried run single execute immediate statement (f.e. begin execute immediate 'insert emp values ('||prac_seq.nextval||','''||'name23'','||trunc(dbms_random.value(1,300))||');' end; / ora gives me error: execute immediate 'insert emp values ('||prac_seq.nextval||','''||'name23'','||trunc(dbms_random.value(1,300))||');'; end; error report: ora-00911: invalid character ora-06512: @ line 3 00911. 000

jquery - Get button value printed by php and process them via javascript -

i have dynamic table results database printed. <table id="table" class="table datatable-responsive"> <thead> <tr class="bg-teal"> <th>#</th> <th>datum & vrijeme</th> <th>stavka</th> <th><center>izabrana količina</center></th> <th><center><i class="icon-pencil"></i></center></th> <th><center><i class="icon-bin"></i></center></th> </tr> </thead> <tbody> <?php $i = 1; while ($r=$q->fetch()) { $a = 0; $a += 1; $id = $r['id']; $datum = $r['datum'];

scala - How to deal with more than one categorical feature in a decision tree? -

i read piece of code binary decision tree book. has 1 categorical feature, field(3), in raw data, , converted one-of-k(one-hot encoding). def preparedata(sc: sparkcontext): (rdd[labeledpoint], rdd[labeledpoint], rdd[labeledpoint], map[string, int]) = { val rawdatawithheader = sc.textfile("data/train.tsv") val rawdata = rawdatawithheader.mappartitionswithindex { (idx, iter) => if (idx == 0) iter.drop(1) else iter } val lines = rawdata.map(_.split("\t")) val categoriesmap = lines.map(fields => fields(3)).distinct.collect.zipwithindex.tomap val labelpointrdd = lines.map { fields => val trfields = fields.map(_.replaceall("\"", "")) val categoryfeaturesarray = array.ofdim[double](categoriesmap.size) val categoryidx = categoriesmap(fields(3)) categoryfeaturesarray(categoryidx) = 1 val numericalfeatures = trfields.slice(4, fields.size - 1).map(d => if (d == "?") 0.0 else d.todouble)

facebook ads api - FB Ads API status , effective_status and the ads actual status -

from ads api doc says effective_status enum {active, paused, deleted, pending_review, disapproved, preapproved, pending_billing_info, campaign_paused, archived, adset_paused} effective status of ad. status effective either because of own status, or status of parent units. status enum {active, paused, deleted, archived} configured status of ad. field returns same value 'configured_status', , suggested 1 use. but, problem unless advertiser actively stops or pauses or deletes advert or campaign ad's status (as far can see in aforementioned cases) active. wrong? secondly, know column on ads manager interface called "delivery" is? has values "completed" , "not delivering" etc. is there way can information api? the field called 'delivery' in facebook's ui not single field returned ui, based on examining status, start/end dates, etc of ads–you replicate examining ads , parent objects. i'

How can I write a C++ type conversion operator to implicitly convert all void* to MyStruct* -

i'm learning windows driver dev, , find problem using visualddkhelper.h c++ code(no problem c code). the question boils down this: // --- formal windows driver sdk header --- typedef void * handle; // --- visualddkhelper.h --- class handle_visualddk_helper { }; typedef handle_visualddk_helper *handle_visualddk_helper_t; #define handle handle_visualddk_helper_t // ★ visualddk handle tweaker // --- user code --- void foo(handle s) { } //operator smy*()(void* ptr) { return (smy*)ptr; } // how can write type conversion operator user code compiles ok. int main() { char* s = "abc"; class user_struct1 { int m; } *pu1 = 0; class user_struct2 { int m; } *pu2 = 0; foo(s); foo(pu1); foo(pu2); // lots of these return 0; } i'm unwilling convert driver code like: foo((handle)s); foo((handle)pu1); foo((handle)pu2); // lots of these can c++ operator overloading me out?

ios - UBSDKRideRequesting authenticating issue -

i tried login code give below - or without using redirect_uri show error 1.there problem in authenticating you.please try again later i checked whole project there no other issue found. id<ubsdkriderequesting> behavior = [[ubsdkriderequestviewrequestingbehavior alloc] initwithpresentingviewcontroller: self]; cllocation *location = [[cllocation alloc] initwithlatitude: 37.787654 longitude: -122.402760]; ubsdkrideparametersbuilder *builder = [[ubsdkrideparametersbuilder alloc] init]; [builder setpickuplocation:location]; ubsdkrideparameters *parameters = [builder build]; ubsdkriderequestbutton *button = [[ubsdkriderequestbutton alloc] initwithrideparameters: parameters requestingbehavior: behavior]; button.frame=cgrectmake(10,self.view.frame.size.height+self.view.frame.origin.y,self.view.frame.size.width-20,50) ; [self.view addsubview:button]; please me solve issue. thanks

c# - The given value of type String from the data source cannot be converted to type varbinary of the specified target column -

i have datatable 1 column has image file path. need replace file path byte array of image. below code gives me error. the given value of type string data source cannot converted type varbinary of specified target column. for (int rowincrement = 0; rowincrement < dt.rows.count; rowincrement++) { byte[] photo = getphoto(dt.rows[rowincrement]["image"]); dt.rows[rowincrement]["image"] = photo; dt.acceptchanges(); } using (sqlbulkcopy copy = new sqlbulkcopy(sqlcon, sqlbulkcopyoptions.keepnulls | sqlbulkcopyoptions.keepidentity, null)) { copy.destinationtablename = "userdetails"; copy.writetoserver(dt); } the column type should specified otherwise columns value still string when need byte[] example: // add new column since cannot change type dt.columns.add("image_tmp", typeof (byte[])); (int rowincrement = 0; rowincrement < dt.rows.count; rowincrement++) { byte[] photo = getphoto(dt.rows[rowinc

ios - Remove data from core data using UILocalNotification -

i trying remove data code data model when local notification fired. notifications's alertbody ,then fetch sort data using notification title : func application(application: uiapplication, handleactionwithidentifier identifier: string?, forlocalnotification notification: uilocalnotification, completionhandler: () -> void) { if identifier == "deleteevent" { context = coredatastack.managedobjectcontext { request = nsfetchrequest(entityname: "event") let titlepredicate = nspredicate(format: "title contains[c] %@" ,notification.alertbody!) request.predicate = titlepredicate results = try context.executefetchrequest(request) print(results.count) // returns 1 } catch { print("error") } { results.removeatindex(0)

Matching algorithm for similarities -

i'm searching algorithm, articles, books or whatever, matching process. i'm writing datingapp , calculate lot of matches. search method solves issue thanks hint i asked similar question of the cs stack exchange , top answer starts the search terms you're looking "similarity measure", "dissimilarity", "distance function", or "metric"... applied trees.

how are we able to use the less than sign( '<'or even greater than( '>') ) in #include directive if c doesn't support operator overloading? -

we know c doesn't support operator overloading.can tell me if so, how able use less sign in #include directive , in comparison also? or functionality provided called else , defined in language? many symbols in c have different meaning depending on context. example: * can mean either multiplication or pointer dereference. such dual meanings makes bit tricky write c parser , trickier provide helpful error messages when code doesn't compile. note dual meaning not operator overloading. 2 separate operators. when comes #include directives answer processed pre-processor. after pre-processor step < , > gone - line has been replaced entire contents of include file.

Delphi Sent TObjectList like var parameter -

i have class tfolder = class node_index: integer; first_index : integer; code_name: ansistring; name: ansistring; constructor create(newnode_index, newfirst_index: integer; newcode_name, newname: ansistring); destructor destroy; override; end; and have type type tfolderlist = class (tobjectlist<tfolder>) end; then try use type taccount = class ... folders: tfolderlist; public constructor create(...); destructor destroy; override; procedure loadfoldersfromdisk(var _objectlist: tfolderlist); end; when try send tobject list parameter procedure tform1.formcreate(sender: tobject); begin ollocalfolders := tobjectlist<tfolder>.create(); account.loadfoldersfromdisk(ollocalfolders); end; i error "types of actual , formal var parameters must identical". i'm doing wrong? just replace tobjectlist<tfolder> wtih tfolderlist defined eariler: procedure tform1.formcreate(sender: tobject); be

json - php json_encode korean character broken. how to solve this? -

php json_encode korean character broken. how solve this? i used var_dump but need json type. my web hosting 5.2 php version, can't use print(json_encode($json_output, json_unescaped_unicode)); while($row=mysqli_fetch_assoc($query)) { $json_output[]=$row; } print(json_encode($json_output)); bellow broken character [ { "name":"chulhoon", "description":"\ud558\ud558\ud638\ud638", "dob":"\uc548\ub155\ud558\uc138\uc694", "county":"\ub9cc\ub098\uc11c", "height":"\ubc18\uac00\uc6cc\uc694", "spouse":"\ubb50\ub4e4\ud558\uc138\uc694", "children":"\uc774\ubbf8\uc9c0\uc55e\uc790\ub9ac", "image":"http:\/\/microblogging.wingnity.com\/jsonparsingtutorial\/johnny.jpg" } ] this not broken. these strange sequences unicode characters. can try use print(json

nixos - override services in nixpkgs for nixops deployment -

using nixops 1 can configure services like: { network.description = "web server"; webserver = { config, pkgs, ... }: { services.mysql = { enable = true; package = pkgs.mysql51; }; but want extend services . example using override done pkgs below: let myfoo = callpackage ... in pkgs = pkgs.override { overrides = self: super: { myfoo-core = myfoo; }; } question how services ? adding service requires first write service definition service. is, nix file declares options of service , provides implementation. let's our service called foo , write service definition save file foo.nix : { config, lib, pkgs, ... }: lib; # use functions lib, such mkif let # values of options set service user of service foocfg = config.services.foo; in { ##### interface. here define options users of our service can specify options = { # options our service located under services.foo services.foo

oracle - What would be the SQL query for this? -

Image
list name of clients have viewed property based on uml graph select [c-name] [client] join [property] on client.clientid = property.propertyid if i've understood uml model can't, view-appointment needs clientid , propertyid adding. then can do, give clients have appointment (obviously adding where on date column give future/past appointments): select [c-name] [client] inner join [view-appointment] on client.clientid = view-appointment.clientid; if want property details in query need inner join: inner join property on property.propertyid = view-appointment.propertyid

php - i want to display array in view in yii2 -

i want display array in view form don't know how ? can 1 me : controller code : $query = new query; $query ->select(['day_name']) ->from('days') ->join( 'inner join','doctorsworkday','doctorsworkday.day_id =days.dayid'); $command = $query->createcommand(); $dataprovider = $command->queryall(); $dataprovider= array($dataprovider); return $this->render('view', [ 'model' => $this->findmodel($id), 'days'=>$days, 'doctorsworkday'=>$doctorsworkday, 'dataprovider' => $dataprovider, ]) my view code : <?= detailview::widget([ 'model' => $dataprovider, 'attributes' => [ 'day_name' ], ]) ?> but shows : (not set) when use vat_dump($dataprovider) there array .. don't know how show enter var_dump well firstly using

jquery - Click event doesn't work on dynamically generated elements -

this question has answer here: event binding on dynamically created elements? 19 answers <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $("h2").html("<p class='test'>click me</p>") }); $(".test").click(function(){ alert(); }); }); </script> </head> <body> <h2></h2> <button>generate new element</button> </body> </html> i trying generate new tag class name test in <h2> clicking button. defined click event associated test . event doesn't work. can

javascript - How to disable list item of dropdown in angular js -

this html file this dropdown having 2 listitems password reset , send activation email want disable send activation email when current state= 'not ready'. <div class="active-send-select" pull-left btn-group title="{{::'title.button.send' | translate}}"> <button class="btn dropdown-toggle" data-toggle="dropdown" ng-disabled="user.entity.isgeuser == true"> <i class="fa fa-envelope fa-lg"></i> <span class="action-button-text">{{::'label.button.send' | translate}}</span> <i class="icon-chevron-down pull-right"></i> </button> <ul class="dropdown-menu filter-state"> <li ng-disabled="currentstate == 'not ready'" ><a href="" ng-click="openco

typescript - Cannot redeclare block-scoped variable -

Image
i have node program uses commonjs , therefore js files start number of require statements. renamed these js files ts hope incrementally move typescript getting these errors: from following code: const rsvp = require('rsvp'); const moment = require('moment'); const firebase = require('universal-firebase'); const email = require('universal-sendgrid'); const sms = require('universal-twilio'); const merge = require('merge'); const typeof = require('type-of'); const promising = require('promising-help'); const _ = require('lodash'); const = require('./upload'); const audience = require('./audiences'); const message = require('./messages'); the locally referenced modules upload , audiences , , messages are define (all?) of same modules such lodash , etc. i'm guessing somehow namespace scope not being respected between modules i'm not sure why. i'm unclear whether usin

Python Pandas self join for merge cartesian product to produce all combinations and sum -

i brand new python, seems has lot of flexibility , faster traditional rdbms systems. working on simple process create random fantasy teams. come rdbms background (oracle sql) , not seem optimal data processing. i made dataframe using pandas read csv file , have simple dataframe 2 columns -- player, salary: ` name salary 0 jason day 11700 1 dustin johnson 11600 2 rory mcilroy 11400 3 jordan spieth 11100 4 henrik stenson 10500 5 phil mickelson 10200 6 justin rose 9800 7 adam scott 9600 8 sergio garcia 9400 9 rickie fowler 9200` what trying via python (pandas) produce combinations of 6 players salary between amount 45000 -- 50000. in looking python options, found itertools combination interesting, result massive list of combinations without filtering sum of salary. in traditional sql, massive merge cartesian join w/ sum, players in d

python - Histogram of my cam in real time -

im trying show histogram in real time grayscale of webcam, problem histogram not being update , cam stop until close histogram's window. how can fix this? want show grayscale img webcam , histogram in same time, possible that? import numpy np import cv2 matplotlib import pyplot plt cap = cv2.videocapture(0) while(true): ret, frame = cap.read() gray = cv2.cvtcolor(frame, cv2.color_bgr2gray) cv2.imshow('janela', frame) cv2.imshow('outra', gray) plt.hist(gray.ravel(), 256, [0, 256]) plt.show() if (cv2.waitkey(1) & 0xff == 27): break cap.release() cv2.destroyallwindows() i have been working while in same task. after time, have piece of code works good. displays camera image in window , histogram in other. since i'm interested in finding colors, i'm working "hue" channel of each frame. # import necessary packages import cv2 import numpy np #create window display image cv2.namedwindow('col

javascript - Want to display HTML code for websites upon click a banner image -

i want display banner html code in popup websites when click on banner. for example banner is <img src="https://myweb.com/images/banners/1.gif"> i want display following data in popup on clicking banner image. <a href="myweb.com" target="_blank"><img src="https://myweb.com/images/banners/1.gif" border=0></a><br>[url=https://myweb.com] [img]https://myweb.com/images/banners/1.gif[/img] [/url] i don't have knowledge how issue can solved. please me in solving problem. thanks if looking display static text in popup, confirm or alert prompt work e.g: <a href="myweb.com" target="_blank" onclick="showhtml()"> <img src="https://myweb.com/images/banners/1.gif" border=0> </a> <script> function showhtml(){ alert("<img src=\"https://myweb.com/images/banners/1.gif\" border=0>"); } </script>

Drupal 8: Multistep ajaxified form in a modal window -

task description: i need open modal window url location hash i.e. www.example.com#overlay=my-multistep-form (pretty same d7 overlay module does). window should contain multi-step ajaxified form, so use drupal.behaviors.rf_overlay = { attach: function(context, settings) { // overlay url if (location.hash.indexof('#overlay') >= 0) { var event = { data: {} }; // special route multistep forms if (location.hash.indexof('#overlay=become-a-sales-partner') >= 0) { event.data.url = '/overlay/partner-form'; openmultistepformmodal(event); } } function openmultistepformmodal(event) { drupal.ajax({ url: event.data.url, success: function(response) { var content = ''; (var in response) { if (response[i].data != undefined) {

android - Issues faced in cordova installation in ubuntu -

using ubuntu cordova installation i enter on terminal **sudo add-apt-repository ppa:cordova-ubuntu/ppa response : sudo: /usr/bin/sudo must owned uid 0 , have setuid bit set failed create helloworld example , install cordova dependencies in ubuntu.

swt - Resizable row/column headers in NatTable -

i have nattable column , row headers, , use cornerlayer it. how make row , column headers resizable other column or row? you need register necessary bindings header regions gridlayer.addconfiguration(new abstractuibindingconfiguration() { @override public void configureuibindings(uibindingregistry uibindingregistry) { uibindingregistry.registerfirstmousemovebinding( new columnresizeeventmatcher(swt.none, gridregion.row_header, 0), new columnresizecursoraction()); uibindingregistry.registerfirstmousedragmode( new columnresizeeventmatcher(swt.none, gridregion.row_header, 1), new columnresizedragmode()); uibindingregistry.registerfirstmousemovebinding( new rowresizeeventmatcher(swt.none, gridregion.column_header, 0), new rowresizecursoraction()); uibindingregistry.registerfirstmousedragmode( new rowresizeeventmatcher(swt

java - How to protect API from from malicious usage -

we developing community portal service using java-spring , angular ui. going have android app soon. our back-end exposes many services via rest api. there couple of services allows anonymous posting , creating service requests. here our questions: how can protect api ddos-like attacks? can ip whitelisting or put cap on requests per minute set of apis? how can log such malicious requests?

linux - cross compile WebRTC for ARM -

i've tried cross compile webrtc armv7 architecture (allwinner a20).on www.webrtc.org there no instructions how that, android , ios, on internet i've found few posts how that, here it: webrtc building arm https://foxdogstudios.com/webrtc-on-linux https://groups.google.com/forum/#!topic/discuss-webrtc/yzuk8watmu8 https://github.com/mpromonet/webrtc-streamer/wiki/cross-compile-webrtc-for-raspberry-pi all of them written around 2 years ago , starts command: gclient config http://webrtc.googlecode.com/svn/trunk as understand it's old repository name , buildsystem changed last 2 years. can me complete instruction how build webtrc arm? not best solution cross-compile webrtc arm platform: install depot tools and... mkdir -p web_rtc && cd web_rtc export gyp_defines="os=linux" fetch --nohooks webrtc gclient sync cd src ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm gn gen out/default --args='target_os="linux"

php - wordpress - jQuery doesn't work in plug in, but works everywhere else? -

sorry easy question, (hey, easy rep!) i'm new php of 1 day. have create wordpress plugin/widget out of necessity. have en queued jquery in header: `<?php wp_enqueue_script("jquery"); ?>` and created class intended clicked in plugin. jquery('.court').click(function () { alert(jquery(this).attr('id')); }); simple stuff , works if place code within footer (which has nothing else in jq). not work if it's inside plugin. javascript alert('boom'); work in plugin. what missing in order use jquery within plugin? don't want put in footer since won't packaged there. i have create wordpress plugin/widget out of necessity. writing plugin scratch? if so; try adding code below anywhere in plugin's main file: <?php function mypluginscripts() { wp_enqueue_script( 'jquery-my-plugin', get_site_url() . "/wp-includes/js/jquery/jquery.js", array(), '')

sql - Oracle: Convert Full Date to a Different Date Format -

in oracle database,i have column of type varchar2 in table has entry this: wednesday, august 3, 2016 12:00:00 cest i wish convert 08-03-2016 i have tried use to_date followed to_char fails. guidance helpful. try one: select to_timestamp( regexp_substr('wednesday, august 3, 2016 12:00:00 cest', '\w+ +\d+, \d{4} \d{2}:\d{2}:\d{2} (a|p)m'), 'fmmonth dd, fmyyyy hh:mi:ss am') dual; resp. select to_char( to_timestamp( regexp_substr('wednesday, august 3, 2016 12:00:00 cest', '\w+ +\d+, \d{4} \d{2}:\d{2}:\d{2} (a|p)m'), 'fmmonth dd, fmyyyy hh:mi:ss am'), 'mm-dd-yyyy') dual; in case need day no time information had luck, because cest ambiguous, see this: select tzabbrev, tz_offset(tzname), tzname v$timezone_names tzabbrev = 'cest' order 2; tzabbrev tz_offset(tzname) tzname ======== ================== ============ cest +01:00

Oracle TO_DATE with only time input will add date component based on what logic? -

running code in oracle 11/12: select to_date('101200', 'hh24miss') dual will return date component oracle automatically adds based on logic? eg: select to_char(to_date('101200', 'hh24miss'), 'yyyymmdd') dual returns 20160701 we see added date component set first day of current month. logic come from? thanks in advance a value of date data type has date , time components. if specify time portion of datetime value did, date portion defaults first day of current month. here 1 of places (7th paragraph) in oracle documentation behavior documented. there undocumented time literal , time data type (needs enabled via 10407 (datetime time datatype creation) event) if need use , store time, without date part. here small demonstration of using time literal , time data type. again it's undocumented , unsupported feature. sql> select time '11:32:00' res 2 dual; res ------------------------ 11.

ipad - How to to determinate in Swift the current width of the app when in Split View? -

edit : have project row of buttons on top on it. buttons 5 in compact view , 6 in regular view. remove button when app runs in 1/3 split view. how can determine width of app? i'm using code determinate current width of app when in split view (multitasking): override func viewwilltransitiontosize(size: cgsize, withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) { // works it's deprecated: let currentwidth = uiscreen.mainscreen().applicationframe.size.width print(currentwidth) } it works, unfortunately applicationframe deprecated in ios 9, i'm trying replace this: override func viewwilltransitiontosize(size: cgsize, withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) { // gives width of screen not width of app: let currentwidth = uiscreen.mainscreen().bounds.size.width print(currentwidth) } the problem first statement gives effective width of a

android - if i have an jsonarray and i display it in listview and want a specifec item from the list how to do it? -

what im trying @ json pull names list view(save imdbid of names) , there can click on movie , go new intent bring movie clicked on name summary , image im searching in json array in looks this(it based on user searched 1 example...) {"search":[{"title":"batman begins","year":"2005","imdbid":"tt0372784","type":"movie","poster":"http://ia.media-imdb.com/images/m/mv5bntm3otc0mzm2ov5bml5banbnxkftztywnzuwmti3._v1_sx300.jpg"},{"title":"batman v superman: dawn of justice","year":"2016","imdbid":"tt2975590","type":"movie","poster":"http://ia.media-imdb.com/images/m/mv5bnte5nzu3mtyzof5bml5banbnxkftztgwntm5njqxode@._v1_sx300.jpg"},{"title":"batman","year":"1989","imdbid":"tt0096895","type":"movie"

node.js - Typing phonegap after installing Phonegap does nothing! *Elementary OS* -

i installed phonegap on system using command sudo npm install -g phonegap@latest . but when type phonegap run nothing happens. new this. if require more info i'll happy provide you. i have attached snapshot below: http://imgur.com/a/dhrst ok followed post , worked. link b/w node , nodejs not functioning should. recreating fixed me: https://askubuntu.com/questions/538996/executing-certain-commands-do-absolutely-nothing

nohup - How to cleanly shutdown a Grails standalone application? -

what best way stop grails application started with: nohup java -jar myapp.war --server-port=9090 & killall -9 java or killall -15 java that's ! command sends signals processes identified name. why -9 or -15 ? because use nohup prevents processes receiving sighup . so, must use -15 ( sigterm ) or -9 ( sigkill ) kill command.

JavaScript object search and get all possible nodes -

i have multidimensional object. need search string in each node , need return array of nodes contains string. e.g. object { "data": { "countries": "['abc','pqr','xyz']", "movies": { "actor": "['abc','pqr','xyz']", "movie": "['abc','pqr','x toyz']" } } and if want search 'pq' need array countries:pqr movies:actor:pqr countries:movie:pqr as result. you try , solve recursive function calls function parse(string, key, before) { return before+key+":"+string; } function findstring(string, json, before) { var results = []; (var key in json) { if (typeof(json[key]) === "string") { // string if (json[key].contains(string)) { // contains needs results.push(parse(string, key, before)); } } else { // ob