Posts

Showing posts from April, 2013

ios - Adding a circle blurred mask layer on UIView -

Image
i'm working xcode 8 , swift 2.3 starting this nice post , my own question , can 2 distinct effects, can't "join" it. : first 1 ( blur ): internal extension uiview { /** add , display on current view blur effect. */ internal func addblureffect(style style: uiblureffectstyle = .extralight, atposition position: int = -1) -> uiview { // blur effect let blureffectview = self.createblureffect(style: style) if position >= 0 { self.insertsubview(blureffectview, atindex: position) } else { self.addsubview(blureffectview) } return blureffectview } internal func createblureffect(style style: uiblureffectstyle = .extralight) -> uiview { let blureffect = uiblureffect(style: style) let blureffectview = uivisualeffectview(effect: blureffect) blureffectview.frame = self.bounds blureffectview.autoresizingmask = [.flexiblewidth, .flexi

javascript - Run a counter that is displayed on website -

i want run counter on end of website, counting. made javascript counter ( http://directinvent.com/counter/ ) displays desired result, although resets whenever site loaded each individual user. the idea simple enough. run counter end , display result live on front end. ideas on how can done? the same way timer in javascript. store when start counter. recalulate result on every update (request). no need math every 1/10s. if nobody ask, useless. basicly, : long starttime = storetimefor(user); return (currenttimeinsec - starttimeinsec) * incrementationpersec with this, need store starttime each user (in database, file, or in cache if want). on reset, store currenttime again. this how timer in lots of langage because incrementing value every seconds (using sleep(1000)) not precise since thread not running time, not alone on machine ;) edit : on client side, not call server, ask value store , math client same logic. using timeout math on , on every x ms. see how cr

python - No handlers could be found for logger “paramiko.transport” with lost connection -

use fabric sudo() , meet error message ! "no handlers found logger paramiko" file "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 603, in connect raise networkerror(msg, e) i meet same issue, think network not connect issue , use try syntax wait network ok. the following code retry send sudo() command , not show error when network connection normally. loop = 10 in range(0,loop) try: sudo("ls -al") except exception, exc : print "exception %s, exc %s"(exception, exc) print "i: %s in %s"%(i,loop)

angularjs - Required attribute in select tag generating "An invalid form control with name='d' is not focusable." -

i using angular-materialize. when press button modal opens , when don't select select tag options not validate required attribute instead push error field not focusable. <div id="modalwatch" class="modal bottom-sheet"> <h5 style="margin: 0px;">add device</h5> <div class="modal-content"> <div class="row"> <form autocomplete="off" class="col s12" name="dev_form" ng-submit="dev_form.$valid && devices.adddevice()"> <div class="row"> <div class="input-field col s4"> <select id="testtt" name="d" class="" data-error="wrong" data-success="right" ng-model="devices.newdevice.device_type_id" material-select watch required> <option value="

mysql - On Duplicate Key Update insert record every time -

i'm using mysql query insert table (vin,name,city,dob) values ('der12','john','city name','2016-17-10') on duplicate key update name='john' table structure id - bigint -primary key vin - varchar name - varchar city - varchar dob - varchar so here have id bigint , autoincreament , , vin can't duplicate , need check if vin in table , update record or nothing if same , if vin diffrent insert record. i tried making vin unique as alter table table add unique (vin) but problem after adding when run query shows duplicacy error instead of updating or ignoring . need kind . thanks in advance from understood, want add record if "vin" different else keep previous record is. you can count of records having "vin" "john" or value inserting currently. if count "0", insert record else nothing.

prestashop back office custom module template for listing OR override by module -

due ps documentation rather bare, 'd know if solve probelm @ subj. have last stable ps. 1.6.1.7 done many modules ... needs (custom table [created]: ok, custom listing [ordering, filtering]: ok): when click on row (subq: when add "addrowaction()" produce same ...), want see controllers edit/update page - escpecially: controller = adminproduct & updateproduct ... id_product given, dunno how pass:. specially: listing of ordered products (own modul, own list) want ovveride link it's automatically provide. i'm sure simple, found solution yet ... the question is: how override (must copy module structure?) list helper, other helpers ... or need write full .tpl got function(s) above ... well, implemented ugly solution q. ( codes :) ): part of _construct()...: $this->fields_list = array(); $this->fields_list['id_order'] = array( 'title' => $this->l('order id'), 'align' =&g

java - How to monitor kafka 0.10.0 running on remote machine using jmx? -

Image
i using kafka 0.10.0 running both in local , remote machine. when run "jvisualvm" command in terminal open java visualvm window , shows java application including kafka running in local machine. but when tried access kafka 0.10.0 running in remote machine shows error message can not connect server how monitor kafka 0.10.0 running on remote machine using jmx? edit 1===> start kafka server using command jmx_port=9999 bin/kafka-server-start.sh config/server.properties also verified process in pointing using command netstat -nlp | grep :9999 output: tcp6 0 0 :::9999 :::* listen 5429/java but when try connect through local machine giving same error you have specify jmx_port in kafka-server-start shell script before doing monitoring.

c# - Matching listview header to column dynamically uwp -

this how listview looks, headers scale relativepanel outside columns stay same width <grid name="listviewgrid" horizontalalignment="stretch"> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition /> </grid.rowdefinitions> <grid x:name="listviewgrid" > <grid.columndefinitions> <columndefinition width="*" /> </grid.columndefinitions> <textblock grid.column="0" text="observation id" /> </grid> <listview x:name="listview" grid.row="1" itemssource="{binding observations}" horizontalalignment="stretch"> <listview.itemtemplate> <datatemplate> <grid width="

Why is my angular2 app crashing when trying to load angular-in-memory-web-api? -

i have been following along tour of heroes tutorial cannot start app when trying load angular-in-memory-web-api. there error thrown says error: module parse failed: ... you may need appropriate loader handle file type. | return inmemorydataservice; ... i have looked on why might occurring cannot find reason. in dependencies section of package.json have included line "angular-in-memory-web-api": "0.1.13" i loading inmemorywebapimodule inmemorydataservice in app.module.ts. import { inmemorywebapimodule } 'angular-in-memory-web-api'; import { inmemorydataservice } './inmemorydb/db/in-memory-data.service'; ... imports[ ... inmemorywebapimodule.forroot(inmemorydataservice) any thoughts why might occur?

Angular2 comparing two arrays and objects and removing any that exist in both -

i writing application allows user add categories product. pulling every category though exists api , categories allocated product. want compare 2 arrays of objects , if category in allocated categories product don't want display option product allocated cannot add product category allocated to. here example of api data: allocated categories product: {id: "3", name: "vitamins , minerals ", description: "", created_at: "2016-08-15 09:21:05",…} all categories on application: 0: {id: "1", name: "detergents , disinfectants", description: "", created_at: "2016-08-15 09:21:05",…} 1 : {id: "2", name: "poultry equipment", description: "", created_at: "2016-08-15 09:21:05",…} 2 : {id: "3", name: "vitamins , minerals ", description: "", created_at: "2016-08-15 09:21:05",…} 3 : {id: "4", name: "gut health &q

in app billing - Android having multiple payment gateways for in app purchase -

i developing application users can purchase credits make voice/video calls. i did research , saw couple of well-known applications allow paying using multiple payment gateways paypal, cashu, etc. is safe add other payment gateways along google in-app? or risking having application removed play? thanks!

oop - Can we create a abstract class without using abstract keyword? -

this question asked interviewer in 1 of interviews. we can avoid creating instance of class using private constructor cannot inherit class thanks in advanve well can use private constructor, not make class abstract. it means other classes cannot create new instance of class. but class can still call own constructor through static method, therefore creating new instance of itself. if don't want class instanciated @ all, never ever, use abstract keyword...

java - How to prevent showing hidden buttons on reload? -

i have code hide button in angularjs, looks this: indexstud.html <button ng-show="show" ng-click="initstud(); btnshow()">init tables</button> controllers.js $scope.show=true; $scope.btnshow=function(){ $scope.show=!$scope.show; } now, added refresh button page indexstud.html <input type="button" value="refresh page" onclick="window.location.reload()"> it works this: i press init tables button, fills tables , disappears, , then, see content in tables, need refresh page... press on button refresh, , content in tables shows up... but, init tables button visible again...but want hidden forever once clicked... how that? my table looks this: <table> <tbody> <tr> <td>id</td> <td>first name</td> <td>last name</td> </tr> <t

ethereum - meteor templating@1.1.9 compressed file is damaged -

i'm running ethereum mist on windows 7. and wish running ethereum wallet. look @ image. has serveral 30 minutes. but has running. it looks templating@1.1.9 compressed file damaged. can me? i solve problem. how? i ran " meteor update ". so templating-compiler , templating-runtime packaged.

widget - Display Login form in Cms Page in Magento 2? -

how can display login form on cms page in magento 2? want add in block. way magento 1.x {{block type="customer/login" template="persistent/customer/form/login.phtml"}} you can use below structure resolve problem. syntax {{block class="[blockclassfullname]" template="[vendorname]_[modulename]::[youttemplatefile.location].phtml"}} example: {{block class="magento\bannerslider\block\slideshow" template="magento_bannerslider::bannerslider.phtml"}} code you {{block class="magento\customer\block\form\login" template="magento_customer::form/login.phtml"}}

apache kafka - Event sourcing in Flink -

i have flink application implemented following event-sourcing paradigm. both events , commands stored in several kafka topics. the application has 2 startup modes: recovery , production. first, recovery mode used recover application state (a savepoint) events topics. in mode, commands not read @ all. once event topics have been processed, savepoint triggered manually (from command line) , application stopped. then, yarn process started in production mode. in mode application processes both events , commands. i prefer execute process programatically. it, several questions arise... how can application itself: detect kafka sources have been readed? trigger savepoint programmatically? stop , start programmatically? thank you!

Jquery Add a delay in P text swap -

$(document).ready(function() { $("p").on("click", function() { var el = $(this); if (el.text() == el.data("text-swap")) { el.text(el.data("text-original")); } else { el.data("text-original", el.text()); el.text(el.data("text-swap")); } }); }); is possible add delay in jquery code? use settimeout sets timer executes function or specified piece of code once after timer expires. $(document).ready(function() { $("p").on("click", function() { var el = $(this); settimeout(function() { if (el.text() == el.data("text-swap")) { el.text(el.data("text-original")); } else { el.data("text-original", el.text()); el.text(el.data("text-swap")); } }, 1000); }); });

Join in Oracle SQL -

Image
is possible achieve below mentioned output table 1 , table 2 have tried joins outer join,left join,right join required output not achieved .please me . this can achieved using partition outer join : with table1 (select 2014 yr, 'main' division, 2000 amt dual union select 2015 yr, 'main' division, 6000 amt dual union select 2016 yr, 'main' division, 7000 amt dual), table2 (select 2014 yr, 'center' division, 100 amt dual union select 2015 yr, 'center' division, 200 amt dual union select 2016 yr, 'center' division, 350 amt dual), -- end of mimicking tables; wouldn't need above -- have tables. -- need following subquery define years you're querying -- against, though. can define either in clause -- or inline view in main sql below years (select 2014 yr dual union select 2015 yr dual union select 2016 yr dual union

html - Bootstrap - submenu as a untouchable and stable belt -

Image
when click in other place site, dropdown disappear. should still visible, , should change when click on other tab menu i think need change css: .nav { margin-bottom: 0; } .nav > li.dropdown.open { position: static; } .nav > li.dropdown.open .dropdown-menu { display:table; width: 100%; text-align: center; left:0; right:0; } .dropdown-menu>li { display: table-cell; } is affects wanted? note, have apply rules after bootstrap.css have been loaded in page.

javascript - Multiple select value if statement jQuery -

i have 2 select menus , i'm trying compare selected value of 1 cannot conditional statement working, please see comments in code below , in jsfiddle. here's code , jsfiddle : the expected value #purpose select menu "5". var selected attempt @ grabbing value #purpose select menu. $('#purpose').on('change', function() { if ( this.value == '8') { $("#business").show(); $("#investor-type").hide(); } else { $("#business").hide(); $("#investor-type").show(); } }); var selected = $("#purpose option:selected", this).val(); $('#investor-type').on('change', function() { if ( this.value == '1') { $("#disclaimer-form").show(); $(".disclaimer-content").show(); // having trouble else if below } else if ( this.value == "2" && selected == "5") { $("#disclaimer-f

dynamic - C# dynamically change the value -

i pretty new @ c# , had make primitive neuron app. works pretty good, except values don't update dynamically. the problem when change values in numericupdown want current function(selected in combobox ) recalculate , change value in richtextbox (the result box) i sure it's event thing, couldn't find anywhere. private void combobox1_selectedindexchanged(object sender, eventargs e) { if(combobox1.text=="suma") { decimal s = 0; decimal temp; (int = 0; < numericupdown1.value; i++) { var currentnumupdown = this.panel1.controls["numericupdown" + (100 + i).tostring()] numericupdown; var currentnumupdown2 = this.panel1.controls["numericupdown" + (200 + i).tostring()] numericupdown; temp = currentnumupdown.value * currentnumupdown2.value; s = s + temp; } richtextbox1.text = s.tostring(); fin = s; } if (combobox1.text ==

scheduling - How to add a `nice` switch to my bash script -

i have bash script runs jobs. want able run jobs nice lower priority on server. for example, if executable a.out , can run terminal nice a.out lower job priority. in bash script have variable nice . 1 of following 2 things: # either nice set nice="nice" # or left unset nice="" i run job using "$nice$ ./a.out later in script. this works when nice="nice" not work when nice left set nice="" . one way around use if statement: if [ "$nice" == "nice" ] nice ./a.out else ./a.out fi but becomes 5 or 6 lines of code rather single line. is possible accomplish attempting using nice variable launch executable niceness or no niceness? your first guess almost right. from bash man page (emphasis mine): explicit null arguments ("" or '') retained , passed commands empty strings. unquoted implicit null arguments, resulting expansion of parameters have no

CSS or jQuery not working inside javascript -

i working on website in header try inspire people text changing javascript. 1 of lines appear among text includes link video, supposed modal video, somehow fails load while other videos outside of javascript work fine. here video of problem. i not sure, isn't working here. css or jquery? <!doctype html> <html lang="en-us"> <head> <!-- load latest jquery 3.1.1 --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <style> .modal.fade.in { top: 20%; } .fade.in { opacity: 1; } .modal.fade { -webkit-transition: opacity .3s linear, top .3s ease-out; -moz-transition: opacity .3s linear, top .3s ease-out; -o-transition: opacity .3s linear, top .3s ease-out; transition: opacity .3s linear, top .3s ease-out; top: -25%;

java - Flatten a Map<Integer, List<String>> to Map<String, Integer> with stream and lambda -

i flatten map associates integer key list of string , without losing key mapping. curious though possible , useful stream , lambda . we start this: map<integer, list<string>> mapfrom = new hashmap<>(); let's assume mapfrom populated somewhere, , looks like: 1: a,b,c 2: d,e,f etc. let's assume values in lists unique. now, want "unfold" second map like: a: 1 b: 1 c: 1 d: 2 e: 2 f: 2 etc. i (or similarly, using foreach ): map<string, integer> mapto = new hashmap<>(); (map.entry<integer, list<string>> entry: mapfrom.entryset()) { (string s: entry.getvalue()) { mapto.put(s, entry.getkey()); } } now let's assume want use lambda instead of nested for loops. this: map<string, integer> mapto = mapfrom.entryset().stream().map(e -> { e.getvalue().stream().? // here can iterate on each list, // best try give me flat map each key, // wouldn't know how flatten.

apache - MAMP Apache2 new vhost 404 error -

i'm trying set new vhost did several times before. im using mac , mamp , configure this: /applications/mamp/conf/apache/extra/httpd-vhosts.conf enter: <virtualhost *:80> documentroot "/users/riggi/phpstormprojects/laufschuhsilex/web“ servername laufschuh.local </virtualhost> in /etc/hosts enter: 127.0.0.1 laufschuh.local then restart apache. works , still works many (>20) other local websites. 2 new sites i'm trying add wont work , return 404. any hints on look? i believe quotation mark formatting issue. how close quote @ end of documentroot formatted differently opening quote. make sure formatting correct copy correct quotation mark (the opening quotation mark) , paste on closing mark. can happen when text copy-pasted 1 place another.

python - How can I find if a selected feature's values have increased in a pre-post feature selection study? -

i have set of features pre , post intervention values, , i'm running feature selection methods find informative ones , know features improved after intervention. my question ¿is there way know if selected features have bigger or lower value after intervention? i using following scikit-learn methods: - gradientboostingclassifier - linearsvc - variancethreshold - selectkbest - randomforestclassifier - rfecv - extratreesclassifier i guess results of selection show me ones informative, i.e. significant in order differentiate between before , after intervention, cannot find if significance means improved or diminished. scikit-learn provide way this? thank much.

c# - Does this code defer retrieval of the event logs until they've been queried? -

where log object of type eventlog , code... log.entries.cast<eventlogentry>().where(x => x.timegenerated == mydate).tolist(); ...somehow query (my where lambda) prior retrieving of logs performs better? (similarly how ef db query) or first pull entire log memory , filter there? if latter, 'best' (i.e. fast, , more 'performant') use this approach instead (i.e. pass in xml , let query lifting)? i may have worded little awkwardly, i'm asking if first approach mentioned inefficient querying. no not perform better, because log.entries implement simple ienumerable , not iqueryable (like ef example). means not analyze "where" clause expression tree , not convert somehow event query before enumeration. query same as: var result = new list<eventlogentry>(); foreach (eventlogentry x in log.entries) { if (x.timegenerated == mydate) { result.add(x); } } return result;

python - How to set minimum number of characters for user password in django-allauth -

i want change account_password_min_length in django-allauth. tried account_password_min_length = 5 in settings.py , not working, django still saying need enter 8 characters, default. here settings.py file: # application definition installed_apps = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', 'taggit', 'django_summernote', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'user_account', 'widget_tweaks', ] site_id = 1 middleware = [ 'django.middleware.security.securitymiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csr

c# - Casting ExceptionLoggerContext to HttpContext -

i've written exception logger implementing system.web.http.exceptionhandling.exceptionlogger class. we have generic exception logging services, 1 of implementations raygun. uses httpcontext.current can seen here: https://github.com/mindscapehq/raygun4net/blob/master/mindscape.raygun4net/raygunclient.cs on line 337 . public override void log(exceptionloggercontext context) { httpcontext.current = ...; exceptionservice.logexception(context.exception); } is possible convert / cast: system.web.http.exceptionhandling.exceptionloggercontext system.web.httpcontext ? you can following public override void log(exceptionloggercontext context) { httpcontext httpcontext = gethttpcontext(context.request); exceptionservice.logexception(context.exception); } private static httpcontext gethttpcontext(httprequestmessage request) { httpcontextbase contextbase = gethttpcontextbase(request); if (contextba

jquery - How to use HTML property "readyState" going to angularjs Controller -

hello guys basic question. want evalute objects status using readystate property seems theres problem on codes below html code: <object id="mypdf" type="aplication/pdf" data="{{xample.pdf}}"></div> controller code: var x = angular.element(document.getelementbyid('mypdf'); var status = x.readystate; console.debug(status); but consolde.debug returns "undifined" status. seems wrong? thank you

java - Dynamically adding options to a listpreference -

i writing program has preferenceactivity , multiple preferencefragment . 1 of options user selects server connect to, populated xml. <string-array name="server_names"> <item>test</item> <item>item1</item> <item>item2</item> </string-array> <string-array name="server_addresses"> <item>10.10.10.1</item> <item>10.10.10.2</item> <item>10.10.10.3</item> </string-array> this works fine , 3 names in list. there separate fragment allows user enter name , ip address added drop down option. i have got working solution involved loading external file, clearing entries , adding ones file. 'ok' want use sharedpreferences save these values. question this, how use editor write options saved each time app launched? i have looked @ using editor , putstringset , commit added option doesn't appear in drop down. there related posts seem de

c# - How to define and store menustrips and context menus in a class library in a designer-editable way? -

i have plug-ins defined class libraries in c# (visual studio 2010). each of these plug-ins, after being loaded, should add own menu items main menu of main app, , context-menus other gui components. these plug-ins implemented class libraries, how design, define, , store menus , context-menus? afaik, cannot part of class library designer-editable files. i found article, more complete discussion of question: how can use visual studio designer without form but, surprised why vs developers haven't provided designer standalone visual components (such menustrips , context menus) designed , used freely without dependency on specific form object (i.e., bound many other different forms or other visual components later), , not providing designer these objects seems such big lack in vs.

What is the most efficient way to deep clone an object in JavaScript? -

what efficient way clone javascript object? i've seen obj = eval(uneval(o)); being used, that's non-standard , supported firefox . i've done things obj = json.parse(json.stringify(o)); question efficiency. i've seen recursive copying functions various flaws. i'm surprised no canonical solution exists. note: reply answer, not proper response question. if wish have fast object cloning please follow corban's advice in answer question. i want note .clone() method in jquery clones dom elements. in order clone javascript objects, do: // shallow copy var newobject = jquery.extend({}, oldobject); // deep copy var newobject = jquery.extend(true, {}, oldobject); more information can found in jquery documentation . i want note deep copy smarter shown above – it's able avoid many traps (trying deep extend dom element, example). it's used in jquery core , in plugins great effect.

jquery - Send html table to controller in MVC by ajax As JSON Object in datatable -

i'm using datatables jquery plugin , i'm having trouble reference below link can download table json, https://datatables.net/extensions/buttons/examples/html5/customfile.html but in case want save table json in variable send controller use angular or jquery ajax i can using tabletojson library store showing row in current page not full rows { var table = $('#datatable').tabletojson();} if you're using client-side processing, can retrieve data whole table using data() api method. var data = $('#datatable').datatable().data();

twig - GRAV cms how to use image from theme folder in page theme -

i use image, user can upload theme folder , show on page. use media functions like: negate, lightbox, cropzoom on image. know how display images is, using code: <img src="{{ url("theme://images/pages/" ~ category.image) }}" alt="{{ category.category_name|e }}" /> but can not use of above functions. more on trying use markdown if did set config , put markdown=“1” in template wasn't able use markdow – showing literal without compilation, when using code from: https://learn.getgrav.org/cookbook/general-recipes#wrapping-markdown-into-html probably impossible becouse according grav documentation: https://learn.getgrav.org/content/image-linking if decide use centralized image directory, advised directory should exist within /pages folder folder intended front-facing content. i should read ealier.

r - Increase space between x-axis factors in ggplot -

Image
i using geom_pointrange function in ggplot2 in order plot spread of measurement on different condition 5 subjects. in order not have subjects overlap have constructed plot follows: final = structure(list(subject = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 5l, 5l, 5l, 5l, 5l, 5l, 5l, 5l), .label = c("1", "2", "3", "4", "5"), class = "factor"), x00.conditionname = structure(c(1l, 1l, 2l, 2l, 3l, 3l, 4l, 4l, 1l, 1l, 2l, 2l, 3l, 3l, 4l, 4l, 1l, 1l, 2l, 2l, 3l, 3l, 4l, 4l, 1l, 1l, 2l, 2l, 3l, 3l, 4l, 4l, 1l, 1l, 2l, 2l, 3l, 3l, 4l, 4l), .label = c("eyeclose-haptic", "mixed-haptic_visual", "only-haptic", "only-visual"), class = "factor"), x03.totaltargetnumber = c(2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2l, 3l, 2