Posts

Showing posts from February, 2011

go - Disable logging for 3rd party library -

i using third party library in 1 of tools uses standard logging golang. library https://github.com/jason0x43/go-toggl now wrote command line utility instruments toggl , not want have logging written there. found go: disable log.logger? deals disabling within own code. how can disable logging in library? that package defines it's own logger, doesn't export it, , provides no hooks modify output. won't able change log destination without modifying package code. another option in case since logger writes os.stderr , redefine os.stderr own io.writer intercept , filter log output there. may simple buffering stderr output, , printing out in case of error.

asp.net mvc - How can I enforce url conventions for my web application? -

as architect, application i'm building has rest-compliant url scheme represents domain accurately, want way enforce convention has following properties: pit of success (easier dev right wrong) follows class convention, unless doesn't, in case it's overridable routes stored in centralized location in codebase takes advantage of type system (strongly-typed controller actions instead of inspecting request variables parameters inside action) versionable in experience, class naming , action naming conventions fall apart (the domain model doesn't follow object model, or developers find difficult debug routes), , application reverts attribute routing. attribute routing has number of drawbacks, , can become wild west environment several url styles grow together. what's out there solve seemingly common problem? well, you're looking third option doesn't exist. traditional routing , attribute routing pretty cover scenarios. use weighing pros ,

Git pull doesnt work as expected -

... because use wrong. szenario: have local repository , remote repository (named staging). developed on local repository , committed , pushed remote repository. then, on remote repository, added file "newfiletest". expected when locally "git pull staging master", should download "newfiletest" file, doesnt. hope :p i'm kinda new git. so did work on local repository , did git add -a git commit -m "embrace epic programming skills" then decided want push upstream remote did git remote add <remote_name> <url> and then git push -u <remote_name> <branch> git asks username , password authentication reasons , poof! pushed stuff upstream. now then, decide make new file (ex. .gitignore, readme.md etc.) on git hub . , run git pull this should fetch , merge changes on top of local repoistory

How to re-write a Jenkins DSL file as a Jenkins pipeline jenkinsfile? -

i have following jenkins dsl file: if (params["build_snapshot"] == "true") { parallel( { build("company-main-build-snapshot") }, { build("1-company-worker-build-snaphsot", worker_name: "sharding-worker") } ) } parallel ( { build("company-deployment-info", api_key: "aaaaa5dd4cd58b94215f9cddd4441c391b4ddde226ede98", app: "company-staging-app") }, { build("company-salt-role-deploy", env: "staging", role: "app") }, { build("company-deployment-info", api_key: "aaaaa5dd4cd58b94215f9cddd4441c391b4ddde226ede98", app: "company-staging-shardwork") }, { build("company-salt-workers-deploy", environment: "staging",

how to un fork the github repository? -

Image
how un fork github repository? i have never seen unfork option knows how that? select respoitory want unfork goto settings select delete repository .

Powershell Invoke-RestMethod "Unable to connect to the remote server" -

i write simple powershell script post json string server. have strange issue when execute script. the server inside our intranet, firewall disable intranet server. i tried execute script in different places: powershell window in own computer (windows 7, powershel 5) powershell ise in computer start powershell.exe in command prompt in own computer start powershell.exe in third party command prompt application in own computer powershell window in citrix seesion (windows 10, powershel 5) start powershell.exe in command prompt in citrix seesion i checked of 6 places have executionpolicy "remotesigned", but, can execute script in last 3 places, in first 3 place, error invoke-restmethod : unable connect remote server @ f:\temp\test.ps1:46 char:9 + $resp = invoke-restmethod -method post -body $result ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [invoke-restmethod], webexception

ios - Specifying z-order (sendSubviewToBack, etc.) on UIStackView -

according apple docs: the order of subviews array defines z-order of subviews. if views overlap, subviews lower index appear behind subviews higher index. i can see case, trying have arrangedsubviews manually reordered using sendsubviewtoback , having no effect. how can adjust z-order of arrangedsubviews in uistackview?

python - Non-error message from another script when importing library -

i produced strange error today, using python 2.7 on windows 10 system. wrote python script, c:\users\$me\copy.py looking this: import subprocess import sys try: out = subprocess.check_output("do_stuff.bat") except subprocess.calledprocesserror e: print "doing stuff failed." do_stuff_did_something = out.find("string found in do_stuffs output.") if do_stuff_did_something == -1: print "do_stuff didn't it." else: print "do_stuff did it." so far, good, works fine , it's supposed do: run batch file, specific string in output, , return message according whether found string or not. some time afterwards, installed openopc library. @ point don't remember, started happening: c:\users\$me>python python 2.7.11 (v2.7.11:6d1b6a68f775, dec 5 2015, 20:40:30) [msc v.1500 64 bit (amd64)] on win32 type "help", "copyright", "credits" or "license" more information. >&g

javascript - Efficiently convert string based time into milliseconds -

i given challenge, create function that'd convert string based time milliseconds. that's string format given: "hours:minutes:seconds.milliseconds" so value example need return 3010220. "0:50:10.220" the function needs short , 1 lined. i'd love know improve function below didn't pass criteria. how can turned 1 liner? function tomilliseconds(time){ return time.match(/[0-9]+/g).map(function(val,s,a){ return s != 3 ? +val * ((math.pow(60,a.length - s -2) * 1000)) : +val; }).reduce(function(a,b){ return a+b; },0); } there many different ways. this shortest way can think of (using es6): var str = "0:50:10.220"; var ms = (s=>1e3*s[2]+6e4*s[1]+36e5*s[0])(str.split(':')); console.log(ms);

angularjs - Angular Directive not updating element using interval -

i have directive angular.module('mydirectives').directive('slideshow', function ($interval) { return{ scope:{slideshow:'=slideshow'}, link:function(scope, element, attrs){ element.css("background-size","cover"); element.css("background-repeat","none"); element.css("background-position","center center"); element.css("background-blend-mode","color"); element.css("background-color","rgba(0, 0, 0, 0.5)"); scope.index=0; function nextslide() { if(!scope.slideshow) return; if(scope.slideshow.sources.length===0) return; var url=scope.slideshow.sources[scope.index++]; if(scope.index>=scope.slideshow.sources.length) scope.index=0; element.css({'background-image': 'url(' + url +')'}); }

CakePHP adding image to echo $this->Html->link -

hi have tried various things not sure if trying on complicate things. quite want add small image country flag word 'spanish' , 'english' , have 'alt' tag words instead. following works fine text , cool have image either replace or sit side side word. available? echo $this->html->link('spanish', array('controller'=>'settings', 'action'=>'lang', 'spa'), array('rel'=>'nofollow')); } else { echo $this->html->link('english', array('controller'=>'settings', 'action'=>'lang', 'eng'), array('rel'=>'nofollow')); } you can either output linked image using image method url attribute:- <?php echo $this->html->image( 'spain.jpg', array( 'alt' => 'spanish', 'url' => array('controller' => 'se

sql server - ADO recordset has no recordcount with source set to ADO command (stored procedure) -

i have ado command object in vba running , returning values stored procedure (in sql server). validate sp , command lines in vba, i've used copyfromrecordset method view data , seems fine. set adocomm = new adodb.command adocomm .activeconnection = adoconn .commandtype = adcmdstoredproc .commandtext = "generatemastersumifs" .parameters.append .createparameter("importfilepath", advarchar, adparaminput, 100, textfilesavepath) end set adorec = new adodb.recordset set adorec = adocomm.execute i'd able navigate returned records using find or getrows (for example) recordset appears have no data (recordset.recordcount returns -1). i've tried research online , have seen references cursor types being restricted depending on source (in case, sql server) haven't been able find solution can understand , use. so, question(s), specifically, are: can continue use ado command/recordset combination collate data 'navigate'

logout - Unable to redirect to CAS for single log out from spring -

i developing application has angular2 frontend , spring boot backend. authentication using cas. single sign on working properly, single log out not working , not redirecting cas/logout endpoint.(i sending post spring boot app's /logout url angular app ) cas version - 4.2.2 cas client core - 3.4 i followed http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-jc.html#m3to4-filter-urls-cas , did necessary changes authentication filter , logout filter. still couldn't identify issue. appreciated. security config @configuration @enableglobalmethodsecurity(prepostenabled = true, jsr250enabled = true) @enablewebsecurity public class securityconfiguration extends websecurityconfigureradapter { @autowired private authproperties properties; @override protected void configure(httpsecurity http) throws exception { http .addfilterafter(csrfheaderfilter(), csrffilter.class) .addfilterbefore(req

Add data between HTML tags to PHP array -

suppose have php variable bunch of data in tags. this: $target_element = '<td colspan="3"> data header 1 </td> //colspan can not changed class or id. <td class="data_title"> title1_1 </td> <td class="data_item"> data1_1 </td> <td class="data_title"> title1_2 </td> <td class="data_item"> data1_2 </td> <td class="data_title"> title1_3 </td> <td class="data_item"> data1_3 </td> <td colspan="3"> data header 2 </td> <td class="data_title"> title2_1 </td> <td class="data_item"> data2_1 </td>

python - How to select a group of minimum values out of a numpy array? -

fitvec = np.zeros((100, 2)) #initializing fitvec, first column` indices , second column contain values after initialization, fitvec gets assigned values running function. final fitvec values: fitvec [[ 2.00000000e+01 2.42733444e+10] [ 2.10000000e+01 2.53836270e+10] [ 2.20000000e+01 2.65580909e+10] [ 2.30000000e+01 2.76674886e+10] [ 2.40000000e+01 2.88334239e+10] [ 2.50000000e+01 3.00078878e+10] [ 2.60000000e+01 3.11823517e+10] [ 2.70000000e+01 3.22917494e+10] [ 2.80000000e+01 3.34011471e+10] [ 2.90000000e+01 3.45756109e+10] [ 3.00000000e+01 3.57500745e+10] [ 3.10000000e+01 3.68594722e+10] [ 3.20000000e+01 3.79688699e+10] [ 3.30000000e+01 3.90782676e+10] [ 3.40000000e+01 4.02527315e+10] [ 3.50000000e+01 4.14271953e+10] [ 3.60000000e+01 4.25365930e+10] [ 3.70000000e+01 4.36476395e+10]] **i haven't shown of 100*4 matrix make less messy. want select twenty (20*4) minimum values out of it. i'm trying

esper - Eseper event timeout -

i want timeout events individually each incoming event in esper. how achieve that? if use time or batch windows, wait other events first fill window ,only events moved rstream. use named window keep-all , put condition when events deleted on-delete. create window customexpirywindow.win:keepall() myevent insert customexpirywindow select * myevent on <.......> delete customexpirywindow <......> in alternative there extension api data windows write code keep , expire events.

Passing variable into MySQL using Python 2.7 -

i've been trying insert string value variable in python 2.7 mysql statement. can't seem work, point me in right direction? import mysqldb country_name = raw_input("which country like?\n") dbh = mysqldb.connect(host="localhost", user="boole", passwd="****", db="mysql_experiment_1") sth = dbh.cursor() sth.execute("""select name, population world name=(%s)""", (country_name)) row in sth: print row[0], row[1] it outputs: /usr/bin/python2.7 "/home/boole/documents/python scripts/mysql_experiment_1/main.py" country like? canada traceback (most recent call last): file "/home/boole/documents/python scripts/mysql_experiment_1/main.py", line 10, in <module> sth.execute("""select name, population world name=(%s)""", (country_name)) file "/usr/local/lib/python2.7/

audio tracks are missing in webrtc call upgrade -

we facing strange issue in webrtc call i.e. in connected webrtc audio call when 1 upgrade call(add video) audio tracks drops orignator side. steps reproduce problem 1.make audio call between 2 peers , b. 2.updgrade call video calling getusermedia again peer a. 3.call established. 4.a can hear audio , view video. 5.b cant hear audio. what expected result? onaddstream(e) e.stream should contain both audio , video tracks what see instead? video track there @ b's side (recipient) what version of product using? on operating system? chrome 51/windows7 please find webrtc dump below link webrtc dump

spring - Failed login and redirect from Okta login page -

i using spring security authenticate saml , okta, works, able authenticate user , access secured urls within application. far good. now have requirement special type of 'internal' users use different authentication mechanism (those users not in ad nor okta) - if authentication fails using okta want display different login page. problem unable redirect okta login page custom page after unsuccessful login, seems okta not redirect after many unsuccessful attempts. is there way implement such requirement? you can't redirect okta on failed authentication. need determine type of authentication use prior validating username , password. okta supports application based custom login page , when user tries access application, okta redirects login page. there login page determine authenticate user. okta configuration custom login page you can use okta's authentication apis , sdks authenticate against ad , custom code.

asp.net - login to the SharePoint 2013 using c# -

is way login sharepoint 2013 using c# code , token of sharepoint 2013, if yes how can do? means user put username , password client side , auth window auth configured on sharepoint 2013 in case please specify sharepoint 2013 config also now created api in mvc , it's working netwrokcredential class available in c# not getting token sharepoint you can use client side object model create context credentials. using (clientcontext context = new clientcontext("http://site_url/")) { context.credentials = new networkcredential("user_login", "user_password", "domain"); list list = context.web.lists.getbytitle("my list"); context.load(list); context.executequery(); console.writeline(list.id); console.readkey(); }

Swagger - Set the "response" based on "consumes" -

is possible specify "response" based on "consumes" option on swagger? my api can return "json" or "text" , i'd "example value", when response's status 200 changes if user selects response content type option application/json or text/plain . this piece of swagger.json file: { "swagger": "2.0", "produces": [ "application/json", "text/plain" ], "consumes" : [ "application\/json" ], "paths": { "/writer/1/": { "get": { "summary": "get writers", "description": "writer description.", "tags": [ "writer" ], "responses": { "200": { "de

google apps script - Find text in string, case insensitive -

i have made small script check expenses. in description term. search within string (like supermarket brand). unfortunately, can check case sensitive. how fix this? want search within string independent of case. search terms can upper of lower case, easy adjust. for (i in uitgaven) { for(n=0;n<data.length;++n)// iterate row row , examine data in column { if(data[n][3].tostring().match(uitgaven[i][0])==uitgaven[i][0]){ data[n][4] = uitgaven[i][1] }; } just substitute this: data[n][3].tostring().touppercase()===uitgaven[i][0].touppercase() for this: data[n][3].tostring().match(uitgaven[i][0])==uitgaven[i][0]

How to convert input field value to other language using javascript/jquery -

i need 1 help. need convert text field or input field values selected language using javascript/jquery. explaining code below. <div id="google_translate_element"> <div class="form-group"> <label for="usr">name:</label> <input type="text" class="form-control" id="usr"> </div> <div class="form-group"> <label for="comment">comment:</label> <textarea class="form-control" rows="5" id="comment"></textarea> </div> <button type="button" class="btn btn-success" id="conv" onclick="convertootherlanguage()">convert</button> </div> <script src="//translate.google.com/translate_a/element.js?cb=googletranslateelementinit"></script> my script given below. function convertootherlanguage(){ var name=document.getelementby

matlab - Does A Function's Workspace Duplicate A Variable Input? -

i have defined in base workspace variable a = ones(10); and create function inputs vector vec1 , gives vec2 : function vec2 = myfun(vec1) operations vec1 end lets make b = myfun(a); in workspace of myfun have variable called vec1 has same values a not in base workspace. when being in debugging mode , using dbup; i can see 2 different variables a , vec1 in base , myfun workspaces respectively. is myfun duplicating variable in 2 different workspaces (and therefore using more memory)? if not case, how work? pointer assigning 2 different names same information? thank in advance. matlab uses system commonly called "copy-on-write" avoid making copy of input argument inside function workspace until or unless modify input argument. if not modify input argument, matlab avoid making copy. instance, in code: function y = functionoflargematrix(x) y = x(1); matlab not make copy of input in workspace of functionoflargematrix , x not

c# - is it right to use dapper and MongoDb in one application -

i'm developing bpm (business process management system) in asp.net c# , workflow foundation 4.5. bpm systems have allot of process , each process has many forms. made easy using json data store forms data in 1 table, there no need create many tables each process approach effect process searching service (advanced search process business intelligence , business analysis ), im thinking use mongodb store forms' data , search in it. approach , practice? another question using windows workflow foundation idea, didn't see lot of systems using lately

javascript - Getting the user's google identity from a chrome app -

i thought had things rolling i've discovered have error after calling getauthtoken interactive:false : oauth2 request failed: service responded error: 'bad request' 'bad request' tells me little. ok, understand i'll need use interative:true (why?) , when attempt that, spawns browser, prompts google login (which enter , real pain because have 2-step authentication), does... nothing... callback never called... anyone interested in helping me out want see bits manifest.json: "key": "mii...qab", "oauth2": { "client_id": "35...-lnf...1pd.apps.googleusercontent.com", "scopes": [ "identity" ] }, "permissions":[ "identity", "https://accounts.google.com/*", "https://www.googleapis.com/*", "https://*.amazonaws.com/*", "<all_urls>" ], you'll want see code in question: chrome.identity.getauthtoken({ 'in

ios - Create view like details of apple app store -

Image
i looking create control apple shows on app store under details expanded view. looks uipageviewcontroller uipagecontrol unable achieve part of left , right view on either side of selected screen. or uicollectionview inside uiscrollview uipagecontrol?

javascript - AngularJS calculate two dynamic values from an array -

i new web development , ran problem arrays in angularjs. i have ng-repeat sequence. in sequence 2 sliders, repeated on , on due ng-repeat . the corresponding html snippet looks this: <h1>index = {{index}}</h1> <div ng-repeat="alert in alerts"> <rzslider rz-slider-model="alert.value" rz-slider-options="alert.options"></rzslider> <br> <br> <div> <h4>{{alert.weighttitle}}</h4> <div> <md-slider flex md-discrete ng-model="alert.weight" step="1" min="1" max="100" aria-label="rating"></md-slider> </div> </div> </div> considering all links , scripts included , controller correctly set up. the code above following: it displays $scope.index angularjs controller. two different sliders appear iterate through array called alerts. there takes

java - How does google-services.json replace default_web_client_id? -

first i'd have google play sign in , working. have struggling understand how specific line of code works. googlesigninoptions gso = new googlesigninoptions.builder(googlesigninoptions.default_sign_in) .requestidtoken(getstring(r.string.default_web_client_id)) .requestemail() .build(); i know how requestidtoken getting real clientid. when investigating: default_web_client_id = 0x7f060035 when log r.string.default_web_client_id get: 2131099701 when log getstring(r.string.default_web_client_id) get: xxxxxxx-xxxxxxxxx0tfctc0fa0a.apps.googleusercontent.com(my web client id) this id not located in strings or resources folder. in google-services.json file. my question how getstring or default_web_client_id resolving clientid in json file? thanks in advance enlightenment! according this apply gradle plugin generates new xml file values json

Postgresql databse with duplicate rows keep only the rows with true -

i've got 3 columns: groupid id yes/no/1 the database consists of rows duplicate values group (same group) want remove duplicate groups , have uniek group values. want keep te duplicate rows yes , remove rest. so: if have 100 rows groupid 502 , there 400 no's, 50 "1", , 50 yes want have 1 row groupid 502 , should yes. please help use distinct on remove duplicate rows. select distinct on (groupid) groupid, column_3 table_name column_3 'yes';

javascript - Update a Google Map Marker position by it's ID -

i creating google map markers , assigning them id follows: var marker = new google.maps.marker({ position: new google.maps.latlng(data.latitude, data.longitude), map: map, id: data.id }); this results in markers appearing on map want update position of markers @ later time, how can grab marker id have assigned , update it's position? i understand can update position setposition(latlng:latlng) on marker object in google api how grab marker it's id? try code <script src="https://maps.googleapis.com/maps/api/js?key=your-api-key&libraries=places" type="text/javascript"></script> <script> $(document).ready(function () { var long = $('#contentplaceholder1_hidlog').val(); var lati = $('#contentplaceholder1_hidlat').val(); var mapcenter = new google.maps.latlng(lati, long); var map; ma

angularjs - http post password to node.js server from angular -

this bugging me. know can following: $http.post('https://url:8080/api/registeruser?username=' + usrname + '&usrpassword=' + usrpassword); but i'm guessing isn't right way of passing password server. i've tried this: $http({ method: 'post', url: url2, data: { username: encodeuricomponent(usrname), userpassword: encodeuricomponent(usrpassword) }, headers: { 'content-type': 'application/x-www-form-urlencoded' } }); but can't find data anywhere on req in node.js when receives it. doing wrong here? you can find: post data on req.body get parameters on req.query route parameters on req.params req.body.username example

ios - NSPredicate filter inherited object in coredata -

question hi all, here have designed coredata (i'll write simple possible, while real data more complex): product (abstract) - nsstring *productname - nsdecimalnumber *productprice - nsstring *producttype productcomplex : product - (nsset <productsimple *> *)childproducts productsimple : product - (productcomplex *)parentproduct so basically, product abstract type, has 2 properties: name , price. there 2 inheritances product: productcomplex : may have many child products. productsimple : may child of complex product or not. then, have list display product (the abstract product , of course). want create predicate filter product list these conditions: only display productcomplex have childproducts ( childproducts.@count > 0 ). only display productsimple doesn't have parentproduct ( parentproduct = nil ). my try i'm using nsfetchresultcontroller , entityname product . i've tried create predicate: nspredicate *predi

c++ - using dllhost directly to host COM objects -

i use ifilter (as client) search text in files. document types doc have registered filter handlers both 32 , 64 bit, others docx register 1 kind. if program happens not match "bitness" of ifilter component, cannot use ifilter object. i have read of registry tricks can used using dllsurrogate , don't want interfere users' registry. can write own surrogate, wondering whether can take advantage of default system surrogate dllhost, calling directly instantiate com class. has tried it? once start dllhost particular /processid:{clsid} how communicate separate process?

search - How to index data using edge ngram in elasticsearch which include spaces also? -

i using edge ngram analyzer. while checking analyze api field getting below result. for example query "galaxy j7", analyzed as. ["g","ga","gal","gala","galax","galaxy","j","j7"] i want data analyzed below. ["g","ga","gal","gala","galax","galaxy","galaxy j","galaxy j7"] how can possible? the setting in index follows . { "analysis": { "filter": { "autocomplete_filter": { "type": "edge_ngram", "min_gram": "1", "max_gram": "20" } }, "analyzer": { "autocomplete_analyzer": { "filter": ["lowercase", "autocomplete_filter"], "type": "custom", &q

Cannot get the mysql extension module to load for php 7.0? -

i'm installing template on php 7.0 / mysql 5.5 needs mysql extension installed. this on ubuntu 14.04, mysql version 5.5, php version 7.0.7-4+deb.sury.org~trusty+1 currently, despite having installed mysql-server , mysql-client , php7.0-mysql -- pre-requisite installation code still returning false: if(!extension_loaded('mysql')){$error = true; echo " mysql php extension missing!";}else{echo " mysql php extension loaded!";} mysqli installed successfully, reason php not seeing mysql extension , therefore cannot proceed installation. the same thing true on phpinfo() check -- no mysql module found, instead there pdo_mysql, mysqlnd, , mysqi.. when check active php ini file (in fpm folder) don't see obvious in there either. what need install or enable mysql extension showing up?? the mysql extension deprecated. see http://php.net/manual/en/mysql.php your options are: 1) switch mysqli or pdo . ideally pdo , since supports

AngularJS not write parameters to PHP -

Image
i'm working on application , have problems when writing file php hosting angular data. i have variable in controller angularjs "$scope.variables" , want pass php , able write file what miss write controller in 1 http.post send parameters. in log of browser console see changing data in json file when writing file php me rewrites json file defecto.no write changes made. in controller have this, send variables php page $http.post ('http: //localhost/proyectos/3.0copy/app/partials/createjson.php data', data) .then (function () { console.log ($scope.variables); }); that when run "exporting sass" should generate json file i not know how make these modified angular me pass data php. and createjson.php file this: $dir='../less/variables.json'; if(file_exists($dir)) { if(unlink($dir)) print "el archivo fue borrado"; } else print "este archivo no existe"; $json = file_get_contents("php://input&

Remove whitespace from filteting url django tastypie -

i have few urls using filtering. when values using specific urls get api/v1/labels/?brand_city__location__state_or_country=new%20york api/v1/labels/?brand_city__city=novi%20sad alot of values being used have space inbetween words. how can remove %20 spaces , have url cleaner return: desired: api/v1/labels/?brand_city__city=novi sad no %20 present api.py class locationresource(modelresource): class meta: filtering = { "state_or_country": } class cityresource(modelresource): location = fields.foreignkey(locationresource, 'location', full=true) class meta: filtering = { "city": all, "location": all_with_relations } class labelresource(modelresource): brand_city = fields.foreignkey(cityresource, 'brand_city', full=true) class meta: filtering = { "brand_category": all, "brand_city&qu

plsql - error in pl/sql package body -

i having error: error(42,22): pls-00103: encountered symbol ")" when expecting 1 of following: current i have written package few functions , procedures. here package: -- specification -- create or replace package superhero_package function get_full_superheroname(v_superheroname in varchar2) return varchar2; procedure get_superheros(v_city in varchar2); procedure get_all_villans; function get_max_xp return number; function get_strongest_superhero return varchar2; end superhero_package; -- body -- create or replace package body superhero_package function get_full_superheroname(v_superheroname in varchar2) return varchar2 begin select first_name, last_name v_fname, v_lname superhero superhero_name = v_superheroname; return (v_fname || " " || v_lname); end; procedure get_superheros(v_city in varchar2) cursor justice_league s

wpf - Prevent ScrollViewer scrolling -

how can prevent wpf (3.5) treeview scroll event? there scrollviewer_scrollchanged event, not good, called after scroll happened, can undo scroll, not prevent. looking (pseudo): scrollviewer_scrollchanging(eventparam e) { if (...) e.cancel = true; } thanks edit i want have scrollbars, , user should able scroll, except when condition happens if (...) - then prevent scroll dynamically. more precisely, want scrollbars have only integer position, if user scrolls 1000.45, should adjusted 1000. because otherwise wpf has rendering problems bitmap in tree... if allow scroll position integer only, rendering seems ok. (no, snaptodevicepixels not help, , no, cannot use layourouding) the workaround can this: private void treeview_previewmouseleftbuttondown(object sender, mousebuttoneventargs e) { if (e.originalsource system.windows.controls.border) { ...your code } } private void treeview_previewmousewheel(object sender, mousewheeleven

php - How to set custom validation rules and error message in laravel 5 -

i'm having address field in form,by using address given fetch lat & long , save db.. if user enter's wrong address lat & long null.. so here need add new validator rule field.. here code, i tried this..but don't know how this.. public function getlatlan( $address = '') { $formattedaddr = str_replace(' ','+',$address); $geocodefromaddr = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.$formattedaddr.'&sensor=false'); $output = json_decode($geocodefromaddr); $data['latitude'] = $output->results[0]->geometry->location->lat; $data['longitude'] = $output->results[0]->geometry->location->lng; return $data; } function postsave( request $request) { $rules = $this->validateform(); $address_validate = array('location' =>'enter valid address'); if($_request['location'] !=

php - Referencing the same variable across two different classes -

<?php class foo{ public $basket; public function __construct() { $this->basket = 1; } public function getbasket(){ return $this->basket; } } class bar{ public function __construct(&$basket) { $basket++; } } $newfoo = new foo(); $newbar = new bar($newfoo->getbasket()); echo $newfoo->getbasket(); ?> i hoping initialise $basket value in 1 class , manipulate same variable via class. unfortunately, keep getting "notice: variables should passed reference in " error message. question: how can change code make happen? thank you. change $newbar = new bar($newfoo->getbasket()); to $basket = $newfoo->getbasket(); $newbar = new bar($basket); the first way doesn't work because php doesn't have variable hold value you're passing new bar() consequence, nothing can passed reference. the second way works because $basket var fixed reference in memory, can pa

elasticsearch - Determining the number of Duplicates in Kibana -

i trying total number of duplicates in "field1" in various documents in elk. read somewhere direct aggregation isn't possible in kibana , need use visualize tool so. , did that. using number of duplicates of each type. lets get count of 'a' 2, 'b' 1 , 'c' 2. rather looking there 2 duplicates (a , other being c). how do it?

html - Angular way to set Iframe src to base64 data -

i trying set iframe source base64 data contains pdf in following format, js $http.get('../../xyz', { token: $scope.token}) .success( function(response) { $scope.reportbase64string = 'data:application/pdf;base64,' + response.data; }); html <iframe id="report" ng-src="{{reportbase64string}}"></iframe> error blocked loading resource url not allowed $scedelegate policy. you can go through doc of strict contextual escaping doc but recommend inject $sce , file path provided change to $scope.reportbase64string=$sce.trustasresourceurl('data:application/pdf;base64,' + response.data);

javascript - Trying to define a function inside onclick -

i trying define function inside onclick. not working , no error showing on console. have called function bottom of page , have defined function inside onclick() not working. <div id="content-wrapper"> <div class="row"> <div class="col-lg-12"> <div class="main-box clearfix"> <div class="clearfix"> <div class="common_page gsb1"> <div class="hdr"> <div class="row"> <div class="col-md-4"> <h4>users</h4> </div> <div class="col-md-5"> //this not working <p><a href="" onclick="function send_data(data){ download_csv(data)};">download </a></p> </div>

node.js - NodeJS Linux Ubuntu running Issue -

when closing putty closing connection ,my nodejs going off. how can solve ? but when terminal closed, node server stopped. have express, socket.io , nodemon services. running nodemon. sudo apt-get install nodejs npm sudo apt-get install npm sudo apt-get install nodejs-legacy node myserver.js you running node child process of shell. once shell terminated, of children terminated, in case - node server. detach shell, can run in background using & operator: $ node myserver.js &

javascript - How do you create a serialized set of objects nested within another one? -

at end of day, need javascript function me create: object question[0]= {questiontext ,answer[{answertext1, icon1}, answertext2, icon2},.....]} i have question class has questions question text, , number of answers. questions in order. answers class of own, each answer has number of answers, answer text, , icon. i'm not sure if i've declared correctly, here attempt @ function create question object: function question(qtext, a) { this.questiontext = qtext; this.answer = a; } function answer(atext, icon) { this.answertext = atext; this.icon= icon; } var answerforquestion1[0]= new answer {"male", maleicon} var answerforquestion1[1]= new answer {"female", femaleicon}] var question[0]= new question ("what's gender?",answerforquestion1) but creates unnecessary answer variables. without knowing how big answer question going be, how create 1 function can create question answers @ once? you using var redefine va

sorting a python list by frequency of elements -

i have code sorts python list frequency of elements. works other cases except when frequency of 2 elements same. if frequency same want place smaller value first before higher value: counts = collections.counter(arr) new_list = sorted(arr, key=lambda x: counts[x]) item in new_list: print item in case of [3,1,2,2,4] output should [1,3,4,2,2] [3,1,4,2,2] . how resolve error? you can set key lambda function tuple, so, sort counts[x] first , if there tie, sort x , value itself. new_list = sorted(arr, key=lambda x: (counts[x], x))

Rails - Rendering a page in JSON based conditionally on the URL? -

Image
i have page want conditionally render in json based on if there either .json or /.json @ end of url, how reddit it, example https://www.reddit.com/r/pics/.json renders page in json. rendering page in json easy enough render json: @some_data , i'm not sure how make conditionally based on url. how go setting up? first of define routes resources resources :xvaziris just append url .json here example: http://localhost:3000/xvaziris.json

.htaccess - how to protect a django web app deployed in elastic beanstalk docker nginx using password -

i've django web application hosted in aws elastic beanstalk docker , nginx. using supervisor start nginx , uwsgi. need protect website using password. i've tried using .htaccess. htpasswd -cb /etc/nginx/.htpasswd admin admin and added nginx config with location / { auth_basic "restricted"; auth_basic_user_file /etc/nginx/.htpasswd; uwsgi_pass unix:/var/sockets/api.sock; include /home/docker/uwsgi_params; } it's working asking password repeatedly. htaccess asks password once in session. asks username , password every time click 1 field or button. there way fix it?

swift - SwiftyJSON Parse JSON error for array object -

i retrieving data url this: let url = nsurl(string: baseurl) let request = nsurlrequest(url: url!) let session = nsurlsession(configuration: nsurlsessionconfiguration.defaultsessionconfiguration()) let task = session.datataskwithrequest(request) { (data, response, error) -> void in if error == nil { let swiftyjson = json(data: data!) let results = swiftyjson[0]["name"] print(results) } else { print("error") } } for above, data this: [ { "_id":"123", "_rev":"345", "name":"hey" }, { "_id":"133", "_rev":"33345", "name":"hello" } ] i end in error block , not sure why? i pasted json in chrome console , able swiftyjson[0].name . print elements above json

sockets - Segmentation fault when send HTTP request and get response in C -

i made client socket connect server. wanna send http request it. get /index.html http/1.1\r\n host: www.google.com\r\n \r\n this code: #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #include <netdb.h> #define max 4096 int main(int argc, char **argv){ char *host; strcpy(host, argv[1]); char *request = "get "; strcat(request, argv[3]); strcat(request, " http/1.1\r\nhost: "); strcat(request, argv[2]); strcat(request, "\r\n\r\n"); char *response; int port; port = atoi(argv[2]); int sockfd; struct sockaddr_in servaddr; if((sockfd = socket(af_inet, sock_stream, 0)) < 0){ perror("failed create socket!"); exit(1); } memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = af_inet; ser