Posts

Showing posts from February, 2013

php - Where's my html tags going? -

starting frustrated form. i'm submitting html content database, stored , retrieved display on front end. have made sure use htmlspecialchars() , however, code getting stripped down plain text upon saving. i've read ton of post's questions identical mine, haven't found suitable answer. here's code i'm having trouble with: <li> <label for="summary">article summary</label> <textarea name="summary" id="summary" placeholder="brief description of article" required maxlength="1000" style="height: 5em;"><?php echo htmlspecialchars( $results['article']->summary )?></textarea> <script> ckeditor.replace( 'summary', { filebrowserbrowseurl: 'wysiwyg/kcfinder/browse.php? opener=ckeditor&type=files', filebrowserimagebrowseurl: 'wysiwyg/kcfinder/browse.php? opener=ckeditor&type=images', f

java - Matching data in 2 different linked lists -

so have program supposed match babysitters people based on inputted info. info both parties saved in linked lists. is possible match data babysitter linked-list parent linked-list? , make output "__ possible matched you" if not have data, simple inefficient way of solving problem is: boolean matches(person person, babysitter babysitter) { // implement logic returns whether babysitter , person match return person.getnumberofchildren() <= babysitter.getmaximumnumberofchildren() && babysitter.getworkingdays().containsall(person.needsbabysitterfordays()); } (person person: people) { (babysitter babysitter: babysitters) { if (matches(person, babysitter)) { system.out.println("babysitter " + babysitter + " recommended " + person); } } } the above algorithm takes o(b * p) time b = number of babysitters, p = number of people. large b , p, slow. based on logic of matches achieve sol

c++ - Detect method's origin when parsing it's metadata in Qt -

i have code parses metadata of qt plugin wrote exposes functionality via interface. plugin's main class inherits qobject, when reading metadata, methods declared , publicly available in qobject, among them: destroyed(object *); objectnamechanged(qstring); etc... i want parse methods introduced in plugin's main class, , not methods have been inherited qobject, looking @ properties qmetamethod provides, don't see way. have access methods qmetaobject include qobject's methods well. one way solve parse metadata of qobject exclude it's methods plugin's main class. last resort. wondering if qt provides out of box. you can use qmetaobject::methodoffset() method index current class' methods start, , iterate there rather starting @ index 0: const qmetaobject *object = metaobject(); // gets methods on actual class. (int = object->methodoffset(); < object->methodcount(); ++i) { qdebug() << object->method(i).methodsignature()

asynchronous - How to wait for free Akka actor while processing stream of data using Plays Iteratee -

i have infinite stream messages represented plays enumerator apply iteratee . each message processed akka actor (number of actors limited 10). now code in iteratee asynchronously wait free actor if 10 actors busy , not send them messages leads exception ask timed out on ... . how can achieve such functionality? there better way process infinite stream 10 actors without await ? example of code talking this: val workers = context.actorof(props[myworker].withrouter(roundrobinrouter(10))) val = iteratee.foreach[msg] { msg => workers ? msg } msgenumerator.apply(it) use iteratee.foldm actor ask pattern have here seems right approach. assuming don't want actors build large mailboxes (if don't care large mailboxes, use tell , iteratee.foreach instead of ask ) require specialized routing logic. since api making custom akka router doesn't support asynchrony, need custom actor handle logic of distributing 1 piece of work each actor in actor pool @ time

javascript - i have a valid json but i keep getting "syntaxerror json.parse unexpected end of data at line 1"! -

i'am lost here, i'm working on game need make call server inisiate game , register user , game data. upon making call start game nothing happens , keep getting error message. have validated json response server. below code please :( json { "message": "game started", "code": 200, "status": "success", "user_session_id": "217c7a4759388ae0af80bdf7668e4bf5", "points": 0, "databn4": { "1": { "number_id": 181, "guess_number": 183 }, "2": { "number_id": 182, "guess_number": 968 }, "3": { "number_id": 183, "guess_number": 742 }, "4": { "number_id": 184, "guess_number": 986 }, "5&

rust - Subtraction not implemented for f32? -

when compiling following code: use std::io::*; fn main(){ let reader = stdin(); let nums = reader.lock() .lines().next().unwrap().unwrap() .split_whitespace() .map(|s| s.parse::<i32>().unwrap()) .map(|s| s f32) .map(|s| (s - 4) / 2) .map(|s| s i32) .collect(); } i error saying: the trait core::ops::sub<_> not implemented type f32 why this? rust stricter other languages when comes manipulating primitive types. math operators require same type on both sides (with exception of bit shifts, expect usize right-hand side operand). rust not automatically cast values 1 primitive numeric type another: must insert explicit cast in code. code demonstrates situation: fn main(){ let a: i32 = 2; let b: i8 = 3; println!("{}", + b); } it fails compile following errors: <anon>:4:24: 4:25 error: mismatched types: expected `i32`, found `i8` (expected i32, found

ruby - Rails to_json belongs_to object -

i have 2 models: cabinet , workplace. class cabinet < activerecord::base def as_json(options={}) options.merge!({except: [:created_at, :updated_at]}) super(options) end end class workplace < activerecord::base belongs_to :cabinet def as_json(options = {}) options.merge!(:except => [:created_at, :updated_at, :cabinet_id], include: :cabinet) super(options) end end when called cabinet.first.to_json { id: 1, cabinet: "100" } but when called workplace.first.to_json id { name: "first workplace", cabinet: { id: 1, cabinet: "100", created_at: "#created_at", updated_at: "#updated_at" } } why this? , sorry english :) not sure if following you, want attributes workplace model, , not cabinet data when workplace.first.to_json? i think because include cabinet in as_json method configuration explained here . you sh

node.js - Making requests to a node API from a different domain using HTTPS -

i serving static page on https ( https://example.com ) makes requests node api on different domain (example-api.com). my api standard express app using http. here's setup code: var express = require('express'); var app = exports.app = express(); var port = process.env.port; exports.server = require('http').createserver(app).listen(port); in requests static page, specify https://example-api.com url. works of time, every once in while (10% of time?) chrome errors out on requests with: net::error_insecure_response other users who've come across issue (e.g. failed load resource: net::err_insecure_response socket.io ) seem solve adding credentials option createserver call, e.g. var server = https.createserver(credentials, app) so when tried implement came following: var fs = require('fs'); var options = { key: fs.readfilesync('server-key.pem'), cert: fs.readfilesync('server-cert.pem') }; var express = require('exp

javascript - Polaroid photobar gallery in DIV -

i made horizontal scrollto website divided in 7 seperate div's. i'm desperately trying add polaroid photobar gallery inside div, can't figure out. can me explain what's going wrong? here url of website , can see gallery appears on first page..... code html <div id="medio2"></div> <div class="section" id="gall"> <div id="fotos" border="1"> <h1>the jargonauts galerie</h1> <div id="pp_gallery" class="pp_gallery"> <div id="pp_loading" class="pp_loading"></div> <div id="pp_next" class="pp_next"></div> <div id="pp_prev" class="pp_prev"></div> <div id="pp_thumbcontainer"> <!-- debut album1--> <div class="album"> <div class="

jquery - Why doesn't my cookie show in input field when set? -

i have cookie function setting cookie in input field, , button save it. when save , refresh page input field empty again. note: have jquery dialog , sticky navigation bar. maybe overrides other jquery code somehow. my jquery code set cookie: //set cookie voor de postcode $(function() { $('#go').click(function(){ $.cookie('postcode', $('#postcode').val()); }); //retrieve cookie on load if it's not undefined if(typeof $.cookie('postcode') !== 'undefined'){ $('#postcode').val($.cookie('postcode')); } }); my function set cookie in input. <div id="searchbox"> <div id="search"> <fieldset> <legend><h2>zoeken in uw regio:</h2></legend> <form action="<?= base_url('home/zoekresultaten') ?>"> <p class="field"><label class="

python 3.x - Pandas use series to select column names -

if have series ('a','b') pulled in column pandas.read_csv, how can use select columns data frame this? pd.dataframe={'a':[1,2,3],'b':[2,3,4]} thanks in advance! i had change list , pass columns this: list=list(series) df=df[list]

App Engine/Go: 'goapp serve' giving an error "Go application could not be built" error -

i trying use go app engine sdk go , when run goapp serve , following error in printed browser after going http://localhost:8080 (i similar errors in terminal): the go application not built. (executed command: c:\go_appengine\goroot\bin\go-app-builder.exe -app_base c:\projects\go\davilex -arch 6 -dynamic -goroot c:\go_appengine\goroot -nobuild_files ^^$ -unsafe -gopath c:\projects\go -print_extras_hash controllers\form\form.go main.go controllers\pages\pages.go models\form.go) 2016/01/20 22:10:42 go-app-builder: failed parsing input: parser: bad import "syscall" in colorable_windows.go gopath seems there somewhat similar question here few days ago, no resolve: bad import "syscall" cloud storage apis at first thought because had both python 2.7.x , 3.5.x installed , the docs work v 2.7.x, uninstalled 3.5.x references, removed sdk , reinstalled it/unzipped/added path path. i can run gcloud , goapp , go fine should set correctly f

LESS CSS @import for javascript -

do know if there's kind of tool less css javascript allows import example "plugin-1.js"; in .js file. i'm working sublime text 2 build less (which references dotless.exe), maybe if you've tried it'll awesome if can share us. if you're in html javascript in web can organize imports libraries require.js or include script tag above 1 you're using in html. <script src="plugin-1.js" type='text/javascript'> </script> otherwise, if you're using node.js done require() directive such var othermoduletorequire = require("plugin-1.js"); after available in file. it worth mentioning while similar @import in functionality behave differently doing importing in run time instead of bundling files 1 @import does. if care bundling files (for example in production under load) can use minifiers , optimizers the closure compiler or the require.js optimizer if chose use require.js.

Session management is not working in spring security -

my spring-security.xml: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:security="http://www.springframework.org/schema/security" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <!-- configure spring-security --> <security:global-method-security pre-post-annotations="enabled" /> <!-- <security:global-method-security secured-annotations="enabled" /> --> <security:http auto-config="false" use-expressions="true

java - spring session with dropwizard -

i using dropwizard framework developing rest apis have managed integrate spring security dropwizard project , works charm. unfortunately have not been able spring session work dropwizard. have followed guide using spring session spring security , rest , no session created or http-headers seen though see spring session configuration initialised in dropwizard logs info [2016-01-21 04:05:53,326] org.springframework.beans.factory.support.defaultlistablebeanfactory: overriding bean definition bean 'httpsessionstrategy': replacing [root bean: class [null]; scope=; abstract=false; lazyinit=false; autowiremode=3; dependencycheck=0; autowirecandidate=true; primary=false; factorybeanname=springsecurityconfig; factorymethodname=httpsessionstrategy; initmethodname=null; destroymethodname=(inferred); defined in com.cr.security.springsecurityconfig] [root bean: class [null]; scope=; abstract=false; lazyinit=false; autowiremode=3; dependencycheck=0; autowirecandidate=true; pri

oop - Overriding a method with more parameters in java? -

i have base class method called execute : class { public execute(int a){} } i have class b, extends a, execute method needs more parameters: currently, solution using optional parameters : class b extends { public execute(int a, object... parameters){ long b = (long)parameters[0]; boolean c = (boolean)parameters[1]; .... } } this still ugly because must cast on parameters. there other options situation? you can add execute(int a, int b) in b, won't override execute(int a) method, overload it. both method callable on instance of b .

html - Star Rating with SVG catering for decimal point rating -

i have code create star rating. have not used svg before , can't figure out how following: rating out of 5 display ratings decimal place ie: 4.5, 3.2, 1.1 whole stars rated stars need yellow, stars remaining need grey how , change on example move star rating left , right display stars catering decimals? fiddle example: http://jsfiddle.net/apbuc773/10/ code: <svg height="210" width="500" fill="url(#g)"> <polygon points="165.000, 185.000, 188.511, 197.361, 184.021, 171.180, 203.042, 152.639, 176.756, 148.820, 165.000, 125.000, 153.244, 148.820, 126.958, 152.639, 145.979, 171.180, 141.489, 197.361, 165.000, 185.000" style="stroke: red;"/> <lineargradient y2="0.9733" x2="1" id="g" x1="0.0167" y1="0.9833"> <stop stop-color="#f00" offset="0.4733"/> <stop stop-color="rgb(255, 255, 255)" offset=&qu

java - Can new File() constructor return null on Android? -

i saw code in android training center website: boolean hasexternalstorageprivatefile() { // path file on external storage. if external // storage not mounted fail. file file = new file(getexternalfilesdir(null), "demofile.jpg"); if (file != null) { return file.exists(); } return false; } does mean on android new file() can return null? http://developer.android.com/reference/android/content/context.html#getexternalfilesdir(java.lang.string) no, constructor may never return null. constructor either returns initialised object or throws exception or error.

copy paste - Cocoa NSAttributedString Pasting Changes Font -

i have nsattributedstring has nsattachment , text. have copied pasteboard. have made sure string has no font attributes. when paste it, changes font helvetica. there way prevent behavior? let wrapper = nsfilewrapper() wrapper.preferredfilename = "image" let attachment = nstextattachment(filewrapper: wrapper) if let im = nsimage(data: data) { attachment.image = im } let image = nsattributedstring(attachment: attachment) let str = nsmutableattributedstring(attributedstring: image) str.appendattributedstring(nsattributedstring(string: "hello world")) let range = nsmakerange(0, str.length) //remove font attributes str.removeattribute(nsfontattributename, range: range) str.removeattribute(nsfontsizeattribute, range: range) swift.print(str.attributes) //prints empty array at point copy data clipboard if let d = str.rtfdfromrange(range, documentattributes: [nsdocumenttypedocumentattribute: nsrtfdtextdocumenttype]) { let pboard = nspasteboard.generalpas

Android view with multi-directional swipe gestures -

i have view textview containing long text, view has give user facility of scrolling through text. also, textview must allow swipe right , left on instances of view. i've got scroll working scollingmovementmethod left , right swipe doesn't work. for enabling swipe gesture left,right,up or down, follow below steps : step 1: create java file simplegesturefilter import android.app.activity; import android.view.gesturedetector; import android.view.motionevent; /** * created nihal on 1/21/2016. */ public class simplegesturefilter extends gesturedetector.simpleongesturelistener { public final static int swipe_up= 1; public final static int swipe_down= 2; public final static int swipe_left= 3; public final static int swipe_right = 4; public final static int mode_transparent = 0; public final static int mode_solid= 1; public final static int mode_dynamic= 2; private final static int action_fake = -13; //just unlikely number private int swipe_min_distance =

c# - get content files according to the number of revision -

i have seek difference between files after changes of content how can read , content while have same path , directory have use implement utility generate statistics code ilist<filespec> filestofind = new list<filespec>(); filestofind.add( new filespec(filespec.depotspec(dpath).depotpath, revision.none)); string[] files = new string[1]; files[0] = dpath; p4command command = new p4command(ps, "where", true, files); options opts = new options(); string v1="", v2="", v3=""; p4commandresult results = command.run(opts); taggedobjectlist list = (results.taggedoutput); foreach (taggedobject obj in list) { console.out.writeline("v1=" + v1 + "hhhhhhhhh1"); int = 0; string v=""; foreach (string s in obj.keys) { string value = "n/a"; obj.trygetvalue(s, out value); if (obj.keys.elementat(i).equals("depotfile")) v1 = value; if

How to generate cryptographic key in the form of a binary string 16 bytes long in PHP -

i trying store string in encrypted form in mysql db, looking 2 way encryption, found guide openssl_encrypt / openssl_decrypt $ciphertext = openssl_encrypt($plaintext, 'aes-128-cbc', $key, openssl_raw_data, $iv); $plaintext = openssl_decrypt($ciphertext, 'aes-128-cbc', $key, openssl_raw_data, $iv); that guide doesn't explain how generate cryptographic key in form of binary string 16 bytes long $key , crypto-secure random binary string 16 bytes long $iv . any appreciated. $key = openssl_random_pseudo_bytes(16); , $iv = openssl_random_pseudo_bytes(16); should generate random 16 byte / 128-bit key , iv.

design - Schema extension for SCIM 2.0 -

we have identity provider user registry, , soap web service applications read/write user profiles. plan add scim interface well. we find core user schema covers basic set of attributes, our existing system has different naming convention same attributes. for example, usertelephonenumber, userstreetaddr1 , on. considering large number of applications using naming convention, continue same scim 2.0. given can extend core user schema, 1) can opt not using attributes core schema ? if payload includes these attributes, can ignore them on server side, , process custom schema attributes ? an example user document - { "schemas": [ "urn:scim:schemas:core:2.0:user", urn:scim:schemas:extension:customattrs:2.0:user"], "id": "2819c223-7f76-453a-919d-413861904646", "urn:scim:schemas:extension:customattrs:2.0:user": { "userfirstname": "fname",

Does java have an equivalent to python __call__? -

just started learning python, i've come across __call__ method. understand when __init__ gets called , when __call__ gets called running simple example: class constructor: def __init__(self, a): print "__init__ called" def __call__(self): print "__call__ called" def dummy(self): print "a dummy method called" print "creating x obj" x = constructor(1) print "calling x object" x() console output: creating x obj __init__ called calling x object __call__ called my questions are: i come java background, know __init__ maps java constructor, java have equivalent __call__ me understand better? can give me simple example of when __call__ can useful? __call__ equates overloading () operator on class. possible in c++ not java. allows 1 have function objects (sometimes called functors ). in python these termed callable objects . in simple terms, allows treat object fun

javascript - can Meteor flow-routing accept any parameters for it dynamic routing? -

i use flow-routing on meteor.js i want template like: <template name="layout"> {{>header}} <div class="container"> <div class="col-md-2"> {{>template.dynamic template=sidebar}} </div> <div class="col-md-8"> {{>template.dynamic template=main para=message}} </div> </div> {{>footer}} </template> can use router make parameter message like: flowrouter.notfound = { // subscriptions registered here don't have fast render support. subscriptions: function() { }, action: function() { blazelayout.render('layout',{sidebar:'sidebar', main:'home',para='your input wrong path.'}) } }; how pass parameters dynamic template in flow-routing? you should have para:'your ...' , not para='your ...' (note colon).

Export pivot table to Excel gives error: missing tag row (with an unwanted tag INSERT) -

i building wpf application uses owc pivot table display data. when click built-in button export pivot table excel, writes log file such error message: xml error in pivottable reason: missing tag action: aborting current xml group file: c:\users\my_name\appdata\local\temp\pivottable71147_cachedata.xml group: pivotcache tag: row when open pivottable71147_cachedata.xml file, looks this: <xml xmlns:s='uuid:bdc6e3f0-6da3-11d1-a2a3-00aa00c14882' xmlns:dt='uuid:c2f41010-65b3-11d1-a29f-00aa00c14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#rowsetschema'> <s:schema id='rowsetschema'> <s:elementtype name='row' content='eltonly' rs:updatable='true'> <s:attributetype name='recid' rs:number='1' rs:write='true'> <s:datatype dt:type='int' dt:maxlength='4' rs:precision='0' rs:fixedlength='true' rs:maybenull=&

ios - Switch doesn't work in SMSegmentViev -

i use frames smsegmentview, can not implement switch in numberofrowsinsection , cellforrowatindexpath ... when start in simulator pressing segment table not changed pressing index segment. can not understand error import uikit class dailystandingviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate, smsegmentviewdelegate { @iboutlet var standingtableview: uitableview! let standingexersisename = ["БЕГ", "ПРЫЖКИ", "ПРИСЕДАНИЯ", "ОТЖИМАНИЯ", "ТОЛЧЕК"] let standingexersiseimage = ["bb", "bt", "ca", "co", "de"] let sittingexersisename = ["ПРИСЕД", "СКАЧКИ", "ПРИСЕДАНИЯ", "ОТЖИМАНИЯ", "ТОЛЧЕК"] let sittingexersiseimage = ["bb", "bt", "ca", "co", "de"] var segmentcontroler: smsegmentview! var alphasegmentview: smbasicsegmentview! var seletionbar: uiview = uiview(

java - Are child Classes equivalent to their racine class from type of object perspective? -

well know question not clear. bare me minute. i've created 3 abstract classes: class article : mother class public abstract class article{ //myprivate var declarations public article(long reference, string title, float price, int quantity){ this.reference = reference; this.title = title; this.price = price; this.quantity = quantity; } } class electromenager : child of article public abstract class electromenager extends article{ //myvar declarations public electromenager(long reference, string title, float price, int quantity, int power, string model) { super(reference, title, price, quantity); this.power = power; this.model = model; } } class alimentaire: child of article public abstract class alimentaire extends article{ private int expire; public alimentaire(long reference, string title, float price, int quantity,int expire){ super(reference,