Posts

Showing posts from September, 2012

ios - Xcode8 : Why Xcode8 is not building/compiling after converting to Swift3 syntax's -

Image
i ran project in xcode8 asked me convert swift3 syntax's did it, there many errors errors fixing 2 days. after converted swift3 step step(error resolving). when build not ran once either in device or simulator. why not moving further ? it not throwing errors fix any(checked again , again) i worried. there need check in build settings or in code ? please refer below image warnings: xcode8 compiler bug : sometimes compiler not detecting errors in xcode8 so started commenting 1 one method/class in swift files there found 1 method troubling compiler has not updated swift3 syntax's after changed syntax's ran successfully many things need check if facing above issue in xcode8 swift3 please refer below syntax's thank above comments helps me think issue nsfetchrequest before : //let fetchrequest = nsfetchrequest() nsfetchrequest in swift3: let fetchrequest = nsfetchrequest<sample>(entityname: "sample") note: *

c# - Encrypt-then-MAC, how to afterwards add data to HMAC -

i want include iv , salt in hmacsha512 calculation without add encrypted data. @ moment change iv , wouldn't noticed that. i chain different streams ensure encrypt-then-mac, later want encrypt large files, design necessary. if add the iv , salt stream, e.g. new memorystream(iv).copyto(hmacstream); result contain data. this code far: private static ihmacanddata encryptinternal(byte[] key, byte[] iv, byte[] plaindata, byte[] salt) { byte[] hmachash; byte[] encryptedbytes; using (var aesmanaged = createaesmanaged(iv, key)) { var encryptor = aesmanaged.createencryptor(aesmanaged.key, aesmanaged.iv); var hmacsha512 = new hmacsha512(key); using (var resultstream = new memorystream()) { using (var hmacstream = new cryptostream(resultstream, hmacsha512, cryptostreammode.write)) { using (var aesstream = new cryptostream(hmacstream

ruby on rails - scrape json from viewsource page -

so i'm trying scrape json exists in website source , use in own site. heres example site: view-source: http://www.viagogo.co.uk/theatre-tickets/musicals/the-lion-king/the-lion-king-london-tickets/e-1545516 if partway down there var eventlistings i code exists in var so far have this: url = "http://www.viagogo.co.uk/theatre-tickets/musicals/the-lion-king/the-lion-king-london-tickets/e-1545516" doc = open(url).read any ideas how can this? thanks the code have far (basically) function using open-uri ruby standard library . standard library module, require 'open-uri' @ top of file in use it. open::uri treats job give contents of file. if comfortable using tools search raw text particular contents looking for, may enough. there few gems, though, assume html , provide special support finding html elements , inspecting contents. this post uses mechanize in turn built on top of nokogiri . easier write working code when using library

regex - Redirect sitemap.xml to a file in /assets/sitemap/ using htaccess -

if have subdomain, how can redirect it's sitemap.xml file found in /assets/sitemap? subdomain1.example.com/sitemap.xml -> /assets/sitemap/subdomain1.xml subdomain2.example.com/sitemap.xml -> /assets/sitemap/subdomain2.xml i used static code how make dynamic depending on subdomain name? rewriteengine on rewriterule ^sitemap\.xml /assets/sitemap/subdomain1.xml [l] you can use rewritecond , capture subdomain name there: rewriteengine on rewritecond %{http_host} ^(?!www\.)([^.]+) [nc] rewriterule ^sitemap\.xml$ /assets/sitemap/%1.xml [l,nc]

ios - Swift async method and return / completion block -

i'm trying create async method in project takes input parameters. if parameters correct stuff , call completion block. however, if input parameters not correct won't stuff (and completion block won't run , i'd have call myself). anyway, i'm wondering best approach this... i'm thinking have method return status enum includes wrong input , have completion block. the problem there error completion block. maybe should different error type? something this... (using login example). enum loginrequeststatus { case missingemail case missingpassword case requestinglogin } and error completion might be... enum loginerror: error { case nouserfound case invalidpassword case success } then function might this... func login(withemail email: string, password: string, completion: (loginerror?) -> ()) -> loginstatus { if email.isempty() { return loginstatus.missingemail } if password.isempty() { re

postgresql - Difference between JSON and JSONB in Postgres -

this question has answer here: explanation of jsonb introduced postgresql 6 answers what's difference between json , jsonb data type in posgressql? when should used specific one? what's benefits or disadvantages respect other? this explain: https://www.citusdata.com/blog/2016/07/14/choosing-nosql-hstore-json-jsonb/ in cases jsonb want when looking nosql, schema-less, datatype. hstore , json can have place it’s less common. more broadly, jsonb isn’t fit in every data model. can normalize there benefits, if have schema has large number of optional columns (such event data) or schema differs based on tenant id jsonb can great fit. in general want: jsonb - in cases json - if you’re processing logs, don’t need query, , use more of audit trail hstore - can work fine text based key-value looks, in general jsonb can still work great h

go - How to get list of objects from sub folder of Amazon S3 bucket using golang? -

how list of objects sub folder of amazon s3 bucket using golang? i tried: svc := s3.new(session.new(), &aws.config{region: aws.string("us-east-1")}) params := &s3.listobjectsinput{ bucket: aws.string("bucket"), } resp, _ := svc.listobjects(params) _, key := range resp.contents { fmt.println(*key.key) } i got list of objects in bucket, need list of objects in subfolder. add prefix parameter in params params := &s3.listobjectsinput { bucket: aws.string("bucket"), prefix: aws.string("root/subfolder"), } will list objects subfolder/

c# - I want to take latest of project but when we click on solution of project means root in solution explore then there is no Update latest option -

Image
example given below first 1 right: install latest version of tortoise svn name as: 1. tortoisesvn-1.9.2.26806-x64-svn-1.9.2 , 2. ankhsvn-2.5.12703.

Wordpress Knowledge Base Plugin with lateral navigation -

i'm creating wordpress site using knowledge base plugin , need lateral navigation allows me jump between post , categories, similar 1 in atlassian . anyone recommend wordpress plugin can use. if has option of shows post in current category should great too. the wordpress knowledge base documentation , faqs has paid-for add-on has lateral navigation.

python - Blackjack Game - displaying ASCII Graphics / Multiline Strings -

i'm pretty new python , trying create basic blackjack game using ascii graphics represent cards. i've placed card images in list of multiline strings , idea call specific index each 1 when card needs displayed. however can't them print next each other, , no amount of tinkering seems work. here's code: cards = [''' ------- |k | | | | | | | | k| ------- ''', ''' ------- |q | | | | | | | | q| ------- ''', ''' ------- |j | | | | | | | | j| ------- ''', ''' ------- |10 | | | | | | | | 10| ------- ''', ''' ------- |9 | | | | | | | | 9| ------- ''', ''' ------- |8 | | | | | | | | 8| ------- ''', ''' ------- |7 | | | | | |

Change URL format with .htaccess -

i've been trying better url format regular one. have deal parameters, , i'd : http://www.whatever.com/embed.php?site=site1&id=videoid to : http://www.whatever.com/embed/site/site1/id/videoid i've been trying using .htaccess, still don't understand how works. this have : rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l] rewriterule ^embed/(.*)/(.*)$ /embed.php?site=$1&id=$2 the 3 first lines hide .php extension, okay, next 1 doesn't work wish ! any 1 idea ? thanks in advance guys ! try it, rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^\.]+)$ $1.php [nc,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^embed/site/([\w-]+)/id/([\w-]+)$ embed.php?site=$1&id=$2 [qsa,l]

sql server - Concatenate fields and join tables using iReports -

i'm trying concatenate 2 fields in 1 table , 2 fields in table , using concatenated value primary key join tables together. due fact primary key linked example 5 different people need unique value per person concatenating policy number dep code. the following example of how run query mssql (i did not include full code - example). alter table [beneficiary] add [unique] varchar(max) update [beneficiary] set [unique] =concat([t1.ms_fk],[t1.dep_fk]) alter table [tsf_claim] add [unique] varchar(max) update [tsf_claim] set [unique1] =concat([t5.ms_fk],[t5.dep_fk]) left join [mipbi_dbo.td_beneficiary] t5 on t1.[unique] = t5.[unique1] i need include above in ireports final left join , dont know how create additional field in ireports. note ireports old version (3.7.1) select t1.scheme_fk,t1.ms_fk,t1.dep_fk,t1.pr_fk,t1.tariff_fk,t1.icd10_fk,t1.claimed_amount,t1.benefit_amount,t1.auth_fk,t1.units,t1.paid_date, t1.claim_date,t1.claim_code,t1.ref_p

javascript - Youtube V3 channel search having results but not showing items -

with order: https://www.googleapis.com/youtube/v3/search?part=snippet&channelid=[insert channel]&maxresults=50&q=test&order=date&key=[insert key] { "kind": "youtube#searchlistresponse", "etag": "\"i_8xdzu766_fsaexeadxtifewc0/r9nz3g9ccu-wws_b-18jkaocaj0\"", "nextpagetoken": "cdiqaa", "regioncode": "lb", "pageinfo": { "totalresults": 66, "resultsperpage": 50 }, "items": [] <--- nothing } changing next page using token shows nothing. why there no items if there results? note: removing order date result in many results , items showing. because default value relevance , query no longer 'test'. possible not results have items? can there result without associated item? i'm confused too. i'm seeing same results, if don't specify order or tell "relevance" tons of items in json. if specify

ios - Update table view numbering when new row is inserted -

i have simple table view cells have number label, , numbered according row number. works fine, until try insert new row at top . i need way update cells below, numbering correct. reloading tableview works, cuts off row insertion animation. know solution this? thanks! if set cellforrowat index function correctly each label number derived indexpath.row after insert occurs call tableview.reloaddata()

After installing Chef Development Kit, i ran "chef verify" -

does know why getting issue. i dont know reason doing in ubuntu machine. please me if had faced similar kind of issue. machine config: ruby 2.2.1 chef 12 server os ubuntu running verification component 'berkshelf' running verification component 'test-kitchen' running verification component 'tk-policyfile-provisioner' running verification component 'chef-client' running verification component 'chef-dk' running verification component 'chef-provisioning' running verification component 'knife-spork' running verification component 'delivery-cli' running verification component 'git' running verification component 'opscode-pushy-client' running verification component 'chef-sugar' .............. generating cookbook example - ensuring correct cookbook file content ================================================================================ error executing action `create_if_missing` on reso

javascript - adding properties to an existing object inside an array -

i picking array few object on external file. using: app.controller('mycontroller', function($scope, $http) { $http.get("file") .then(function(response) { $scope.lols = response.data; });}); this give me like: $scope.lols = [ { prop1: "h1", prop2: "h2", }, { prop1: "g1", prop2: "g2", },} now want add prop3 in each of objects how should ? if had data js file manually picking data external file... i have tried doing: app.controller('mycontroller', function($scope, $http) { $http.get("file") .then(function(response) { $scope.lols = response.data; $scope.lols.push = [ {prop3: "h3"}, {prop3: "g3"} ] });}); but has not worked... thanks or link explain it. solution: https://jsfiddle.net/d3c96e0z/3/ you want prop3 sibling of prop1 , prop2 ? if can either hard-coded like: $scope.lols[0].prop3 = "h3"; $sc

c# - Get report path from project folder in win-forms -

i crystal report winforms app drive: rpd.load("c:\\emprep\\crystalreport1.rpt"); i want load project folder, error. how can fix this? rpd.load("reports\\crystalreport1.rpt"); try code: rpd.load(application.startuppath + "\\reports\\crystalreport1.rpt");

java - iText Fill Form / Copy Page to new Document -

i'm useing itext fill template pdf contains acroform . want use template create new pdf dynamically pages. idea fill template pdf, copy page written fields , add new file. main problem our customer want designe template them self. i'm not sure if try right way solve problem. so i've created code don't work right error com.itextpdf.io.ioexception: pdf header not found. my code x = 1; try (pdfdocument finaldoc = new pdfdocument(new pdfwriter("c:\\users\\...final.pdf"))) { (hashmap<string, string> map : testvalues) { string path1 = "c:\\users\\.....temp.pdf" inputstream template = templatevalues.get("template"); pdfwriter writer = new pdfwriter(path1); try (pdfdocument pdfdoc = new pdfdocument(new pdfreader(template), writer)) { pdfacroform form = pdfacroform.getacroform(pdfdoc, true); (hashmap.entry<string, string> map2 : map.entr

unity3d - Rotate an object to face an opposite direction -

i have object , b. when click on object b, rotates object b (a faces b). b doesn't face a. need following : when faces b, need face opposite direction. have code rotating @ b. how rotate face opposite direction after that? vector3 targetdirection = target - transform.position; float step = speed * time.deltatime; vector3 newdirection = vector3.rotatetowards (turretdome.transform.forward, targetdirection, step, 0.0f); turretdome.transform.rotation = quaternion.lookrotation (newdirection); you object facing object b, want inverse direction of object after that? objecta.transform.rotation = quaternion.inverse(objecta.transform.rotation) but lets assume example turretdome object a, (negate direction): turretdome.transform.rotation = quaternion.lookrotation (-newdirection); naturally, both of these snippets not show how smoothen rotation, seem know how use time.deltatime. just incase unsure, quaternion.lerp this

node.js - Is it possible to get window instance somehome in the javascript? -

i tring write stand alone node.js application, in browser api . example: window.rtcsessiondescription is possible this? if want use browser api in node, if code running in browser, can use modules like: https://www.npmjs.com/package/node-dom https://www.npmjs.com/package/js-dom https://www.npmjs.com/package/nodejs-dom https://www.npmjs.com/package/dom-layer if want access actual window object of browser doing request node application serving, won't able access directly. have serve javascript browser access browser's api on behalf , communicate node application via http, websocket or in other way.

javascript - pass constructor object into self invoke function -

#1 //pass obj self invoke, works fine var foo = { a: 1 }; (function(o){ console.log(o.a); })(foo); #2 //this not working var foo = function(){ this.a = 1; }; (function(o){ console.log(o); })(foo); i'm new in javascript, try pass object self invoke my problem when try pass constructor obj, not working anyone know why? in order #2 work have correct follows; var foo = (function(){ return this.a = 1; })(); (function(o){ console.log(o); })(foo);

javascript - How to return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback

java - Groovy Scripting with elasticsearch -

my groovy script code: def value=dynamicvalue def nvalue=newvalue def field=fieldvalue def prod newvalue=newvalue.tointeger() prod=doc[''+dynamicvalue+''].value*newvalue if(._source.doc[''+fieldvalue+''].value != null) { ._source.doc[''+fieldvalue+''].value=prod } i trying update value of field in elasticsearch index like ._source.doc[''+fieldvalue+''].value=prod where avg_price_per_unit field in index. but when exceuting java "reason" : { "type" : "script_exception", "reason" : "failed run file script [fieldscript] using lang [groovy]", "caused_by" : { "type" : "illegal_argument_exception", "reason" : "argument type mismatch" } there solution?? my java code: map<string, object> params = immutablemap.o

c# - XML Deserialization - Parent element getting attribute value of child -

when deserializing xml using restsharp library, if have element contains nested element attribute same name, parent element takes on attribute value of nested element - how can prevent happening? i have several classes (larger reduced form demonstrate) set deserialize xml. [xmltype(anonymoustype = true)] [xmlroot(isnullable = false)] public class base { [xmlattribute("title")] public string title { get; set; } [xmlarray("base")] [xmlarrayitem("foo")] public list<foo> foos{ get; set; } public base() { foos = new list<foo>(); } } [xmltype(anonymoustype = true)] public class foo { [xmlattribute("style")] public string style { get; set; } [xmlelement("bar")] public list<bar> bars { get; set; } public foo() { bars = new list<bar>(); } } [xmltype(anonymoustype = true)] public class bar { [xmlattribute("style&qu

javascript - Displaying query result within Node.js Express -

i'm new node.js , express framework. i wondering if there way display result of query mysql database within html file. for example i'am establishing connection local mysql database, querying database , logging result. var mysql = require('mysql'); var connection = mysql.createconnection({ host: 'localhost', user: 'root', password: 'password', database: 'applicants' }); connection.connect(); var id = 1; var query = connection.query('select * applicants id = ?', id, function(err, result) { console.log(result); }); i to, if possible, save result , display in html page. please me , tell me if possible or if going wrong way around it. thanks

java - How to use Servlets and Ajax? -

i'm new web apps , servlets , have following question: whenever print inside servlet , call webbrowser, returns new page containing text. there way print text in current page using ajax? indeed, keyword "ajax": asynchronous javascript , xml . however, last years it's more asynchronous javascript , json . basically, let js execute asynchronous http request , update html dom tree based on response data. since it's pretty tedious work make work across browsers (especially internet explorer versus others), there plenty of javascript libraries out simplifies in single functions , covers many possible browser-specific bugs/quirks under hoods, such jquery , prototype , mootools . since jquery popular these days, i'll use in below examples. kickoff example returning string plain text create /some.jsp below (note: code doesn't expect jsp file being placed in subfolder, if so, alter servlet url accordingly): <!doctype html> <html l

ruby - Update a regex to find SQL syntax errors -

i have regular expressions find syntax errors off of webpages (i'm pentester living): sql_regex = %r((?-mix:sql query error)|(?-mix:mysql query error)|(?-mix:expects parameter)|(?-mix:you have error in sql syntax)) i regex find error messages on website if have incorrectly closed sql syntax, 1 above works, seems me it's little slower could be, suggestions on how make better more reliable regex?

firebase - FCM Schedule delivery date or time of push notification -

i have working fcm console send push notification , has option schedule delivery date. but in references, api not documented option. need know if possible push notification predefined delivery date through post request. if you're looking public api of fcm scheduled push or payload parameter can set push date, unfortunately, there's nothing of moment. you must implement own app server , implement scheduled push (also mentioned here ).

How to install federated authenticators in wso2 API manager 2.0? -

i trying install following feature in wso2 api manager 2.0. http://xacmlinfo.org/2015/05/13/federated-authenticators-in-wso2-api-manager-wso2apim/ but getting error in api manager's console while installations. it seems above package not compatible 2.0 version. please suggest me exact version of 'application authenticator' feature compatible wso2 version 2.0. thanks in advance it seems p2 repos still not updated latest authenticator versions based on identity application management server feature 5.2.0 or above. updated next release. however can use wso2 use case. can configure sso apim using this link . can federate openam this link . can connect apim openam. hope helps.

java - Types in a LambdaMetaFactory -

i exception when call metafactory . says: java.lang.invoke.lambdaconversionexception: incorrect number of parameters instance method invokevirtual my.executetest$aprocess.step_1:()boolean; 0 captured parameters, 0 functional interface method parameters, 0 implementation parameters i not understand documentation of lambdametafactory.metafactory . have problems figuring out correct parameters: methodhandles.lookup caller -- thats easy string invokedname -- here methodtype invokedtype -- whats this? methodtype sammethodtype -- err... not sure here methodhandle implmethod -- that's fine methodtype instantiatedmethodtype -- whats this, again? second time? so boils down differences between: methodtype invokedtype methodtype sammethodtype methodtype instantiatedmethodtype my code this: package my; import java.lang.invoke.*; import java.lang.reflect.method; public class execute { public interface processbase {}; @functio

Create JSON object with array array as attribute in PHP -

i'm trying create json-string looks this: {"id":"1","name":"new group test","beschreibung":"this description","gewerbe":"1" , "members":[{"uniqueid":"100110001"},{"uniqueid":"100110002"},{"uniqueid":"100110003"}]} right output looks this: {"data":{"id":"1","name":"new group test","beschreibung":"this ne","gewerbe":"1"},"members":[{"uniqueid":"100110001"},{"uniqueid":"100110002"},{"uniqueid":"100110003"}]} using following php code: return array('data' => $data, 'members' => $members); $data result of sql-query , $members result array of sql-query. want have members array attribute inside of data in example posted. how create string that?

javascript - ExtJS Paging with Combo box -

Image
created combo box extjs framework. pagination not working. please on this? var store = new ext.data.arraystore({ fields: ['id'], pagesize:1, data : [ ['15'], ['25'], ['225'], ['325'], ['525'], ['625'], ['125'], ['8725'], ['825'], ['1825'], ['3825'], ['4825'], ['67825'], ['82725'], ['84725'], ['86725'], ['87525'], ['87625'], ['872665'], ['235'], ['235'], ['225'], ['245'], ['550'] ] }); var combo = new ext.form.combobox({ name : 'perpage', width: 40, mode : 'remote', value: '1', store: store, //the store use in grid pagesize:true, listwidth : 1, width : 600, trigg

r - Remove Size data label in a plotly plot -

Image
i have plot plotly: but want remove "size(size): x" data label keep names: ["aaaaaaaaa", ......, "iiiiiiiiii"] this code use: plot_ly(test, x = x, y = y ,text = type,mode = "markers+text", size = size) any tips? using latest cran version of plotly. df <- data.frame(x = 1:3, y = 1:3, size = round(runif(3, 1, 5)), labels = letters[1:3]) df %>% plot_ly(x = ~x) %>% add_markers(y = ~y, size = ~size) %>% add_text(y = ~y, text = ~labels)

wpf - How to call C++ DLL function from VB? -

i need call function c++ dll (bvrelate.dll) through visual basic (vbwpf). c++ dll code: //vbrelate.h #ifdef vbrelate_exports #define vbrelate_api __declspec(dllexport) #else #define vbrelate_api __declspec(dllimport) #endif extern vbrelate_api void dosomething(); //vbrelate.cpp #include <atlstr.h> #include "vbrelate.h" vbrelate_api void dosomething() { cstring stroutput("hello world"); messagebox(null, stroutput, l"got message", mb_ok); } then try call function vb (wpf project) imports system.runtime.interopservices class mainwindow declare function dosomething lib "m:\vbrelate.dll" () private sub button_click(sender object, e routedeventargs) handles button.click dosomething() end sub end class and got exception: "marshaldirectiveexception unhandled". unhandled exception of type 'system.runtime.interopservices.marshaldirectiveexception' occurred in vbwpf.exe then used dum