Posts

Showing posts from May, 2010

regex - Javascript to pull attributes from shortcode string -

i have javascript application retrieves shortcode stings wordpress database. may end variable this: var shortcode = '[wp-form id="1946" title="my test form"]'; i looking use pure javascript access attributes can extract title, etc. imagine form or regex , split(). far efforts frustrated splitting whitespace. any ideas appreciated. try use code: var shortcode = '[wp-form id="1946" title="my test form"]'; var attributes = {}; shortcode.match(/[\w-]+=".+?"/g).foreach(function(attribute) { attribute = attribute.match(/([\w-]+)="(.+?)"/); attributes[attribute[1]] = attribute[2]; }); console.log(attributes); output: object {id: "1946", title: "my test form"}

php - PhpStorm refactor local variable to class field -

like in topic, want refactor local variable class field. i thinking of 2 approaches: a. quick , simple: want refactor name of variable $var $this->var . b. extended version: from: class x { function y() { $var = new targetclass; } } to: class x { /** @var targetclass $var */ // version c, optional (public|protected|private) $var; function y() { $this->var = new targetclass; } } can't of this, when try refactor $var , refactoring $this->var , end message: inserted identifier invalid defining $this->var first doesn't either. only workaround found type $this->var , loose focus on refactoring variable, type whatever , delete it. phpstorm cheated , variable changed. simple dirty-covers approach a. select variable , rightclick. choose refactor->extract->field. enter name wan't field.

itextsharp - Embedding font using itext 5 for PDF/UA compliance -

Image
we building proof of concept generate pdf/ua compliant pdf from css , html (xhtml) file using xslt. able tag pdf , add appropriate metadata information. the last major issue unable solve embedding standard pdf font zapfdinbats, our accessibility assessment tool complains - using pac 2.0 along adobe dc built in checker. as can see image below other fonts using seems automatically embedded using xmlworker our css. i have tried finding font indicated , found one, however, doesn't seem correct one. here sample of our code private static returnvalue createfromhtml(string html) { returnvalue result = new returnvalue(); var stream = new memorystream(); using (var doc = new document(pagesize.letter)) { using (var ms = new memorystream()) { using (var writer = pdfwriter.getinstance(doc, ms)) { writer.closestream = false; writer.setpdfversio

Unable to delete an entry-Springs MVC Hibernate -

i trying delete entry through spring mvc unable it.i getting 404 error stating requested resource not found. my controller code is @requestmapping("/delete/{user_id}") public modelandview deleteuser(@pathvariable("user_id")integer user_id){ userservice.removeuser(user_id); return new modelandview("redirect:/userlist.html"); } and going userservice , there going userserviceimpl , there userdao userdaoimpl code is public void removeuser(integer user_id){ user user = (user) sessionfactory.getcurrentsession().load( user.class, user_id); if (null != user) { sessionfactory.getcurrentsession().delete(user); system.out.println("successfully deleted"); } i did hibernate.show_sql=true int properties file still delete getting select statement. wrap delete code transaction: session session = sessionfactory.getcurrentsession(); transaction t

onclick - how to draw a Google Pie Chart only on a click event using javascript/jquery? -

how draw google pie chart on click event using javascript/jquery? ive tried calling drawchart on onclick event no success. from api: <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { var data = google.visualization.arraytodatatable([ ['task', 'hours per day'], ['work', 11], ['eat', 2], ['commute', 2], ['watch tv', 2], ['sleep', 7] ]); var options = { title: 'my daily activities' }; var chart = new google.visualization.piechart(document.getelementbyid('piechart')); chart.

html - Navbar Not changing color -

i don't understand why navbar not changing color despite fact added css modify it. simple it's bothering me because not working should. here html: <div class="uk-container uk-container-center uk-margin-top"> <nav class="uk-navbar" id="navbar"> <ul class="uk-navbar-nav"> <li class="uk-active"><a href="">login</a></li> </ul> </nav> </div> and here css: #navbar { background-color: black !important; } the css property overridden property targets same element either because: a. new css property preceding older one, or b. not specific enough css selector #navbar . solution a: make sure property: #navbar { background-color: black !important; } is below other css properties , make sure css file has above property below other css files , see if helps. solution b: if didn't help, there

c++ - How to prevent qmake from adding a `_d` suffix to the libraries in the Debug mode? -

this question has answer here: mixing debug , release library/binary - bad practice? 2 answers why doesn't #include <python.h> work? 5 answers my qt project links library python27.lib on windows 8.1. .pro file contains following line: win32:libs += c:\python27_11\libs\python27.lib when building project in release mode, links correctly python27.lib. when building project in debug mode, looks python27_d.lib: error: lnk1104: cannot open file 'python27_d.lib' how enforce linking python27.lib in debug mode? thank in advance! roni. p.s. tried use different syntax win32:libs += -lc:/python27_11/libs -lpython27 , , enclose declaration config(debug, debug|release) {} . none of these worked. the system info: qt creator 3.5.1 (opensource) based on qt 5.

c# - How to solve this "error in your SQL syntax" -

i have connected database windows form, put values of database table column @ listbox, , want following: when select item listbox, column of table appear in textbox. more specific, drink names appear @ listbox( espresso,water etc) , want price appear @ textbox , when selected listbox. used following code that: private void listbox1_selectedindexchanged(object sender, eventargs e) { string constring = "datasource=localhost;port=3306;username=root;password=root;"; string query = "select * apps.drinks drink_name ='" + listbox1.text + "'; "; mysqlconnection condatabase = new mysqlconnection(constring); mysqlcommand cmddatabase = new mysqlcommand(query, condatabase); mysqldatareader myreader; condatabase.open(); myreader = cmddatabase.executereader(); while (myreader.read()) { string dprice = myreader.getstring("drink_price"); pric

Spring security - resource j_spring_security_check not avaiable -

i trying build spring based web application , start configuring simple authentication system based on username & password tuples stored in database table. it understanding can achieved using spring security, cannot work. the following web.xml file. <?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>servlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/servlet/servlet-context.xml</param-value> <

pandas - filling columns based on multiple row values in Python -

i have dataframe a empty cells want fill have dataframe b . here sample data: a= month type sale 2016-01 20 2016-02 10 2016-01 b 40 2016-02 b 30 2016-01 c 2016-02 c 2016-01 d 2016-02 d b= month type sale 2016-01 20 2016-02 10 2016-01 b 40 2016-02 b 30 2016-01 c 60 2016-02 c 40 2016-01 d 60 2016-02 d 40 here have done: empttypes= ['c', 'd'] x = a.groupby('month', sort = false).sale.sum() b['sale'][b['type'].isin(empttypes) & b['month'].isin(x.index)]=x and nothing happens! i think can use fillna sum : df['sale'] = df.groupby('month', sort = false).sale.apply(lambda x: x.fillna(x.sum())) print (df) month type sale 0 2016-01 20.0 1 2016-02 10.0 2 2016-01 b 40.0 3 2016-02 b 30.0 4 2016-01 c 60.0 5 2016-

mysql - Error 42000 Mydac TMyquery sql script wrong parse -

need mydac tmyquery not work script in navicat , sqlfiddle work tmyquery not work set @@group_concat_max_len = 32000; select group_concat(concat('sum(ifnull(if(s.id=',s.id,',m.qty,0),0))`',s.sizes,'`'))eval, group_concat(concat('i.`',s.sizes,'`'))list @eval, @list from( select distinct s.id, s.sizes property p join size_goods s on s.id=p.id_sizes p.id_goods in (6,7,8) order s.id )s; select group_concat(p.id) @where property p p.id_goods in (6,7,8) ; set @sql=concat_ws(' ', 'select g.id, g.name, g.model,', @list,',i.total,i.price,i.cargo_payment,i.cost from(select p.id_goods id,',@eval, ',sum(ifnull(m.qty,0))total', ',ifnull(sum(price*qty)/sum(qty),0)price', ',ifnull(sum(cargo_payment*qty)/sum(qty),0)cargo_payment', ',sum(ifnull(m.qty*(m.price+m.cargo_payment),0))cost', 'from property p', 'join size_goods s on s.id=p.id_sizes', &#

forms - Firefox: what is the difference between reloading a page and re-getting page? -

i doing web application , notice 1 thing happens in firefox. i have form. able enter string in input field. if position mouse in address bar , hit enter key, field shows original value (blank or existing value). however, if enter new value in field, , then, without submiting form, click page reload button (in right-side of address bar), new value shows there (not original value). this not happen in ie or chrome tested. does know why? thanks , regards. imagine spent 3 hours writing , somehow reloaded page, can lost, firefox auto fill these fields you. helps not loose data. sometimes reloading page keeps relationship previous state, while re-getting - not. example submit form. re-get load page again default values, reloading try resubmit form.

gradle - Trouble adding BottomBar to Android Studio -

i'm trying add bottombar (3rd party lib) android studio project module. error error: (4, 0) cannot property 'compilesdkversion' on properties extension not exist , it's pointing build.gradle file. i'm not sure what's wrong. appreciate help. bottombar: https://github.com/roughike/bottombar/blob/master/readme.md#common-problems-and-solutions apply plugin: 'com.android.application' android { compilesdkversion rootproject.ext.compilesdkversion buildtoolsversion rootproject.ext.buildtoolsversion defaultconfig { applicationid "com.example.bottombar.sample" minsdkversion rootproject.ext.minsdkversion targetsdkversion rootproject.ext.targetsdkversion versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', incl

scalability - Stages of scaling a Java EE application -

i curious how professional programmers scale web application . have made significant research effort failed information stages of scaling, might related fact server performance depends on many factors. however, pretty sure details can laid down approximately. for instance, 1.) how many concurrent request can single tomcat server handle decent implementation , decent hardware? 2.) @ point should load-balancer server involved? 3.) when full java ee stack (jboss/glassfish) begin make sense? i feel opinion based but, ultimately, "it depends". for example, how load can tomcat handle? depends. if you're sending static html page every request answer "alot". if you're trying compute first 100,000 prime numbers every time not much. in general, best try design application clustering/distributed use. don't count on in session - keeping sessions in sync can expensive. best have every method stateless. can hard consumer (i.e. web si

swift - didBeginContact() in SpriteKit is not working -

in spritekit project (swift), use, else, autofill feature in xcode. when type in didbegincontact, nothing comes up. try type out this... func didbegincontact(contact: skphysicscontact) { } but creates bran new function. type out function inside class, not created side function. has had had problem before? , know solution? i've never heard autofill feature. have tell function, do, when somethings making contact. example: func didbegincontact(contact: skphysicscontact) { let firstbody : skphysicsbody = contact.bodya let secondbody : skphysicsbody = contact.bodyb collisionwithbullet(firstbody.node as! skspritenode, bullet: secondbody.node as! skspritenode) } func collisionwithbullet(enemy: skspritenode, bullet: skspritenode) { enemy.removefromparent() } this remove "enemy", when hits "bullet". can check out great tutorial jared davidson on youtube. https://www.youtube.com/watch?v=cew6scqv--o

Shopify / Liquid specific loop index within loop -

in shopify trying cycle through metafields contain feature titles. need cycle through other metafields , feature description based on current loop index. this code works fine me, inelegant , i'm sure there better way achieve same result! {% field in product.metafields.feature_title %} <h4>{{ field | last }}</h4> {% assign = forloop.index %} {% if forloop.index == 1 %} <p>{{ product.metafields.feature_description.001 }}</p> {% endif %} {% if forloop.index == 2 %} <p>{{ product.metafields.feature_description.002 }}</p> {% endif %} {% if forloop.index == 3 %} <p>{{ product.metafields.feature_description.003 }}</p> {% endif %} {% if forloop.index == 4 %} <p>{{ product.metafields.feature_description.004 }}</p> {% endif %} {% if forloop.index == 5 %} <p>{{ product.metafields.feature_description.005 }}</p> {% endif %} {% en

Mongodb aggregation - sort makes the query very slow -

mongodb 3.2, installed on centos 6, plenty of ram , disk. i've collection 10k documents of following structure: { "id":5752034, "score":7.6, "name":"asus x551 15.6-inch laptop", "categoryid":"803", "positiveaspects":[{ "id":30030525, "name":"price", "score":9.8, "frequency":139, "rank":100098 }, { "id":30028399, "name":"use", "score":9.9, "frequency":99, "rank":100099 } . . ] } for each document, nested array positiveaspects has few

java - Spring Cloud Config Server - properties not being returned -

this question related post . approach seemed work earlier today seeing below response instead of seeing properties defined properties file - { "name": "order-service" "profiles": [1] 0: "dev-v1" - "label": null "version": "0299eae906ee10555b68bd1bfe36bd390728969e" "propertysources": [0] } i see empty propertysources. below defined in application.yml spring: cloud: config: server: git: uri: https://github.companyname.com/projectname/orderservice-properties username: ordersvc password: ordersvc search-paths: order-service,v* the github url has 2 folders v1 , v2 have file order-service-dev.properties. please can let me know missing? thanks. edit i changed application.yml below: spring: cloud: config: server: git: uri: https://github.companyname.com/projectname/orderservice-properties usern

ruby - Paginate many has_many belongs_to relationships in Rails with will_paginate -

a user has_many potatoes. potatoes belong_to user. potato has_many quirks. quirks belong_to potatoes. i want display potatoes , associated quirks in users show , paginate using will_paginate gem below. potato_names -> sweet potato russet potato mystery potato quirk_name -> shiny rough purple quirk_name -> big brown orange quirk_name -> old medium blue my users controller pre-pagination userscontroller def show @user = user.find(params[:id]) @potatoes = @user.potatoes @quirks = quirk.where(potato: @potatoes) end i can paginate potatoes changing userscontroller - @potatoes = @user.potatoes.paginate(page: params[:page]) and users - show.html.erb <%= @potatoes.potato_name %> <%= will_paginate @potatoes %> but how can quirks paginate potatoes when click next potatoes , quirks associated next set? getting potatoes paginate , quirks show itself, why didn'

javascript - Node: fs write() doesn't write inside loop. Why not? -

i want create write stream , write data comes in. however, able create file nothing written it. eventually, process runs out of memory. the problem, i've discovered i'm calling write() whilst inside loop. here's simple example: 'use strict' var fs = require('fs'); var wstream = fs.createwritestream('myoutput.txt'); (var = 0; < 10000000000; i++) { wstream.write(i+'\n'); } console.log('end!') wstream.end(); nothing ever gets written, not hello. why? how can write file within loop? the problem aren't ever giving chance drain buffer. buffer gets full , run out of memory. writestream.write returns boolean value indicating if data written disk. if data not written, should wait drain event , indicates buffer has been drained. here's 1 way of writing code utilizes return value of write , drain event: 'use strict' var fs = require('fs'); var wstream = fs.createwritestream('m

jsf 2 - Change the color the rows of datatable with a button click -

starting color rows of datatable based condition in jsf 2 : how change clicking button in row of datatable changed value of entry.action , therefore rowstyleclass? there way update rowstyleclass after rendering? my button has tag calls listener that's changing value of entry.action.

canvas - Delphi FireMonkey app can not draw simple black rectangle -

Image
just create simple firemokey hd app, put timage align=alclient on form , trying draw simple black rect: procedure tform8.formcreate(sender: tobject); var c: tcanvas; begin image.bitmap := tbitmap.create(clientwidth, clientheight); c := image.bitmap.canvas; c.beginscene; try c.clear(clawhite); c.stroke.color := clablack; c.stroke.kind := tbrushkind.bksolid; c.drawrect( trectf.create(7,7,clientwidth-7,clientheight-7), 0,0, [], 1 ); c.endscene; end; end; and doesn't work. color of rect not black, kind of gray. there changes of color in corners. did need set other properties or wrong here ? tried different opacity values (1,100,255,65535), picture doesn't change @ , there no information in hell option means. zoomed left-top corner: also tried use polygons described in example. same problem - rounded corners , gray color instead of black (opacity property of image 1, properties default): procedure tform8.bu

r - knitr updated from 1.2 to 1.4 error: Quitting from lines -

i updated knitr 1.4, , since .rnw files don't compile. document rich (7 chapters, included child=""). now, in recent knitr version error message: quitting lines 131-792 (/daten/anna/tex/costa/chapter1.rnw) quitting lines 817-826 (/daten/anna/tex/costa/chapter1.rnw) fehler in if (eval) { : argument kann nicht als logischer wert interpretiert werden (the last 2 lines mean knitr looking logical , cannot find it. @ lines 131 , 817 2 figures end. compiling these sniplets separately work. have no idea how resolve problem. thank's in advance hints allow resolve issue. here sessioninfo() r version 2.15.1 (2012-06-22) platform: x86_64-pc-linux-gnu (64-bit) locale: [1] lc_ctype=de_de.utf-8 lc_numeric=c [3] lc_time=de_de.utf-8 lc_collate=de_de.utf-8 [5] lc_monetary=de_de.utf-8 lc_messages=de_de.utf-8 [7] lc_paper=c lc_name=c [9] lc_addre

Performance of fetching DB items individually vs looping with php -

out of curiosity, of these segments of code have faster performance time when implemented on mass scale? let's have table members , want fetch photos. method 1 $members = $db->query('select * members order id asc'); foreach($members $m) $memberids[] = $m['id']; $photos = $db->query('select * photos member in'.join(',', $memberids).' order id asc'); foreach($photos $p) { // multi_arr_search(search_val, search_column, search_array) returns parent key in multi dimensional array $memberarraykey = multi_arr_search($p['member'], 'id', $members); $members[$memberarraykey]['photos'][] = $p; } or method 2 $members = $db->query('select * members order id asc'); foreach($members $k=>$m) $members[$k]['photos'] = $db->query('select * photos member='.$m['id'].' order id asc'); method 1 result in fewer queries being ran, requires more php

javascript - Object within Prototype -

this question has answer here: nested object literal access parent 3 answers i have created object within prototype , trying access variable constructor this , alert returning undefined . constructor function example() { this.param1 = 'test'; } prototype example.prototype = { constructor: example, obj: { sample:function() { alert(this.param1); // error undifined } } }; instantiate var o = new example(); o.obj.sample(); any advice appreciated. you can though function example() { this.param1 = 'test'; } example.prototype = { constructor: example, obj: { sample:function(){ alert(this.param1); // error undifined } } }; var o = new example(); o.obj.sample.call(o); // <--- use "call" supply context. in case, context "o"

refresh - update a page automatically with jquery -

i have been testing 'jquery' script automatically updates page every n seconds ,it works fine in browsers except internet explorer doesn't load page 'posts.php' , doesn't show errors code reference $(document).ready(function() { $("#responsecontainer").load("posts.php"); var refreshid = setinterval(function() { $("#responsecontainer").load('posts.php?randval='+ math.random()); }, 2000); $.ajaxsetup({ cache: false }); }); many sites have found have suggested ie may caching code $("#responsecontainer").load("posts.php" + new date().gettime()); try ..it may or maynot solve issue let know caching problem see this more info.

2D Array method in c++ - declaration of array must have bounds Catch-22 -

i've been doing problem involves rotating square arrays in c++. length of array in 'len'. however, these rotate , flip methods return 2d array , need 2d array arguments. compiler gives me error: error: declaration of 'a' multidimensional array must have bounds dimensions except first. however, size of array depends on input - , when have input 'len' , declare method, gives me old 'variable not declared in scope' problem. pretty much, can't length of array because changes depending on input. is there way past this? #include <iostream> #include <fstream> #include <cmath> using namespace std; class transform{ private: int len; public: bool rot90[][](bool a[][]); bool rot180[][] (bool a[][]); bool check (bool a[][], bool b[][]); bool rot270[][] (bool a[][]); bool flip[][] (bool a[][]); }; bool transform::check(bool a[len][len], bool b[len][len]){ for(int h=0; h<len; h++){

integer - Need unusual sorting algorithm -

i have list of approximately 5000 integer ranges (e.g. 30-50, 45-100, etc.) need put "sorted order." order needs based on list items range subsets of other items. example 10-12 range subset of 2-14. if list(1).low_value >= list(2).low_value , list(1).upper_value <= list(2).upper_value list(1) subset of list(2). complicate things, list items subsets of many list items. i need create ordered list such list items @ lower indexes subsets of, or unrelated (e.g. ranges 1-2 , 3-4) to, items following in list. thanks, mark my first reaction sounds topological sort , ranges viewed nodes in graph, , edge considered exist range range b iff subrange of b. i assume mean condition output list if appears before b, b not strict subset of (but it's fine if = b, , b disjoint, or , b overlap without 1 being subrange of other). if width of range b ( b.upper_value - b.low_value ) @ least of range a, b cannot strict subrange of a. hence suffices sort list increasing

html - Efficient way to create pages from multiple similar type links -

i have page there 30 links , links have similar page except few contents changed(there pictuures). there efficient way without repeating codes , repeated nestings of codes. thank you. using plain html won't able this. the straightforward way it, think, using server-side scripting implement rendering template. have default "main" template 30 pages have in common , in each of pages use main template , load custom content. so if want modify in main template you'd have modify main.html (or whatever called it) page , not each of 30 pages. see this.

swift - Firebase snapshot.key not returning actual key? -

i have query searches user based on user id. usersref.queryorderedbychild("email").queryequaltovalue(email).observeeventtype(.value, withblock: { snapshot in if snapshot.exists() { print("user exists") print(snapshot.key) the query returns correct user, line print(snapshot.key) literally returns word "users", , not actual user id. print(snapshot) returns following user: snap (users) { delyncz9zmttbikfbnyxtbhuadd2 = { email = "test3@gmail.com"; "first_name" = test; "last_name" = test; }; how can delyncz9zmttbikfbnyxtbhuadd2 ? can email using let email = child.value["email"] can't key because it's not named attribute. thanks!! edit: updated code frank's answer. getting ambiguous use of key query.observeeventtype(.value, withblock: { snapshot in print(snapshot.key) if snapshot.exists() { print(&qu

JQuery ajax call receives invalid JSON, but no error handlers are called -

informational question rather issue need solved. couldn't find satisfactory answers elsewhere i'm new jquery/js, , i'm trying test error handlers have ajax call rails backend. had hell of time getting handlers fire. i tried letting backend return 500 , stack trace, handlers didn't fire. console shows vm26658:1 uncaught syntaxerror: unexpected token s in json @ position 0 . i tried returning empty response bad request status, same error , behavior i got handlers fire returning empty (but formed) json response , 400 status so seems ajax error handlers don't fire when response body cannot parsed. correct? if seems pretty substantial , unintuitive limitation of handler logic. if not, how being stupid? thanks! update code in haml: = simple_form_for @object, method: :put, url: setup_object_path, remote: true |f| = f.input :some_input = f.submit, class: 'js-submit' in coffeescript: $(document).on 'ajaxstart', startfunction $(

Calling a C# overloaded method with out parameters from F# -

i have following f# code handle gtk.treeview event: tree.cursorchanged.add(fun (e : eventargs) -> let selection = tree.selection let mutable iter = new treeiter () if selection.getselected(&iter) console.writeline("path of selected row = {0}", model.getpath(iter)) ) selection.getselected has 2 overloads, signatures bool getselected(out treeiter, out itreemodel) and bool getselected(out treeiter) which preventing me using tuple-returning version described in this post : let selection = tree.selection match selection.getselected() | true, iter -> // success | _ -> // failure is there way specify getselected overload want latter syntax? edit: clarify question, know method signature want; don't know how specify it. instance, tried this, didn't work: let f : (byref<treeiter> -> bool) = selection.getselected match f() | true, iter -> // success | _ -> // failure i think matc

erlang - Uncaught error in rebar core when doing make rel -

i cloned repo , trying generate release using make rel , see following error. not sure whats wrong. can ? uncaught error in rebar_core: {'exit', {{case_clause, {error, {function_clause, [{filename,join, [{error,bad_name},"erts.app"], [{file,"filename.erl"},{line,406}]}, {rmemo,ets_tab,0, [{file,"src/rmemo.erl"},{line,187}]}, {rmemo,init,1, [{file,"src/rmemo.erl"},{line,181}]}, {gen_server,init_it,6, [{file,"gen_server.erl"},{line,304}]}, {proc_lib,init_p_do_apply,3, [{file,"proc

ios - no visible interface for 'GAITransaction' -

i'm trying implement in app purchase tracking in ios google analytics receive these errors: the exact example code taken google analytics page has 2 errors: - (void)onpurchasecompleted { gaitransaction *transaction = [gaitransaction transactionwithid:@"0_123456" // (nsstring) transaction id, should unique. withaffiliation:@"in-app store"; // (nsstring) affiliation when compile here above says "]" inserted transaction.taxmicros = (int64_t)(0.17 * 1000000); // (int64_t) total tax (in micros) transaction.shippingmicros = (int64_t)(0); // (int64_t) total shipping (in micros) transaction.revenuemicros = (int64_t)(2.16 * 1000000); // (int64_t) total revenue (in micros) here below error: "no visible interface 'gaitransaction' declares selector 'additemwithsku:name:category:pricemicros:quantity'" [transaction additemwithsku:@"l_789

android - How to send a notification when checkbox is checked? -

public class settings extends appcompatactivity { checkbox cb1; notificationmanager manager; notification mynotication; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_settings); cb1=(checkbox) findviewbyid(r.id.notificationchk); manager = (notificationmanager) getsystemservice(notification_service);// here , above seems ok(no error) cb1.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton togglebutton, boolean ischecked) { notificationcompat.builder builder = new notificationcompat.builder(this)//"this" taskstackbuilder cannot applied oncheckedlistener .builder(mcontext)//the mcontext not working .setcontenttitle("new mail ") .setcontenttext("i") .setsmallicon(r.d

python - Memory issues when writing to file from MySQL -

db.connect() sentencetb = sentencetb.select() i, sentence in enumerate(sentencetb): open('./commentary/sentence%i.txt' %i, 'w', encoding='utf-8') f: f.write(sentence.sntenc) db.close() i use code connect database, select table , write in table separate file. table has on 1 mln records , going great first, when code started writing 900 000th record, computer slowed down much. pycharm continuously asking me allocating more memory , if first 500k records done in 1 hour, takes him 1 hour write 50-100 records. i have thoughts should somehow connected releasing memory, don't know how it. any appreciated. do need close cursor? looks you're opening new 1 each iteration, explain lack of memory after few hundred thousand iterations. db.connect() sentencetb = sentencetb.select() i, sentence in enumerate(sentencetb): open('./commentary/sentence%i.txt' %i, 'w', encoding='utf-8') f: f.write(sentence

ios- decompress PNG directly to disk -

i have large png want uncompressed file, don't have memory capacity on device expand png in memory, file. is there native ios method uncompress png each scan line? alternatives? update : libpng - reading image data - http://www.libpng.org/pub/png/libpng-1.2.5-manual.html#section-3.8 for non-interlaced pngs png_read_rows(png_ptr, row_pointers, null, number_of_rows); as , idea how start: take how doing java png decompressing algorithm. java should have open-source files. maybe has ios idk. uncompress algorithm idea. should around 1k-5k lines of code. when know how it, implement @ ios read chunk of file , export file, read chunk , process , export it. know easy , @ least theoretically working. maybe public in site. libpng can starting point. png looseness compression zip. there have remember runtime built data table. table depends how big is, maybe need swapped to disk, makes longer decompression process. good luck!

javascript - Call function after ajax calls have finished -

this question has answer here: jquery callback multiple ajax calls 12 answers i'm trying use twitch.tv's api information channels. have different channels im trying information in array iterate through forloop , within loop make $.ajax() each 1 of these channels. after information want these channels store them in object push onto different arrays depending on wether or not channel streaming or offline. issue seems when call display method , change divs html information channels, of requests have not completed yet , reason dont channels added onto page. question should call display function in code , if there better approach im trying achieve. in advance here code. https://jsfiddle.net/bwsvxsdv/4/ <!doctype html> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/boo

Why use the -p|-n in slurp mode in perl one liner? -

in perl 1 liner slurp mode 0777 hope equal below script open $fh, "<","file"; local $/; $s = <$fh>; #now whole file stored $s here not using loop storing elements together(single data). but in perl 1 liner, why use -p|-n switch enable slurp mode ( -0777 )? performance gain here.? -p | -n using looping purpose. actual performance of 1 liner below script or else? open $fh, "<","file"; $s; while (<$fh>) { $s.=$_; } print $s; without -n or -p there no implicit while (<>) loop default $_ not set, , stdin isn't read either. if want have <> , $_ default in slurp mode need 1 of these switches along -0777 , on own merely (un)sets $/ . this echo "hello" | perl -0777 -e 'print' prints nothing, , -w warns of use of uninitialized value $_ . this echo "hello" | perl -0777 -e '$v = <>; print $v' does print hello . stdin can read variable, &#

cmake - Silence CMP0048 Warnings in Vendored Projects -

i have git submodules cmakelists.txt files causing warnings due cmp0048. warnings this: cmake warning (dev) @ submodule_directory/cmakelists.txt:24 (project): policy cmp0048 not set: project() command manages version variables. run "cmake --help-policy cmp0048" policy details. use cmake_policy command set policy , suppress warning. following variable(s) set empty: project_version project_version_major project_version_minor project_version_patch warning project developers. use -wno-dev suppress it. i don't control these cmakelists.txt files , don't want fork there's nothing done , want cmake shut it. using cmake_policy(set cmp0048 old) before adding submodule directories doesn't solve this. (i guess project() resets cmake policies?). is there can this?

Toggle state in c# - wpf -

i want make function work in toggle(switch) mode when press key , can't figure how it. tried lots of ways , "registerhotkey" method working fine. "registerhotkey" overwriting mapped key game , not need. i'm trying use "getkeystate". code below it's working 1 position no matter change...: private void mw_keydown(object sender, keyeventargs e){ bool sw = (toggle = !toggle); int tog = (getkeystate(key.tab)); if ((tog & 1) == 1) { if (sw) { system.windows.messagebox.show("go second position...!"); } } else { system.windows.messagebox.show("go first position...!"); } } any idea or suggestion how can ? thank you, solution provided sergey alexandrovich kryukov codeproject. link: solution public partial class mainwindow : window { bool toggle; public mainwindow() { initializecomponent(); mainwindow.keyd

angularjs - Can't able to connect my controller with html properly in Angular js -

here code, cant able ajax call, getting errors here. don,t know how clear that, can me please. var app = angular.module('app',['ui.router']); app.controller('postctrl',['$scope','$http',function($scope,$http){ console.log('inside jobpost'); $http.get("/api/job-posts").success(function(data, status, headers, config) { $scope.items = data.data; }).error(function(data, status, headers, config) { console.log("no data found.."); }); }); app.filter('searchfor', function(){ return function(arr, searchstring){ if(!searchstring){ return arr; } var result = []; searchstring = searchstring.tolowercase(); angular.foreach(arr, function(item){ if(item.title.tolowercase().indexof(searchstring) !== -1){ result.push(item); } }); return result; }; }]); &

node.js - Remote hooks in loopback -

in loopback using afterremote hook request follows modelname.afterremote("**", function(ctx, expenses, next){ if(ctx.method.name == 'find') { for(var i=0; i<ctx.result.length; i++){ delete ctx.result[i].category; } } }); in above trying delete key request response before sending client. still appears. not possible delete key have created in model.json?. please share ideas. in advance. you need use result.unsetattribute('field') modelname.afterremote("**", function(ctx, expenses, next){ if(ctx.method.name == 'find') { for(var = 0; < ctx.result.length; i++) { ctx.result[i].unsetattribute('category'); } } }); here related github issue , in case interested. it documented in operation hooks section of loopback documentation, there sadly no mention of in remote hooks section. note: if want restrict hook find method, can specify modelname.afterremote("find"