Posts

Showing posts from September, 2012

c++ - Definition of the static data member -

i'm reading scott meyers' c++ , come across example: class gameplayer{ private: static const int numturns = 5; int scores[numturns]; // ... }; what see above declaration numturns , not definition. why not definition? looks initialize static data member 5. i don't understand means declare not define variable value 5. can take address of variable fine. class { public: void foo(){ const int * p = &a; } private: static const int = 1; }; int main () { a; a.foo(); } demo because isn't definition. static data members must defined outside class definition. [class.static.data] / 2 the declaration of static data member in class definition is not definition , may of incomplete type other cv-qualified void . definition static data member shall appear in namespace scope enclosing member’s class definition. as taking address of static member without defining it, compile, shouldn't link.

android - How to resolve access to class not allowed -

i calling class jar file . but, class called, application crashes , in logcat i'm getting error: caused by: java.lang.illegalaccessexception: access class not allowed @ java.lang.class.newinstanceimpl(native method) @ java.lang.class.newinstance(class.java:1319) @ android.app.instrumentation.newactivity(instrumentation.java:1053) @ android.app.activitythread.performlaunchactivity(activitythread.java:2099) what reason? can please me?

php - Twilio costs, and displaying alternative name as phone number -

i sending sms using twilio, , says there pricing sms costs $0.02 when sending texts philippines. looked @ account , noticed charged $0.20. also, how can display "gian" sender instead of random twilio number when sending sms because receiving sms +123178232(whatever) , changed name.. can has done before or has idea on how to me? twilio developer evangelist here. if there has been billing mistake, i'd advise take our team emailing help@twilio.com , including account sid. in order send sms messages using alphanumeric sender id need check country sending messages supports alphanumeric sender ids (the philippines does) , use text want send instead of twilio number from parameter in rest api call. so: // require twilio helper library require "services/twilio.php"; // set accountsid , authtoken www.twilio.com/user/account $accountsid = "acxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $authtoken = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; $cl

twitter bootstrap - PHP header won't redirect to home.php -

i'm following this video tutorial on website designing myself. have run 2 major problems: the first being when code comes header("location: home.php"); command script erases entire screen instead , echo's pass onto blank screen. meaning login credentials have passed. reason header() function not redirecting home.php page. site hosted on bluehost.com. my second problem while loop commented out not allow page load problem has stumped me. code: <header id="header"> <?php include ( "./inc/connect.inc.php" ); session_start(); if(isset($_post['login'])){ $user_login = strip_tags(@$_post['user_login']); $password_login = strip_tags(@$_post['login_password']); $password_login = md5($password_login); $sql = mysql_query("select id users email='$user_login' , password='$

css3 - Fixed content header with a flexbox layout that has scrollable content area -

i want content header fixed content scrolls underneath. classic holy grail layout using flexbox scrollable content area. i have tried setting content header fixed position , adding padding works sort of not take full width of content area. html, body { height: 100%; min-height: 100%; overflow: hidden; } .holy-grail { display: flex; height: 100%; flex-direction: column; width: 80%; margin: 0 auto; } .holy-grail-body { display: flex; flex: 1; } .holy-grail-content { flex: 1; background: #ffc94e; overflow: auto; } .holy-grail-content-header { background: lightyellow; height: 50px; } .holy-grail-nav, .holy-grail-sidebar { /* 12em width of columns */ flex: 0 0 12em; background: #c9ea5d; } .holy-grail-nav { /* put nav on left */ order: -1; background: #85d6e4; } header { background: #92e4c9; } footer { background: #f7846a; } * {

jquery - JavaScript static function in callback -

hi i've been trying clarify there's i'm still confused about. know can't return values asynchronous functions i've referenced answer's top answer returning value asynchronous javascript method? what i'm trying use flickrapi biggest size image. flickrapi allows 1 search images, use photo_id, use photo_id procses request api's getsize method url biggest size photo. the code looks little messy is, because have method called flickrrequest sends xmlhttp request , gets json string. know can achieve want writing functions follows: function flickrqforimage() { ...got id function flickrrqforsize() { ...got maxsizeurl create image based on maxsizeurl here } } but wondering if possible this function flickrqforimage() { ...got id function flickrrqforsize() { ...got maxsizeurl } create image based on maxsizeurl here } or create image based on maxsizeurl here in general question whether possible have

vbscript - WshShell.SendKeys - SLASH not allowed? -

today having difficulties following code: x=msgbox("your text here" ,0, "your title here") username=inputbox("after message, have 5 seconds switch minecraft. please enter username wish type song to:") wscript.sleep 5000 wshshell.sendkeys "/msg" + username + "i know met maybe dumb feels there moment" wscript.sleep 1000 wshshell.sendkeys "/msg" + username + "that touched 'cause, it's alright, it's alright wanna make mine way you're lightin'" wscript.sleep 1000 wshshell.sendkeys "/msg" + username + "up room caught corner of eye can both sneak out door don't have say" wscript.sleep 1000 wshshell.sendkeys "/msg" + username + "goodbye 'cause, it's alright, it's alright waste time tonight maybe i'm kid in love" wscript.sleep 1000 wshshell.sendkeys "/msg" + username + "maybe i'm kid in love oh, baby if it's falling in

linux - How to handle missing values while calculating average in shell script? -

i have dataset many missing values double slash (//). part of data input.txt 30 // 10 40 23 44 // // 31 // 54 // , on i calculate average in each 6 rows interval without considering missing values. trying this, not getting need. awk '{if ($1 -ne "//") sum += $1} (nr%6)==0 {print(sum/nr)}' input.txt it giving 24.5 19.33 but answer should come 29.4 42.5 you need modify awk bit obtain output as $ awk '!/\//{sum += $1; count++} nr%6==0{print sum/count;sum=count=0}' test $ awk '!/\//{sum += $1; count++} nr%6==0{print sum/count;sum=count=0}' file 29.4 42.5 what does? !/\//{sum += $1; count++} !/\// pattern checks if line doesn't contain / {sum += $1; count++} when line doesn't contain / action performed, sums column 1, $1 sum , increments count tells how many digits awk has seen till next print. nr%6==0{print sum/count;sum=count=0} when number of records, nr multiple of 6 , print average, sum/coun

Using addEventListener To Handle jQuery Click Events On Selectors Inside Google Maps infoWindow With jQuery UI Maps -

the problem: when trying fire jquery events on selectors within google maps infowindow, click event listener required catch events within gmap object must parent other click functions, resulting in failure click events fire on first click. all solutions found here on stackoverflow showed how add eventlistener, still did not account failure fire on first click issue. the solution below work if using jquery ui maps populate clickable markers open infowindows, , want able target elements inside infowindow jquery events on main (parent) page. this solution solves typical first fire issue resulting nested click functions, jquery events not fire on first click, since functions must within addeventlistener $('map_canvas').gmap() in order caught - then, of course, nested within click function , therefore wouldn't fire until second time clicked. there surely more standard and/or eloquent ways of achieving this, aside requiring non-typical syntax, solves issues , makes qu

c++builder - Define and build lapsed timer -

in delphi, understand how build lapsing timer. not sure how write code c++builder. not find example. in delphi wrote code below, copy source somewhere:- .... type tframe2 = class(tframe) statusbar1: tstatusbar; timer1: ttimer; constructor tframe2.create(theowner: tcomponent); begin inherited create(theowner); starttime := now; timer1.enabled := true; end; destructor tframe2.destroy; begin inherited destroy end; procedure tframe2.timer1timer(sender: tobject);//this event occurs every second. var hour, min, sec, msec : word; diff : ttime; begin timer1.enabled := false; diff := - starttime; decodetime(diff, hour, min, sec, msec); statusbar1.panels.items[1].text := inttostr(min)+' minutes, '+inttostr(sec)+' seconds.'; timer1.enabled := true; end; ... please kindly how same in c++. thanks try this: .... class tframe2 : public tframe { __published: tstatusbar *statusbar1; ttimer *timer1; ... void __fastcall timer1ti

hadoop - Context Object in JAVA MapReduce -

this question has answer here: what keyword context in hadoop programming world? 2 answers what use of context context in map() method. public void map(longwritable key, text value, context context) extracted here in: map(object key, object value, context context) to allow serialization , transfer of types of data, java defines own writable class. these box classes text (for string), intwritable (for integers), longwritable (for long) instances of base class writable (for values), , instances of writablecomparable (for keys). context used collect , write ouput intermediate final files.

c++11 - creation of priority queue - c++ -

i want create general priority queue. yes know can achieved stl still don't have full understand of , why want build 1 myself. when general mean in sense act same int,string,any class,etc. understand each item in queue needs have @ least 2 fields : 1. value 2. priority figure value field should template found out there ain't such option. bit lost here should locate template , how use afterward. edit1: 1st 2 comments said question broad i'll try narrow down. lets got start of pq: template <class t> class stack { public: int priority template <t> value stack(s); //ctor } this code how fought should written doesn't compile. if had methods in class need write before each implementation of each method : template<class t> or maybe can use : stack<t>::stack(int s) //ctor if @ std::priority_queue<t, c, p> you'll see takes 3 template parameters: the value type t . the type of underlying container c (defaulted

javascript - Why doesn't the Reflux.js listenAndPromise helper work? -

i'm using qwest query endpoint shown below, ongetresourcecompleted handler fires expected data undefined. why? var actions = reflux.createactions({ 'getresource': { asyncresult: true } }); actions.getresource.listenandpromise(function (id) { return qwest.get('http://localhost:8000/my-data/'+id, null, { withcredentials: true }); }); var mystore = reflux.createstore({ listenables: actions, init: function () { actions.getresource(''); }, ongetresourcecompleted: function (data) { console.log('ok', data); // get's called data undefined. why? } }); i can see data loads correctly looking @ dev tools calling qwest in isolation doing: qwest.get('http://localhost:8000/my-data/'+id, null, { withcredentials: true }).then(function(data) { console.log('ok', data); }); also doing following works : serviceactions.getresource.listen(function (id) { serviceactions.getresource.promise( qwest.get(

html - Continue ordered list numbering automatically -

i wonder how can have following ordered list in html 1 item 1 1a item 2 1b item 3 2 item 4 2a item 5 2b item 6 2c item 7 3 item 8 like this: ol.number, ol.letter { list-style-type: none; } ol.number { counter-reset: number; } ol.letter { counter-reset: letter; } ol.number > li:before { content: counter(number, decimal) " "; counter-increment: number; } ol.letter > li:before { content: counter(number, decimal) counter(letter, upper-alpha) " "; counter-increment: letter; } <ol class="number"> <li>item 1</li> <ol class="letter"> <li>item 2</li> <li>item 3</li> </ol> <li>item 4</li> <ol class="letter"> <li>item 5</li> <li>item 6</li> <li>item 7</li> </ol> <li>item 8</li> </ol> or if you

bash - Grep string between two html comments in pages -

i have report on how many times css class appears in content of our pages (over 10k pages). trouble is, header , footer contains class, grep returns every single page. (not useful) so, how grep content? i have <!-- main content --> , <!-- end content --> comment on every page. so how grep (do grep?) between comments? this hosted on linux server, , have access grep, awk , sed. ideally, report (.txt or .csv) pages , line numbers class shows up, list of pages suffice. thanks! the following script performs requested: print files , line numbers css class name occurs: #!/bin/sh pattern="class=\"([a-za-z0-9_-]* )*$1( [a-za-z0-9_-]*)*\"" awk -v pat="$pattern" ' /<!-- main content -->/ {y=1} /<!-- end content -->/ {y=0} y && $0 ~ pat {f[filename] = f[filename]" "fnr;} end {for (k in f) printf "%s\tlines:%s\n", k,f[k];} ' *.html save class_find.sh use this: cla

html - what's wrong with my php syntax? -

i'm trying display products on page hoping store products , attributes in 2d array include them on page , display them. way add products editing 2d array. here's catalog.php <?php $varproduct = array ( // title, style, price, number of xsmalls, number of small, number of medium, number of large, number of xl, number small picture path, medium picture path, large picture path, sale array("title" , 10213 , 100, 0,0,1,1,0, "/womens/tops/s/2.png", "/womens/tops/s/2.jpg", "/womens/tops/s/2.jpg", 50 ) array("title" , 10213 , 100, 0,0,1,1,0, "/womens/tops/s/2.png", "/womens/tops/s/2.jpg", "/womens/tops/s/2.jpg", 50 ) ) ?> i want display title index [0] picture index [8] , price index [2] here's mypage.php <h3 style="margin-bottom:20px; left:10px; position:relative;"> new women's designs , colors </h2> <?php include("catalog.ph

sass - SCSS Compilation error using mixin / semantic grid -

i've added semantic grid css file project , imported homepage.scss. '.column(x)' causing compilation error. i'm doing stupid - spot issue? @import '../layout/main.scss'; @import '../base/grid.scss'; $columns: 12; $column-width: 60; $gutter-width: 30em; $total-width: 100%; .banner{ .column(6); background: pink; height: 5em; } scss syntax different less. need: @include column(6);

editor - IJG library or Windows photo viewer DQT generation -

the question is: how windows photo viewer generates dq (discrete quantization) tables? and/or how editor or application uses ijg library generates dq tables? i'm trying find out algorithm of recomputing tables when image resaved , parameters of computes them. the ijg library uses baseline set of quantization tables using sample 1 in jpeg standard (or @ least used to). uses "quality" parameter scale values in tables. off top of head, quality setting 75 uses unmodified table. quality values higher baseline scale values smaller. lower quality values scale them larger.

Django - How to make migrations locally within an application while overriding User or Group model? -

i have application 'registration' in trying add field in django auth groups. have implemented using monkey patching. however, when post application else , run 'migrate', build fails stating reason newly added field not exists. reason being when created migrations, migration files not created in 'registration' application, instead, created in django.contrib.auth application. how can past problem? i solved adding dummy migration file in application - 'registration'. inside migration, created column manually executing sql query build not fail. i'll post code here. def check_and_add_column(apps, schema_editor): import sqlite3 conn = sqlite3.connect('db7.sqlite3') cur = conn.cursor() result = [true in cur.execute('pragma table_info(auth_group)') if i[1] == 'is_auto_assign'] if not result: cur.execute('alter table auth_group add column is_auto_assign boolean default false') class migration(

Why is 'SHOW WARNINGS' query issued here? (JPA/Hibernate/MySQL) -

we refactoring persistence layer of java application jdbc template jpa/hibernate. i profiling sql statements being issued database , see "show warnings" issued many, many times. according jprofiler "show warnings" accounting considerable amount of 'inherent time'. what cause show warnings issued frequently? this show warnings not issued when using jdbc template. below part of our stack relevant persistence. change here introduction of jpa/hibernate. jpa / hibernate: 4.3.6 mysql driver: 5.1.33 mysql database: 5.6.20 jdbc connection pool: hikaricp-2.3.2 edit: here's sample stack trace of when show warnings issued. com.mysql.jdbc.statementimpl.getwarnings() com.zaxxer.hikari.proxy.preparedstatementjavassistproxy.getwarnings() org.hibernate.jpa.internal.queryimpl.getsingleresult() com.mysema.query.jpa.impl.abstractjpaquery.getsingleresult(javax.persistence.query) com.mysema.query.jpa.impl.abstractjpaquery.uniqueresult() com.mysema.qu

android - WebSocket and Rx Java -

i'm develop android app communicates server using protocol websocket. use asyncandroid lib. websocket has listener, receive data server. something this private websocket.stringcallback mstringcallback = new websocket.stringcallback() { @override public void onstringavailable(string s) { } }; i need write api this, , want use rxjava. cannot imagine, should observable, , observer. tried observable string received server websocket listener, think bad idea. there ideas how correctly build api. thank u. you wrap websocket new interface this: interface rxwebsocket { void send(byte[]); // send data observable<string> stringobservable(); // receive string data } then in rxwebsocket implementation can use publishsubject internal websocket.stringcallback publish strings.

android - How to place the Floating Action Button exclusively on one fragment only in Tab layout -

i trying achieve following no success.i have 2 material design swipe tabs.i used this library 'com.oguzdev:circularfloatingactionmenu:1.0.2' achieve fab when swipe tab second tab,the fab still attached new fragment. i hide fab on second fragment . there way achieve this? here did similar kind of problem. declared coordinator layout fragment. inside coordinator layout can see in image have declared recyclerview use , below declared floating action button. after inflated layout floating action button in oncreateview fragment method. here xml file code: <android.support.design.widget.coordinatorlayout android:id="@+id/main_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:focusableintouchmode="true"> <edittext

excel - Searching for a case-sensitive VBA version of sumproduct function -

Image
what looking suggestion regarding formula use macro. macro meant search column string ( "can" ), , return summation of of corresponding numeric values column 3 rows over, long case sensitive string present. i've searched vba version of vlookup, tried sumproduct, index/match, etc., necessity of macro being not case sensitive summation of multiple numeric values has led roadblocks of these functions. i not experienced programmer means, , sorry if post vague. make simpler (hopefully), i'm looking best function use if want make macro take following list, search "apples", , have value 21 return. if not site for... let me know , i'll delete post. oranges apples $10 apples oranges $12 pears grapes $14 grapes oranges $18 apples oranges $19 oranges pears $16 apples oranges $11 i reiterate here: pivot tables . they're little intimidating @ first, designed track kind of data. link gives tutorial. if adamant done in

java - Debugging service test client: Netbeans debugger won't recognize Glassfish server -

here's i've done far: did fresh build of project (web service project). redeployed project war file glassfish server. restarted server --debug=true. attached debugger netbeans. debugger attaches server without error (responds "user program running"), debug tab (in projects/files/services window) different services supposed attached fails show did when working. when try start debugging project, server dropdown doesn't have servers in it, , won't let me start debugging without selecting server. glassfish version 2.1.1. netbeans version 7.4 patch 3. jre version 1.7.0_79-b15. i'm bit of netbeans newbie, apologize if i've left out information that's important. can see i'm doing wrong? check if netbeans,jdk , glassfish server installed in same folder program files(x86) or program files.if not re-install them. use netbeans 7.0.1 ,glassfish 3.1.1 , jdk 1.7 , runs fine. if problem else if not clear question, @ https://n

javascript - Perform an arithmetic calculation in jquery -

i have looped through database table , displayed records in page. in every single record displayed there 3 essential elements - span class called "cost-per", 2nd span class called "quantity" , 3rd 1 called "total-cost". there 2 submit buttons use ajax increase , decrease quantity in database. here's problem. when press increase/decrease button, works , value in span class of "quantity" updated new database value. when ajax gives me new "quantity" result database, not want display it. want multiply value in "cost-per" span element , display result in "total-cost" span element. can me this? possible perform arithmetic calculations in jquery? thank in advance , sorry being wordy. here php display records: if(mysqli_num_rows($run) >= 1){ while($row = mysqli_fetch_assoc($run)) { $name = $row['name']; $quantity = $row['quantity&#

Oozie on YARN - oozie is not allowed to impersonate hadoop -

i'm trying use oozie java start job on hadoop cluster. have limited experience oozie on hadoop 1 , i'm struggling trying out same thing on yarn. i'm given machine doesn't belong cluster, when try start job following exception: e0501 : e0501: not perform authorization operation, user: oozie not allowed impersonate hadoop why , do? i read bit core-site properties need set <property> <name>hadoop.proxyuser.oozie.groups</name> <value>users</value> </property> <property> <name>hadoop.proxyuser.oozie.hosts</name> <value>master</value> </property> does seem problem? should contact people responsible cluster fix that? could there problems because i'm using same code yarn did hadoop 1? should changed? example, i'm setting namenode , jobtracker in workflow.xml, should jobtracker exist, since there resourcemanager? have set address of resourcemanager, left property name jobtr

javascript - appending div in JS as string(?) -

i'm using google maps api, , i'm trying have "card" appear (as apposed tooltip/infobox) when clicking on marker. followed this card appear. however, method person uses appending huge string html white box links/information hard coded string. i'm trying change can dynamically insert desired information (i've stripped down code of card displays grey box when clicking on marker, can see code here ). the important bit of code is:` google.maps.event.adddomlistener(marker, 'click', function() { // prevents card being added more once (i.e. when page resized , google maps re-renders) if ( $( ".place-card" ).length === 0 ) { var rootdiv = document.createelement('div'); rootdiv.style = ('position', 'absolute'); rootdiv.style = ('right', '0px'); rootdiv.style = ('top', '0px'); var seconddiv = document.createelement('div'); seconddi

Ruby on Rails 4.2.2 ArgumentError (wrong number of arguments (2 for 1)) -

this question has answer here: rails 'parse_query' error on server in brand new app 2 answers i've cleaned out of gems due issue , tried reinstall via following: $ gem install rails $ rails new myproject $ cd myproject $ rails server while above seems pretty straightforward new rails installs, got following 500 error: $ rails server => booting webrick => rails 4.2.2 application starting in development on http://localhost:3000 => run 'rails server -h' more startup option' => ctrl-c shutdown server [2015-06-18 16:44:22] info webrick 1.3.1 [2015-06-18 16:44:22] info ruby 2.2.0 (2014-12-25) [x86_64-darwin14] [2015-06-18 16:44:22] info webrick::httpserver#start: pid=60434 port=3000 started "/" ::1 @ 2015-06-18 16:44:27 -0400 argumenterror (wrong number of arguments (2 1)): actionpack (4.2.2) lib/action_dispatch/h

java - What am I missing on my layout? I can't seem to get the sizes right -

i need have sidebar measures wrong. can't make them resizable , have right size. want jlabels left of corresponding text fields , and button right of them all-- in 1 panel in north , 2 panels below, 1 center , 1 south. missing? this panel code: package csheets.ext.findnetworkworkbooks.ui; import csheets.core.cell; import csheets.ext.findnetworkworkbooks.searchnetworkextension; import csheets.network.protocol.echo.echo; import csheets.ui.ctrl.uicontroller; import java.awt.borderlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import javax.swing.defaultlistmodel; import javax.swing.jbutton; import javax.swing.jlabel; import javax.swing.jlist; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtextfield; import javax.swing.listselectionmodel; /** * * @author eduardo pinto <1130466@isep.ipp.pt> */ public class