Posts

c# - Are delegates created via lambda expressions guaranteed to be cached? -

it seems working way, stated somewhere in spec or implementation detail can't depend on? i'm trying speed property/field name extraction faster creating expression tree once , caching it. wrapping tree in lambda , using key cache. , break down miserably if runtime decides create new delegate every time hits same lambda expression. // keyvaluepair<string, t> getpair<t>(func<expression<func<t>>> val)... var item = new item { num = 42 }; var pair = getpair(() => () => item.num); // guaranteed same instance? // pair.key = "num" // pair.value = 42 edit: ok, here full thing. seems works , doesn't seem generate garbage in process. another edit: ok, changed it, doesn't seem capture anything, , works faster! using system; using system.diagnostics; using system.linq.expressions; using system.runtime.compilerservices; class program { static void main(string[] args) { var pair = new pair<int>(); ...

c - sscanf() double showing zeros -

i'm having troubles sscanf() function read doubles. have comma separated text file this: abc,def,0.465798,0.754314 ghi,jkl,0.784613,0.135264 mno,opq,0.489614,0.745812 etc. so first line fgets() , use sscanf() 2 string , 2 double variables. fgets(buffer, 28, file); sscanf(buffer, "%4[^,],%4[^,],%lf[^,],%lf[^\n]", string1, string2, &double1, &double2); printf("%s %s %f %f\n", string1, string2, double1, double2); but output is: abc def 0.465798 0.000000 ghi jkl 0.784613 0.000000 mno opq 0.489614 0.000000 so somehow doesn't scan last float. i've tried %lf[^ \t\n\r\v\f,] , %lf still doesn't work. change "%4[^,],%4[^,],%lf[^,],%lf[^\n]" to int result; result = sscanf(buffer, "%4[^,],%4[^,],%lf,%lf", string1, string2, &double1, &double2); if (result != 4) // handle error notice & on double1 , double2 - likley typo. also strongly recommend check result 4. not checking sscanf(...

wordpress - Get images used in, but not attached to page? -

i want of images used in page. code i'm using: function get_page_images($id) { $photos = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'asc', 'orderby' => 'menu_order id') ); $results = array(); if ($photos) { foreach ($photos $photo) { // correct image html selected size $results[] = wp_get_attachment_image($photo->id, $size); } } return $results; } this gets images uploaded page, if have reused image uploaded different page/post, aren't retrieved (as attached post uploaded to, not posts reused in). know way all images used in page/post? use built-in php dom parser grab images located in content. code untested, should started in right direction: ...

php - Select element from other table on the form zf2 -

i have 2 table manytoone relation on database between client , sale , want select id_client on sale form . o used . saleform : public function __construct(clienttable $table) { parent::__construct('vente'); $this->setattribute('method', 'post'); $this->clienttable = $table; $this->add(array( 'name' => 'id', 'attributes' => array( 'type' => 'hidden', ), )); $this->add( array( 'name' => 'id_client', 'type' => 'select', 'attributes' => array( 'id' => 'id_client' ), 'options' => array( 'label' => 'catégory', ...

camera - code work on android 4.1 but don't on 4.2 (possible?) -

i'm writing application record video front camera. possible app can't work on android 4.2? i've tried tablet 4.1.1, customer says not work in tablet. this code related recording: //create surface view public void surfacecreated(surfaceholder holder) { mcamera= camera.open(1); setcameradisplayorientation( this, 1, mcamera); viewgroup.layoutparams params = msurfaceview.getlayoutparams(); parameters parameters = mcamera.getparameters(); list<size> sizes = parameters.getsupportedpreviewsizes(); params.width = (sizes.get(0).width / 4); params.height = (sizes.get(0).height / 4); msurfaceview.setlayoutparams(params); } i things error in code edit i have insert lot of log... app freezing when stopping recorder. call on trycatch.. try{ appendlog(...

node.js - REFERENCE KEY in node-orm2 -

i working on rest api based on node.js , chose postgresql database store data. suppose database has 2 tables names user , comment . comment belongs 1 user , when decide remove user , comment 's of him/her must removed. so, designed table follows: create table user( user_id serial, username varchar(32) not null, password varchar(32) not null, constraint pk_user primary key (user_id), constraint uq_user unique (username) ) create table comment( comment_id serial, user_id integer not null, content text not null, constraint pk_cmnt primary key (comment_id), constraint fk_cmnt foreign key (user_id) references user(user_id) on update cascade on delete cascade ) but don't run code , use node-orm2 instead. designed 2 simple models handle simple code: var user = db.define('user', { username: { type: 'text', size: 32, // varchar(32) required: true, // not null unique: true...

command line - Python: find current directory of remote "cmd.exe" processes -

i write script among other things erases directory using shutil.rmtree i have ensure no "cmd.exe" opened in directory (and blocking me erasing directory). i can killing "cmd.exe" on remote computer: process_name = "cmd.exe" computer_name = "atacama6" try: subprocess.check_call('taskkill.exe /s {} /u admin1 /p abc$ /im {}'\ .format(computer_name, process_name)) except subprocess.calledprocesserror: # no matches found - thats ok! pass but afraid of killing "cmd.exe" processes opened in other directories , need run. how can kill ones opened in specific directory?

Semantic Web-rdf-Workers' projects and used computers in a company according to years -

i want sesame rdf database workers in company. workers involved in projects in date range. have computers. after database, must able search database according computers used people or people worked in projects in past or now. so, cant decide how order attributes of worker, company, project, computer because dont know place attribute year . example, workers' past companies or past projects... how can place year in rdf file below? didnt place year in file in proper way, think. because start , end dates should defined in way or date range? after how search sparql find people working in special project or before now? or people using same computer in different years? <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:worker="http://www.semantic.fake/worker#" xmlns:company="http://www.semantic.fake/company" xmlns:project="http://www.semantic.fake/project"> <rdf:description rdf:about="http://www.semantic...

tomcat - Continuous Delivery with Grails -

background: my team has been using jenkins run our continuous integration (ci) our grails applications. trying move closer continuous delivery setting deployment pipeline , having push button deployments multiple environments (dev, itg, prod). have tried use jenkins tomcat plugin deploy our code have run occasional permgen issues on tomcat , have manually restart after deployment. questions: is jenkins right tool use automated deployments grails? how can automate deployment tomcat without having manually restart afterwords? i don't think can if jenkins "right" tool, one. when hot-deploy tomcat, permgen inevitably grow. restart easiest way handle this. see other questions what makes hot deployment "hard problem"? more information. can use post build task run shell script on jenkins server deploys war , restart tomcat.

css3 - Pure CSS scrolling UL LI table with fixed header -

i'm trying implement pure css scrolling ul-li table fixed header. my requirements: using table css (table, table-row, table-cell, table-header-group...) all cells have list items (li) header has fixed when table content scrolling when table column changes width, appropriate header width should changed currently have html: <ul class="testtable"> <div class="testheader"> <li class="testrow"> <span>id</span> <span>name</span> <span>description</span> <span>other details 1</span> <span>other details 2</span> </li> </div> <div class="testbody"> <li class="testrow"> <span>1</span> <span>2</span> <span>3</span> <span>4</span> ...

python - Data import from excel breaking up the values -

taking data excel spreadsheet fourth column fourth_column = [32.86667, 34.08333, 39.0, 36.63333, -13.2, 30.8, 14.3] these values latitude , similar values longitude. wondered if there easy way running them each separately through code 1 after other, setting latitude equal take each value in turn. for value in fourth_column: do_something(value)

c++ - Unpacking msgpack to an arbitrary object, without msgpack_define -

i'm working on body of code deals custom string implementation rather std::string (long story various reasons has used) refer "string" here on. i able pack string without issue using "raw" type pack raw char bytes , size i'm having problems unpacking it. i able manually unpack shown below. // before i've unpacked point following object has string msgpack::object_kv& kv = obj.via.map.ptr[0]; // kv.key == string want string key = string(key.via.raw.ptr, key.via.raw.size); // works but want use built in >> operator or .as template function , haven't been able manage it. don't have access modify string class add msgpack_unpack function nor add msgpack_define i tried creating struct , giving msgpack_unpack function, apparently calls msgpack::object::implicit_type compiler replies error: 'struct msgpack::object::implicit_type' private and can't figure out way of getting msgpack::object out of "implicit_type...

php - cURL returns same results with different query -

curl returns same results different query ajax. if copy query in url field of browser, works , returns correct results. test.php <?php header("content-type: text/html; charset=iso-8859-1"); curl_setopt($c, curlopt_fresh_connect, 1); // don't use cached version of url $query = $_get['query']; $source = $_get['source']; $startdate = $_get['startdate']; $enddate = $_get['enddate']; if($query != ""){ $query = '%20and%20' . $query ;} $req = '...:['. $startdate .'t00:00:00z%20to%20'. $enddate .'t00:00:00z]%20and%20origin:'. $source . $query; $curl1 = curl_init($req); curl_setopt($curl1,curlopt_fresh_connect, true); curl_setopt($curl1,curlopt_returntransfer, true); $result = curl_exec($curl1); echo $result; script.js $.ajax({ url : 'test.php', type: 'get', datatype: 'json', ...

c# - Method must have a return type on an InitializeComponent() method -

i have partial public class namespace bugnetwpf { public partial class reportscreen_idrangereport : page { public generatereport(mainwindow mainwindow) { initializecomponent(); } } } the error saying method must have return type, ideas how fix this? what else saying return type true, i'm guessing want: namespace bugnetwpf { public partial class reportscreen_idrangereport : page { public reportscreen_idrangereport(mainwindow mainwindow) { initializecomponent(); } } } the constructor needs have same name class.

Error creating folder in google drive through ruby -

i'm having trouble creating folder in google drive using google-drive-api library in ruby. can log in, list folders, add file root folder. have folder called 'applications' under root folder. listing files show id folder, lets call "0bwivxebt'. in controller init google drive connection (as i'm able list files) , call create_parent('test') method in google_drive_connection.rb: def create_folder (title) file = @drive.files.insert.request_schema.new({ 'title' => title, 'description' => title, 'mimetype' => 'application/vnd.google-apps.folder' }) file.parents = [{"id" => '0bwivxebt'}] # 0bwivxebt id applications folder media = google::apiclient::uploadio.new(title, 'application/vnd.google-apps.folder') result = @client.execute( :api_method => @drive.files.insert, :body_object => file, :media => media, :parameters => { ...

php - Jquery form post errors -

i new in jquery. i'm working on form. title , text (textarea) when fill out fields , click send, 2 alerts appear when click ok 2 times scroll page up. fill in fields , starts again beginning. how can ensure after 2 checks continues page? jquery: $("#formpages").submit( function(event) { var title = $('#title').val(); var text = $('#text').val(); if(title == ''){ $("#titleerror").html("<p>fill title</p>"); alert('title empty'); } if(text == ''){ $("#texterror").html("<p>fill text</p>"); alert('text empty'); } $("html, body").animate({ scrolltop: 0 }, 600); event.preventdefault(); }); form: <form class="form" id="formpages"> <div> <label class="title"...

html - Separate CSS for label checkbox to label input -

i have used label both input textboxes: <label for="username">username</label> <input id="username" type="text" value=""> and checkboxes/radioboxes <label for="live">system live</label> <input id="live" name="live" type="checkbox" value="false"> the trouble have how specify different css labels different input types. if generic label css: label { color: #00a8c3; line-height: 20px; padding: 2px; display: block; float: left; width: 160px; } i find either end unaligned checkboxes or badly positioned textboxes. you add classes labels. example: <label for="username" class="textbox-label">username</label> <input id="username" type="text" value=""> <label for="live" class="checkbox-label">system live</label> <inpu...

app store - iTunes Connect Autoingestion.class doing nothing -

This summary is not available. Please click here to view the post.

css - DIVs Failing to Align Properly -

i trying align 2 divs side side. image on left, text on right first item. text on left, image on right second item. , image on left, text on right third item. it works first , third items. second item fails align. have done wrong? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <style type="text/css"> .container { padding: 5px; background-color:#66c; } .imagecontainer { margin: 0 25px 0 0; float: left; height: 301px; width: 301px; background-color:#0cc; position:absolute; margin-bottom: 50px; } .imagecontainerrt { margin: 0 0 0 0px ; float: left; height: 301px; width: 301px; background-color:#0cc; ...

python - Scrapyd init error when running scrapy spider -

i'm trying deploy crawler 4 spiders. 1 of spiders uses xmlfeedspider , runs fine shell , scrapyd, others use basespider , give error when run in scrapyd, run fine shell typeerror: init () got unexpected keyword argument '_job' from i've read points problem init function in spiders, cannot seem solve problem. don't need init function , if remove still error! my spider looks this from scrapy import log scrapy.spider import basespider scrapy.selector import xmlxpathselector betfeeds_master.items import odds # parameters myglobal = 39 class homespider(basespider): name = "home" #con = none allowed_domains = ["www.myhome.com"] start_urls = [ "http://www.myhome.com/oddxml.aspx?lang=en&subscriber=mysubscriber", ] def parse(self, response): items = [] tracecompetition = "" xxs = xmlxpathselector(response) oddsobjects = xxs.select("//oo[odd...