Posts

Showing posts from April, 2011

php - Setters and objects -

i've added method class: /** * @param string|streamableinterface $body * @return message */ public function setbody($body) { $this->body = $body instanceof streamableinterface ? $body : new stringstream($body, true); return $this; } and occurs me semantics little bit different depending on if pass method string or object. if give string, construct new object, otherwise create reference object provide, means can further modify object outside class in 1 case, not other. is bad practice? should create full clone of object if pass 1 in? i'm not sure expected behaviour is. in opinion, stream shouldn't cloned , should keep code way is. consider have done best practice. if wants object have own isolated stream, should give object own stream—i leave decision caller. your method commonly done in every similar scenario have seen.

html - Side banner on a webpage -

Image
how make banners along top , bottom of page ( http://i.imgur.com/sxjbcjv.jpg ) instead @ both sides of page? i have them both fixed top , bottom of page: #header { position: fixed; top: 0; width: 100%; height: 66px; z-index: 999; } #footer { position: fixed; bottom: 0; width: 100%; height: 66px; z-index: 999; } and html: <body> <div id="wrapper"> <a href="project.html"> <div id="header"> <button id="next-button" href="project.html"><i class="fa fa-arrow-circle-right fa-4x"></i> </button> </div> </a> <div id="main"> <div id="splash"> <div id="name"> <h1 class="wow animated flipinx">max wilson</h1> </div> <div id="profi

javascript - jQuery Before (and other DOM manipulations) Not Executing in Internet Explorer -

i've been searching through stackoverflow, jquery, , google answer, thinking surely there definitive answer on why can't jquery call .before() run in internet explorer. seems work correctly in chrome, firefox, safari , opera. original problem have fixed breadcrumb , nav bar @ top of document. rest of document contains many paragraphs enclosed in appropriate <p></p> tags. before every opening p tag, anchor in format of <a name='paragraphidentifier'>paragraphidentifier</a> . typically format of pargraph identifier citational (1)(b)(a) . since introducing nav bar @ top of page, external hyperlink 1 of these anchors, causes anchor appear beneath toolbar. found seems reasonable fix pixelflips.com found here adding span tags class above anchor. i used jquery accomplish adding span tags suggests using below jquery code , related css: if(window.location.hash){ var myhash = window.location.hash; var hashname = m

Where are symbols loaded from in a c# application -

i have c# application got developers. when application starts run, see message box telling me symbols loading. located on machine, there 1 message says: loading symbols tiprodata.dll from: \\missioncontrol\users\klewis2\documents\cvsroot\c_sharp\tiprodata\obj\release i not connected called missioncontrol. question application information load symbols here? also, when end application, see these warning messages in output window: windowsformsapplication1.vshost.exe' (clr v4.0.30319: windowsformsapplication1.vshost.exe): loaded '\\psf\home\downloads\trade-ideas api2 new2\trade-ideas api2\ti_pro_api\ti_pro_api\ti_pro_api\tiprodatatest\tiprodatatest\bin\debug\tiprodata.dll'. cannot find or open pdb file. windowsformsapplication1.vshost.exe' (clr v4.0.30319: windowsformsapplication1.vshost.exe): loaded '\\psf\home\downloads\trade-ideas api2 new2\trade-ideas api2\ti_pro_api\ti_pro_api\ti_pro_api\tiprodatatest\tiprodatatest\bin\debug\serverconnection.dll

multithreading - Setting multiple values of 3 different labels via cross threading c# winforms -

so got code runs on usb connect event. if , android device detected runs build prop related code. however... manages return android version , nothing else. code below. private void main_shown(object sender, eventargs e) { var watcher = new managementeventwatcher(); var query = new wqleventquery("select * win32_devicechangeevent eventtype = 2"); watcher.eventarrived += new eventarrivedeventhandler(watcher_eventarrived); watcher.query = query; watcher.start(); } private void watcher_eventarrived(object sender, eventarrivedeventargs e) { process process = new system.diagnostics.process(); processstartinfo startinfo = new system.diagnostics.processstartinfo(); startinfo.windowstyle = system.diagnostics.processwindowstyle.hidden; startinfo.redirectstandardinput = false; startinfo.createnowindow = true; startinfo.redirectstandardoutput = true; startinfo.

javascript - Stopping Angular.js from running on pages in a specific directory -

i working on optimizing angular site seo. have necessary static pages being scraped , created, problem i'm seeing despite .htaccess serving static page when hitting corresponding url rewriteengine on rewritecond %{query_string} ^_escaped_fragment_=/?(.*)$ rewriterule ^(.*)$ %{request_uri}/snapshots/%1.html? [nc,l] the whole process go this: 1.google crawler hits mysite.com/#/home 2.crawler see's angular site (thanks < meta name="fragment" content="!" > ) , re-crawls page given url of mysite.com?_escaped_fragment_=home 3. .htaccess sees , redirects crawler mysite.com/snapshot/home.html houses static page content. have indexed page. for aren't familiar i'm trying http://www.yearofmoo.com/2012/11/angularjs-and-seo.html it looks though angular still firing, continues append hashtag url (www.mysite.com?_escaped_fragment_=home/#/home). how stop angular adding url given static pages living in specific directory? original thoughts

null - MySQL: AVG when there are no matching rows -

i'm creating website users can rate items (say books), 1 5 stars. have created mysql database , table stores info each rating (itemid, userid, ratingvalue). each item has dedicated webpage, , i'd put on page info about: (1) number of ratings , (2) average rating. thought best done view. in thinking mysql queries use in view, came to: select itemid, count(ratingvalue), ifnull(avg(ratingvalue),0) reviews group itemid problem: if item not yet rated, not appear on query. items appear in query result (view), , if there item no reviews, should appear information there 0 reviews , average rating arbitrary value, let's 0. from official documentation , avg() returns null if there no matching rows and reason tried use ifnull() function. however, doesn't work. example, in database items 1,2,3,4,5, item 5 has no reviews, i'll get: itemid count(rating) ifnull(avg(ratingvalue),0) 1 4 4.0000 2 2 4.0000 3

yarn - Getting NullPointerException when using a S3 job file with Samza -

i'm getting following exception when passing s3 file path yarn.package.path. exception in thread "main" java.lang.nullpointerexception @ org.apache.hadoop.fs.s3native.natives3filesystem.getfilestatus(natives3filesystem.java:433) @ org.apache.samza.job.yarn.clienthelper.submitapplication(clienthelper.scala:111) @ org.apache.samza.job.yarn.yarnjob.submit(yarnjob.scala:54) @ org.apache.samza.job.yarn.yarnjob.submit(yarnjob.scala:47) @ org.apache.samza.job.jobrunner.run(jobrunner.scala:62) @ org.apache.samza.job.jobrunner$.main(jobrunner.scala:37) i'm able curl s3 file same box (after exporting aws environment variables). how package path set in job properties file: yarn.package.path=s3n://{access_key}:{secret_key}@bucketname/path1/path2/tar.gz

dns - Combine data types in SQL Server -

is there way combine data types in sql server? i.e. have value of cell both text , number text same? i have table called contract . contractid field should have value of: 'tcwxyz' 'tc' string characters , 'wxyz' integers. i have following doesn't seem working: create type tenantcontracts char(6) check (substring(value,1,2)='tc' , (substring(value,2,4) smallint) any assistance appreciated. constraints added table definition, don't need create type. alter table contract add constraint chk_contractid check ( substring(contractid, 1, 2) = 'tc' , isnumeric(substring(contractid, 3, 4)) = 1 ) this solution accept few incorrect values, instance tc1.01 . i'd use virtue of simplicity though, rather trying determine if last 4 digits integer, gets surprisingly tricky ( t-sql - determine if value integer ). edit: if did want make more robust integer check, perhaps best check individually if each of last 4 char

c - Store argv to an int array -

i have code store argv dynamically allocated int array: int *data; // pointer array of integer numbers int size; // size of data array int main(int argc, char* argv[]) { // initialize array data size=argc; printf("%dsize=\n",size); printf("%d\n",argc); data=(int*)calloc(size,sizeof(int)); int i=0; (i=1;i<size;i++) { data[i]=argv[i]; printf("%d\n",data[i]); } (i=1;i<argc;i++) { printf("%d\n",argv[i]); } return 0; } when run in command line: ./sumprime 5 1 2 3 4 prints: 6size= 6 15311660 15311662 15311664 15311666 15311668 15311660 15311662 15311664 15311666 15311668 not array of 5 1 2 3 4 expected. how can store int array argv , print out? should be: data[i]=atoi(argv[i]); remember command line argument strings. though pass integer in command line string needs converted integer.

javascript - How to synchronize two text areas within separate iframes? -

i have 2 iframes, both of contain form text area. my goal synchronize 2 text areas, user types in 1 reproduced in other. how can across 2 (or more) separate iframes? main document: <script> $("iframe").ready(function(){ $(".editor").keyup(function(){ $(".editor").val($(this).val()); }); }); </script> <iframe src="/editor.php?mode=post&f=1" class="iframe-editor"></iframe> <iframe src="/editor.php?mode=post&f=2" class="iframe-editor"></iframe> content of iframes: <fieldset class="fields1"> <textarea name="message" id="message" class="editor">{message}</textarea> </fieldset> as of now, jquery script works if text areas placed in main document. the way have set doesn't work because ".editor" belongs dom. however, can access dom using "contentwindow&

r - Graphing a histogram overlaid with a fitted 2 parameter Weibull function -

Image
i plot both histogram fitted weibull function on same graph. code plot histogram is: hist(data$grddia2, prob=true,breaks=5) the code fitted weibull function is:(need mass package) fitdistr(data$grddia2,densfun=dweibull,start=list(scale=1,shape=2)) how plot both on same graph. i've attached data set. also, bonus can provide code can achieve same thing, create graph each column of data. many columns within data set. nice have graphs on same page. https://www.dropbox.com/s/ra9c2kkk49vyyyc/diameter%20distribution.csv?dl=0 here code library("ggplot2") library("dplyr") library("tidyr") library("mass") # import dataset , filter column "treeno" # use namespace dplyr:: explicitly because of conflict mass:: function "select" data <- read.csv("diameter distribution.csv") %>% dplyr::select(-treeno) # function provide weibull distribution each column # distribution calculated base

javascript - Highlighting row of a HTML table which is populated using AJAX return data -

how row value of table on mouse click? data in table populated data returned using ajax. below code not working: $('table#tblbdy tbody tr').click(function() { $('tr').click(function () { var tabledata = $(this).closest("tr").children("td").map(function() { return $(this).text(); }).get(); $('#bx1txt').val($.trim(tabledata[0])); $('#bx2txt').val($.trim(tabledata[1])); $('#oldqty').val($.trim(tabledata[1])); }); i'm not sure follow question, title , descriptions seem conflict. looking value specific cell on click? question says want value of row... if understand correctly, either want value of specific cell when clicked, or want highlight row of cell clicking. i have setup codepen http://codepen.io/anon/pen/oxnemx simple solution. depending on how table generated, can put javascript code it's own function , call function whenever have new ajax data click handler gets bo

excel - How to skip unresponding url from list of urls in php -

i have list of urls in excel xheet. reading urls excel sheet , existing urls , non existing urls storing in serapare text files. problem if url not responding loop stopped. aim ship url , check next url. require_once 'excel_reader2.php'; $data = new spreadsheet_excel_reader("urls.xls"); $totalsheets=count($data->sheets); for($i=0;$i<count($data->sheets);$i++) // loop sheets in file. { if(count($data->sheets[$i][cells])>0) // checking sheet not empty { $totalrows=count($data->sheets[$i][cells]); for($j=1;$j<=count($data->sheets[$i][cells]);$j++) // loop used each row of sheet { $name=$data->sheets[$i][cells][$j][1]; $url=$data->sheets[$i][cells][$j][2]; $file_headers =get_headers($url); if(strpos($file_headers[0],"200")==true || $file_headers[0]!= 'http/1.1 404 not found') { $exists = 'yes';

Oracle Contains Query Returning False Positives -

i trying search names in clob field in oracle using contains. know text testing on contains 'joe smith' 1 space in between joe , smith, query works returns records when run it: select * case_search contains(text, 'joe smith', 1) > 0 the issue query, 2 spaces between joe , smith, returning text hit text has 'joe smith' 1 space , not 'joe smith' 2 spaces: select * case_search contains(text, 'joe smith', 1) > 0 i can add many spaces in between joe , smith , still returns hit. need add name hit in exact form table in order work later. can explain happening here , how fix it?

Text search not working with sunspot rails -

i'm implementing basic search bar sunspot. code seems work search result returns no object. don't understand why , after reading sunspot documentation, i'm bit lost. if can give me clue, helpful. here code : my controller: class bookscontroller < applicationcontroller before_action :set_book, only: [:show, :edit, :update, :destroy] respond_to :html def index @search = book.search fulltext(params[:search]) end @books = @search.results respond_with(@books) end # additional code end my model: class book < activerecord::base has_many :wishs has_many :loans validates_presence_of :title, :author, :description enum status: [ :available, :unavailable, :on_loan ] searchable string :title string :author string :description end end my view: <div class="container"> <div class="row"> <h1>listing books</h1> <%= form_tag books_path, :method => :get

vhdl - Vivado Including Black Box Module -

i have never come across problem before when uses black-boxes inside custom ip. instantiate , add custom ip project, , instantiate , add black box ip modules (the black boxes inside custom ip) project. for reason getting classic [project 1-486] not resolve non-primitive black box cell 'fx_thomas_core_0fx_thomas_core_0fx_thomas_core_0thomas_sub' instantiated 'subtractor' ["c:/users/sam/documents/zynq7020/fx_parallel_thomas_solver/fx_parallel_thomas_solver.srcs/sources_1/ip/fx_thomas_core_0/work/fxthomascore.srcs/sources_1/imports/sources_1/imports/sam/documents/zynq7020/thomas_solver_1.1/mult_sub_core.vhd":109] here can see trying use black box subtractor inside custom ip, described above, have created , added subtractor ip (with correct name) project yet fails compile black box during implementation. am missing project setting picks , replaces black box project ip? just add clarity question: project -> axi_perph -> my_ip(imp

c# - What is the dispatcher priority given to the action when you call Dispatcher.Invoke(Action)? -

what dispatcher priority given action when call dispatcher.invoke(action)? i understand how dispatcher.invoke(action, dispatcherpriority) works, assume if leave out dispatcherpriority parameter give action default dispatcherpriority value. wrong? if no default value? thanks! you can in reference source microsoft directly in source code. it using dispatcherpriority.send . the reference source comes pretty handy cases this.

sockets - How to send character from android phone to arduino through Bluetooth? -

currently using arduino nano receive data , transmit android phone through bluetooth. want set button on smart phone, , after pressed it, transmit character arduino. have tested arduino if give command in serial monitor , give me analog read signal. i wanna ask how can transmit character(like "e") phone arduino? following code associated bluetooth connection. else can add achieve goal? bluetooth code in arduino public class homescreen extends activity { private button mbtnsearch; private button mbtnconnect; private listview mlstdevices; private bluetoothadapter mbtadapter; private static final int bt_enable_request = 10; // code use bt enable private static final int settings = 20; private uuid mdeviceuuid = uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb"); // standard spp uuid // (http://developer.android.com/reference/android/bluetooth/bluetoothdevice.html#createinsecurerfcommsockettoservicerecord%28java.util.uuid%29) private int mbuffersize

sql server 2008 - sql format function -

i trying execute following query, error function format not exist. create table [prods]( [id] [int] not null, [shippeddate] [datetime] not null, [shipid] (format([shippeddate], 'yymm','en-us') +right('00000' + convert([varchar],[id]).(6))) ) what doing wrong? the format function available in sql server 2012+. formatting dates in 2008 , earlier bit cumbersome. can do right(cast(year([shippeddate]) nvarchar(4)), 2) + right('0' + cast(month([shippeddate]) nvarchar(2)), 2) to string consisting of 2 digit year plus 2 digit month.

node.js - error:a hook ('orm') failed to load when lifting sails app using Redis -

i trying connect project wigh sails.js redis, when try lift it, have error of readonly, the whole error next: error: hook ('orm') failed load! error: error: readonly can't write against read slave. @ hiredisreplyparser.execute (/home/victor/downloads/gestamp-desarrollo/gestamp-desarrollo/node_modules/redis/lib/parser/hiredis.js:30:33) @ redisclient.on_data (/home/victor/downloads/gestamp-desarrollo/gestamp-desarrollo/node_modules/redis/index.js:547:27) @ socket.<anonymous> (/home/victor/downloads/gestamp-desarrollo/gestamp-desarrollo/node_modules/redis/index.js:102:14) @ socket.eventemitter.emit (events.js:95:17) @ socket.<anonymous> (_stream_readable.js:746:14) @ socket.eventemitter.emit (events.js:92:17) @ emitreadable_ (_stream_readable.js:408:10) @ emitreadable (_stream_readable.js:404:5) @ readableaddchunk (_stream_readable.js:165:9) @ socket.readable.push (_stream_readable.js:127:10) @ tcp.onread (net.js:

android - Date and Time formatting from sqlite database -

i have formatted timepicker , datepicker data following formats hh:mm am/pm , dd/mm/yyyy, , stored both variables sqlite database. now, in activity need retrieve these values database, , pass pendingintent alarm through alarmmanager. my problem getting these values in activity database, can't figure out how compare these values current calendar time, , pass pendingintent cal.gettimeinmillis(). i tried using simpledateformat, catches parseexception: unparseable date can me out problem? in advance i have tried simpledateformat this simpledateformat sdf = new simpledateformat(" mm/dd/yyyy h:mm a", locale.us); try { cal.settime(sdf.parse(dnt)); } catch(parseexception e){ log.d(logcat, e.tostring()); }

yii2 gridview row css does not get applied after filter -

i have row css on gridview. after use filtering not applied. below view containg gridview <?php use yii\helpers\html; use yii\grid\gridview; /* @var $this yii\web\view */ /* @var $searchmodel app\models\surveyssearch */ /* @var $dataprovider yii\data\activedataprovider */ $this->title = 'surveys'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="surveys-index"> <h1><?= html::encode($this->title) ?></h1> <?php // echo $this->render('_search', ['model' => $searchmodel]); ?> <p> <?= html::a('create surveys', ['create'], ['class' => 'btn btn-success']) ?> </p> <p> published - available on website<br/> new - created ready publishing. not visible on website.<br/> <span class="red">deleted</span> - flagged deleted. not visible on w

c# - Why is nullable decimal crashing my object initializer? -

i have object called project. in project have property definition this: public decimal? fytotalcost { get; set; } then roll through datareader fill list of objects. while (dr.read()) { #region fill project object try { projects.add(new project { fytotalcost = (dr["fy_total_cost"] != null && dr["fy_total_cost"].tostring() != string.empty && dr["fy_total_cost"].tostring() != "") ? decimal.parse(dr["fy_total_cost"].tostring()) : (decimal?)null, this evaluates false in quick watcy: dr["fy_total_cost"] != null && dr

regex - Show vim buffers matching a pattern -

Image
in vim, can show open buffers running :buffers command, however, list can long, there way limit output filenames matching pattern? for example: how show *.c files? use ctrl-d after wildcard: :b *.c<ctrl-d>

ckan datapusher fails to read json header and types -

ubuntu 14.01 / ckan 2.3 installed source. utf-8. datapusher can't determine headers , types when uploading json datastore. top of file i'm trying upload/update (as shown text view ckan): { "type": "featurecollection", "features": [ { "type": "feature", "id": "baal_og_grillpladser.2", "geometry": { "type": "point", "coordinates": [ 10.3591, 55.407 ] }, "geometry_name": "wkb_geometry", "properties": { "navn": "Åløkkeskoven ved den gamle golfbane ", "beskrivelse": "bål- og grillplads på græsarealer ved Åløkkeskoven tæt på søhusstien. er også en lille overdækning hvor man kan søge ly, og der er en balancebane og en legeplads tæt på. perioden 1. maj til 1. oktober lægges der brænde ud før weekender og

ios - CAKeyFrameAnimation with Color from patternImage -

Image
i trying animate backgroundcolor of calayer cakeyframeanimation. when make classics colors works; color generated patternimage uicolor(patternimage:"imagename").cgcolor , doesn't work @ all. @ibaction func animfirstview(sender: anyobject) { addanim(view1, colors: [uicolor.blackcolor().cgcolor, uicolor.redcolor().cgcolor]) // works } @ibaction func animsecondview(sender: anyobject) { var firstcolor = uicolor(patternimage: uiimage(named:"stars1")!).cgcolor; addanim(view2, colors: [firstcolor]); // doesn't works @ :( } func addanim(view:uiview, colors:[cgcolor]) { let anim = cakeyframeanimation(keypath:"backgroundcolor") anim.values = colors; anim.keytimes = [0.0, 0.25, 0.5, 0.75, 1]; anim.calculationmode = kcaanimationdiscrete anim.duration = 0.3; anim.repeatcount = float.infinity; view.layer.addanimation(anim, forkey: "backgroundcolor"); } someone has idea? isn't pos

python serial write hexadecimal string -

i have string in python: string = "\x02\x30\x31\x48\x41\x4e\x4f\x56\x45\x52\x03\x38\x39" if do: serial.write(message) everyting works expected. here problem: i have function generates above string. if debug using print, exact same string shows up. however, when try send via serial, not send hex. sends longer text (52 instead of 13 bytes), not recognised receiving device. how can convince python send string containing same hex?

c++ - Bipartite Undirected Graph Test: Converting to check nodes with strings instead of integers -

i'm working on bipartite test undirected graphs, using adjacency-list representation. user inputs nodes , connect to, each line being pair. example: 0 1 2 3 1 2 0 3 means 0 connected 1 , 3, 2 connected 1 , 3, etc. algorithm bfs, coloring nodes goes, , seeing if can bipartite. in addition seeing if graph bipartite, stores , outputs nodes belong group in sorted order. following previous example, 1 , 3 in group a, 2 , 0 group b. sample output be: group a: 0 2 group b: 1 3 as best can tell, current algorithm works fine, has little no problem, save few "messy" code bits here , there cleaned up. here's entire program: #include <iostream> #include<vector> #include<queue> #include<map> #include<list> #include<algorithm> #include<set> #include <stdio.h> #include <stdlib.h> using namespace std; vector<int>vec[50]; map<int,int>color; queue<int>q; vector<int> b; vector<int> h; bo

ios - Resizing Behavior Button Missing From Xcode -

Image
i have xcode 6.3 installed on 3 macs latest version of yosemite , on every 1 of them resizing behavior button missing. can't find preference or view setting bring back. i've scoured internet, can't find similar issue. i've uninstalled , reinstalled xcode no joy. anyone else have issue? it's been removed permanently. apple says caused confusion siblings , descendents. check out stack button on same toolkit; apple recommends using stack views before pinning

Javascript code for auto-advance on matrix format in Qualtrics -

i'm creating survey on qualtrics i'm hoping auto-advance next page after survey taker makes his/her choice on last question of matrix. have javascript code auto-advance after click on single-choice question need edit auto-advance on click of last single-choice question in matrix table: var = this; this.questionclick = function(event,element){ if (element.type == 'radio') { that.clicknextbutton(); } } this can done programmatically using 2 more methods api; getchoices() , getselectedchoices(). allows write flexible code work regardless of order in choices selected or how many options presented. var = this; var choices = this.getchoices( "radio" ).length; this.questionclick = function( event, element ){ var selected = that.getselectedchoices().length; if ( choices == selected ) { that.clicknextbutton(); } } we compare number of choices number of answers , progress once each statement has been answered.

c# - Using Google maps API to Generate valid Addresses? -

i creating desktop c# application create test files, problem files need have valid addresses. there way can use 1 of google maps apis valid address put file create? you use google geocoder api pass addresses , receive data on location, such lat&long coordinates, specific address details, etc... data can validate if lets want limit addresses country or city. downside there limited requests day, should sufficient. the api extensive provide links below idea of it. documentation: https://developers.google.com/maps/documentation/geocoding/ example: https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple another example: http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html edit: article on address validation using geocoding: http://blog.mgm-tp.com/2011/08/address-validation-with-geocoding/ edit 2: here stackoverflow article on same topic: address validation using google maps api an example response following: {

c++ - Properly dereferencing pointer -

i struggling handling pointers in piece of c++ code. without further ado, let me show portion of code: in file1.cpp void *someclass::extract() { double foo = 3.14; return (void*) &foo; // returns pointer double } in file2.cpp void * bar = someclass->extract(); // fetches pointer double fprintf(screen, "pointer address: %p \t value: %.3e \n", bar, (double*) bar); (because of massive oversimplification of code, there may inconsistencies.) want print out value of foo in file2.cpp , retrieved calling function in file1.cpp . when compare pointer addresses of foo , bar , find identical. when want dereference pointer, bogus. suspect i'm doing wrong in dereferencing, when compare other sections of code (which did not write myself way), seems valid. i aware supposed basic c++, somehow not working me. i'd grateful if explain me how done properly. martijn you attempting return pointer automatic variable, destroyed extract function exi

Displaying MySQL in PHP -

so far, have program links phpmyadmin database php script. now, need display things in table "all records," "all contacts last name starts s," "all pet owners," etc. question is: there simpler way insert code php script display information database. right have long echo statement display information. there way can use select * statement display records , simplify code? <?php $db_hostname='localhost'; $db_username='root'; $db_password=''; $db_database='address book'; $connection = new mysqli( $db_hostname, $db_username, $db_password, $db_database); if ($connection->connect_error) { echo "sorry"; } else { echo "connected!<br><br>"; $sql = "select * people"; $result = $connection->query($sql); if (!$r

VBA Nested For Loop Crashing Excel -

i trying create list of possible combinations of entries 2 separate sheets, whenever try run it, excel crashes after 20 seconds. have tips how make more efficiently, or way make work? thanks! sub create() dim dates, groups, current integer dim datevalue date dim groupvalue string dim cell long application.screenupdating = false sheets(3).cells.clear cell = 1 dates = 1 730 sheets(1).select datevalue = cells(dates, 1).value groups = 1 155 application.statusbar = datevalue & " " & groupvalue sheets(2).select groupvalue = cells(groups, 1).value sheets(3).select cells(cell, 1) = datevalue cells(cell, 2) = groupvalue cell = cell + 1 next groups next dates application.statusbar = false application.screenupdating = true end sub remove .select calls. groupvalue = sheets(2).cells(groups, 1).value is better than sheets(2).select groupvalue = cells(groups, 1).value .select

java - User defined variables are executed twice in jasper -

i tried use variable in jasper report. created list component below. <componentelement> <reportelement x="0" y="0" width="426" height="50" uuid="a99e79ba-74a6-4224-a1e5-d8b8d557a42f"/> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetrun subdataset="dataset2" uuid="61554b87-1110-4c24-848a-c74c83ca33aa"> <datasourceexpression><![cdata[new net.sf.jasperreports.engine.data.jrbeancollectiondatasource(arrays.aslist("buenos aires", "córdoba", "la plata"))]]></datasourceexpression> </datasetrun> <jr:listcontents height="50

typo3 - Update content programmatically -

i publishing content on typo3 instance have editor rights. @ moment, content generated automatically html; workflow consists of copy html code log in typo3 select page click edit on html element of page paste html code submit is there library or api helps automating process? since normal editor in typo3 instance, assume cannot add typo3 extensions helps task. if alter typo3 instance, there numerous ways automate process: scheduler task fetches new content , puts page or fetches content mailbox or dropbox share etc.. the solution see browser automation perform task. use e.g. use chromium browser automation if work chrome. can record form entries (username, password, paste text rte) , clicks , should able define variables (id of page , content element, content itself).

Extract an exact key from object in Underscore.js -

i using underscore.js library. want extract exact key object. var student = {sid : 101; sname: "abc"} i have tried this. var key = _.findkey(student, 'sid'); but showing 'undefined' in key variable. me. the _.findkey can used this: _.findkey(student, function(x){ return x === 101}); // returns 'sid'

java - SMTPClient set timout for an open port -

my problem is: need discovery if 1 ip , port running smtp service. this, i'm using smtpclient try open connection. i'm using code below. private static boolean validatesmtp(string ip, int port, int timeout) { smtpclient smtp = new smtpclient(); try { smtp.setconnecttimeout(timeout); smtp.connect(ip, port); return true; } catch (socketexception e) { logaplication.warning("ops... wrong", e); } catch (ioexception e) { logaplication.warning("ops... wrong", e); } finally{ smtp = null; } return false; } it's working fine , i've gotten expected results, timeout has been problem. e.g: if try ip: 127.0.0.1 , port 80 (iis open port) connect step takes long (much more defined in timeout) throw exception java.net.socketexception: connection reset how can set timeout case? or existis way simple test ? after take @ grepcode , found method co

c++ - Cout Vector in Random Coordinates n times -

i trying cout vector 12 times in loop @ random coordinates. have created vector here: vector<item> sv(maxpills, pill); currently prints 1 of vector out. code random coordinates of vector , attempt @ printing 12 of them out. i'd appreaciate if help! void generatepowerpills(char gr[][sizex], item pill){ (int = 0; < 12; i++) { gr[pill.y][pill.x] = pill.symbol; } } void initialiserandompillscoordinates(vector<item>& sv) { //pass vector function give each pill random coordinates seed(); (size_t i(0); < sv.size(); ++i) { sv.at(i).y = random(sizey - 2); //vertical coordinate in range [1..(sizey - 2)] sv.at(i).x = random(sizex - 2); //horizontal coordinate in range [1..(sizex - 2)] } } i'd comment sadly can answer. anyway, you're iterating here: (int = 0; < 12; i++) { gr[pill.y][pill.x] = pill.symbol; } but using "i" inside loop? seems same, 12 times. unl

php - Get html between comments block Simple HTM DOM -

how can take block of dom identify 'comment' tag, like <!-- start block --> <p>hello world etc</p> <div>something</div> <!-- end of block --> i'm using simple php dom parser, doc incomplete, http://simplehtmldom.sourceforge.net/manual.htm . it's fine if can pure php. you can try iterate thru elements first, if found starting comment, skip first, add flag starts concatenation of next elements. if reach end-point, stop concatenation: $html_string = '<!-- start block --> <p>hello world etc</p> <div>something</div> <div>something2</div> <!-- end of block --> <div>something3</div> '; $html = str_get_html($html_string); // start point $start = $html->find('*'); $output = ''; $go = false; foreach($start $e) { if($e->innertext === '<!-- start block -->') { $go = true; continue; } elseif($e->in

Motion Detection in Kurento WebRTC -

we working on kurento media server . run example of node.js platedetector,pointdetector , crowddetector etc we facing problem how detect motion . let suppose if moves in front of camera , detects change calls event . in simple words if moves in front of camera want trigger event thanks. it default in kms-filters https://github.com/kurento/kms-filters/tree/master/src/gst-plugins/movementdetector

jquery - Replace an element when the window width is less than something -

the nav bar when resize browser window, logo stays under nav bar, come solution replace navbar when window lesser 500px image jquery isn't working. can please take look? , tell me what's wrong? thank you! function resizefunction() { if($(window).width() > 500) { if(!$('.head').hasclass('greater')) { $('#menu').show(); } } else { if(!$('.head').hasclass('less')) { $('#menu').hide(); $('#navbarbutton').addclass('less'); } } } .head header, #menu navbar , want replace button #navbarbutton. on html #navbarbutton style="display:none". can not achieve in pure css? use media query set #menu display:none when less 500px , #navbarbutton display:block in same media query. in css rest of page (when on 500px) set #navbarbutton display:none , #menu display:block. something this: #menu { di

c# - WPF Distorted Shape -

Image
i need add distortion effects shape in wpf. for example, want distort shape spikes such shown below: not sure trying achieve, if need static shape, can use path. advantage of path is, can create (or convert image to) vectors inkscape , export xaml path.

php - Google OAuth2 - isAccessTokenExpired() always true -

i use oauth in application , want log out user when access token expired. but when checked token expiration with $client->isaccesstokenexpired() it return 1. if (isset($_get['logout'])) { unset($_session['token']); } if (isset($_get['code'])) { $client->authenticate($_get['code']); $_session['token'] = $client->getaccesstoken(); $redirect = 'http://' . $_server['http_host'] . $_server['php_self']; header('location: ' . filter_var($redirect, filter_sanitize_url)); } if (!isset($_session['token'])) { $authurl = $client->createauthurl(); } if (isset($_session['token'])) { $client->setaccesstoken($_session['token']); $service = new google_service_calendar($client); $oauth2 = new google_service_oauth2($client); $userinfo = $oauth2->userinfo->get(); $emailuser = $userinfo->getemail(); $_session['ema