Friday, 15 March 2013

develop custom extension in magento, which processes image of product and tags with prominent color codes -



develop custom extension in magento, which processes image of product and tags with prominent color codes -

i have been struggling in figuring out how can tag product color , when user selects color color picker, user should products tagged particular color or near hex codes.

a simple solution create 2 product attribute main_color , related_colors, main_color should single selection input type , should searchable while related_color should multi-selectbut not searchable. can assign 1 main color product , multiple related color shades. on frontend have custom code, related_color attribute value,extract related color codes , fetch products having main_color value.

hope makes sense.

magento

html - Mystery spacing on svg web graphic -



html - Mystery spacing on svg web graphic -

this code: http://jsfiddle.net/c8d34/17/

this code svg:

<svg viewbox="0 0 100 100"> /* here */ <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" /> </svg>

i've tried few different things, seems although in theory circle should nail top , bottom of bluish box, instead leaves space. i've tried this:

* { padding:0px; margin:0px; }

all no avail. can please tell me why circle doesn't fill area completely.

basic geometry.

your numbers must such (r * 2) + strokewidth = height

in case, if want maintain stroke-width="4", want r = (height - strokewidth) / 2 = 96 / 2 = 48

so:

<circle cx="50" cy="50" r="48" stroke="green" stroke-width="4" fill="yellow" />

html css svg

tfs - Visual Studio restoring solution to previous point -



tfs - Visual Studio restoring solution to previous point -

i have vs2012 solution have been developing quite time now. regularly (at to the lowest degree 1 time week) check-in of changes tfs. solution made of 6 or 7 projects.

right having bit of problem. need entire solution as-it-was in previous point in time. know changeset need get, don't know how accomplish that. tried doing rollback had heart attack because lost several projects. seems doing gets files commited on changeset.

i tried going through browser , download project on changeset want when opened solution projects missing it's same doing rollback. sure not how solution when did check-in.

i must doing wrong.

i'm sorry if i'm not clear enough, i'll glad provide more info if necessary.

thanks in advance.

first, check-ins much more 1 time week. little commits encompass single new feature or change. it's practice commit several times day.

that said, feature you're looking "get specific version". can right-click on folder, mouse on "advanced", , it's right there.

you can specify changeset, , it'll pull downwards version of source code point in time.

if have work in progress, you'll want create shelveset containing work in progress prior getting specific version -- overwrite haven't checked in yet.

visual-studio-2012 tfs

ruby - PG Error could not connect to server: Connection refused Is the server running on port 5432? -



ruby - PG Error could not connect to server: Connection refused Is the server running on port 5432? -

i updated machine (macbook pro running mount lion) , ever since then, whenever set rails project, machine craps out , cannot connect pg. currently, error getting when seek go localhost;

pg::error not connect server: connection refused server running on host "localhost" (::1) , accepting tcp/ip connections on port 5432? not connect server: connection refused server running on host "localhost" (127.0.0.1) , accepting tcp/ip connections on port 5432? not connect server: connection refused server running on host "localhost" (fe80::1) , accepting tcp/ip connections on port 5432?

here checklist, , list of things have tried;

postgresql version 9.3.4 i have installed through homebrew i have host: localhost in database.yml file rails version 4.1.1, ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0] ran brew uninstall postgresql brew install postgresql tried access postgres.conf file wasn't allowed through pgadmin , command line

ran locate pg_hba.conf , terminal shot out;

warning: locate database (/var/db/locate.database) not exist.

i have tried using rails 4.0 still problem

i can still work on other projects on machine started/finished before updated computer.

when run psql terminal psql: not connect server: no such file or directory server running locally , accepting connections on unix domain socket "/tmp/.s.pgsql.5432"?

i lost here, , not sure else do. help much appreciated.

update:

thanks this question, resolved downloading postgres.app mac. works great now.

this quite easy think because if update mac process running postmaster.pid file missing /usr/local/var/postgres/ here. need start process postgres create postmaster.pid.

if progress running -

stop manually:

pg_ctl -d /usr/local/var/postgres stop -s -m fast

start manually:

pg_ctl -d /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

now working...

ruby osx postgresql ruby-on-rails-4

android - update a fragment on ViewPager based on the fragment before -



android - update a fragment on ViewPager based on the fragment before -

i using viewpager fragments , fragmentstatepageradapter, need update sec fragment based on user checked in first one, happens both fragments loaded when fragment activity started, doesn't matter user checks on first fragment, sec not updated. i've tried override de getitemposition notifydatasetchanged phone call method update fragment, appears called when it's created, need update sec fragment when user check options want in first fragment. thanks

public class screenslidepageradapter extends fragmentstatepageradapter { public screenslidepageradapter(fragmentmanager fm, list<fragment> fragments) { super(fm); } @override public fragment getitem(int position) { if(mfragments.get(position) instanceof updateablefragment){ notifydatasetchanged(); } homecoming mfragments.get(position); } @override public int getcount() { homecoming mfragments.size(); } @override public int getitemposition(object object) { if (object instanceof updateablefragment) { ((updateablefragment) object).customize(); } homecoming super.getitemposition(object); } }

android android-fragments android-viewpager

Basic Ruby - Need simple explanation of what an if/else statement is doing -



Basic Ruby - Need simple explanation of what an if/else statement is doing -

for basic auto class exercise, asked create drive method should take input number of miles driven, alter position accordingly , cut down fuel @ rate of 20 miles per gallon.

i understand basic concept of need , how if/else statement works, need help breaking downwards if/else statement more 'layman terms' happening content.

def initialize @fuel = 10 @distance = 0 end def drive(miles) if (@fuel - miles/20.0) >= 0 @distance += miles @fuel -= miles/20.0 else @distance += @fuel * 20.0 @fuel = 0 puts "you're out of gas!" end

you set fuel value of 10 , distance 0.

when drive x amount of miles (hence why miles input), have see if you're out of gas.

if amount of fuel minus number of miles traveled, divided 20, greater or equal 0, set distance traveled distance + amount of miles traveled (+= shorthand @distance = @distance + miles). think if may need clarification though: "fuel - miles, divided twenty"? or "fuel - miles/20", order of operations comes play?

anywho, shorthand +=:

@distance = @distance + miles

then set fuel amount of fuel minus amount of miles traveled, divided 20 (-= shorthand, similar before.)

@fuel = @fuel - miles/20.0

however, otherwise (the else), set distance

@distance = @distance + fuel *20

then set fuel 0, , print out string "you're out of gas!".

ruby

Supported (and recommended) scaling methods with Azure SQL Database "Premium" (replacement for web & business) -



Supported (and recommended) scaling methods with Azure SQL Database "Premium" (replacement for web & business) -

microsoft azure provides auto-scale feature of services, including web sites. feature enables set target cpu value, , azure automatically spin or downwards additional "instances" of web site in effort meet target cpu utilization. allows meet demand spikes.

most websites backed datastore of kind, whether it's mongodb, oracle database, oracle mysql, or azure's sql database. thus, went @ scaling features of azure sql database. best can tell, there no "auto-scale" feature. instead, take tier , that's you're going get.

i've done bit of searching , while i've found recommendations one1, , talk sharding , partitioning, nil i'm finding discusses way "auto-scale" azure sql database in response load. manual scaling method supported?

azure sql-azure

networking - Can I lose datagrams in the socket receive buffer and how can it happen when I use UDP? -



networking - Can I lose datagrams in the socket receive buffer and how can it happen when I use UDP? -

i want utilize udp sockets under reliable transport in c-programm, , want know more packet can lost also.

as known udp not reliable protocol. mean that:

if info packet lost in low-level protocol, not sent again data packet can lost in receive buffer, illustration if receive buffer overflowing

i'm interested in sec case - how work? in receive buffer datagrams recorded along size of datagrams, because udp guarantees preservation of message boundaries. , when receive buffer overflowing, first datagram remove:

read first 8 bytes head of ring buffer (receive buffer), contain datagram size move head of ring buffer amount equal size of message - i.e. move head next datagram if free space in ring buffer plenty new received datagram, write ring buffer , move tail end of it, else goto 1 step

i.e. mean when phone call read socket, happens scheme call, access such ring buffer in kernel space, reads first 8 bytes datagram size, , reads datagram size, isn't it?

is right?

os: linux x86_64 (redhat 6)

and when receive buffer overflowing, [the] first datagram [is] remove[d]

no. when datagram arrives , receive buffer full, new datagram dropped. processing of buffer doesn't occur @ all.

sockets networking udp ethernet tcp-ip

python - Is "syscall-template.S: No such file or directory" a bug of GDB or My Program -



python - Is "syscall-template.S: No such file or directory" a bug of GDB or My Program -

i used gdb debug combined programme of python , c. gdb gives me error when segmentation fault of programme occurs.

81 ../sysdeps/unix/syscall-template.s: no such file or directory.

here several lines more of trackback information.

0 0x00007ffff6f2b6d7 in kill () @ ../sysdeps/unix/syscall-template.s:81 1 0x000000000042a241 in posix_kill.64590 (self=<optimized out>, args=<optimized out>) @ ../modules/posixmodule.c:4306 2 0x000000000050e78c in call_function (oparg=<optimized out>, pp_stack=0x7fffffffd7b0) @ ../python/ceval.c:4020 3 pyeval_evalframeex (f=f@entry=frame 0x7ffff5784608, file /usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py, line 121, in python_reloader (main_func=<instancemethod @ remote 0x7ffff69a3a00>, args=(), kwargs={'use_static_handler': true, 'settings': none, 'pythonpath': none, 'verbosity': '1', 'traceback': none, 'use_ipv6': false, 'use_threading': true, 'use_reloader': true, 'insecure_serving': false}, exit_code=-11), throwflag=throwflag@entry=0) @ ../python/ceval.c:2666

is bug of gdb or program? cannot find class of programme in trackback information.

thanks !

if programme passes invalid arguments c library function, can crash in c library. and, if don't have source c library installed, message gdb. however, doesn't mean wrong... normal missing debuginfo and/or source 1 or more libraries used program. ordinarily solution go "up" few stack frames , see real problem is. more may encountering library bug.

python c gdb

javascript - Change global variable using History.js -



javascript - Change global variable using History.js -

i've been trying implement history.js. i've got understanding of how getting , pushing states work, i'm having particular problem info storing component of history along using global variables.

as simple example, decided seek , set script alter colour of html box upon beingness clicked. trigger history - creating history clicking box (and colour beingness changed on each state of history).

is there way update global variable based on info (in case, updating i per click) supplied in history state's data?

html:

<div id="box">click me</div> <button id="back">back</button> <button id="forward">forward</button>

css:

#box { width: 300px; height: 300px; background-color: black; color: white; vertical-align: middle; text-align: center; display: table-cell; }

javascript:

var history = window.history; var = 0; if (history.enabled) { var state = history.getstate(); history.pushstate({count:i}, $("title").text(), state.urlpath); } else { homecoming false; } // bind statechange event history.adapter.bind(window,'statechange', function(){ state = history.getstate(); console.log(state.data, state.title, state.url); $(this).css('background-color', getcolour()); }); // trigger alter $("#div").on("click", function() { i++; history.pushstate({count:i},"state " + i,"?state=" + i); }); function getcolour() { var colours = ["red", "orange", "yellow", "green", "aqua","blue", "purple", "magenta","black"]; if (i > colours.length - 1) { = 0; } if (i < 0) { = colours.length - 1; } homecoming colours[i]; } $("#back").on("click", function() { history.back(); }); $("#forward").on("click", function() { history.forward(); });

i'm using jquery, ajaxify-html5.js , scrollto.js per recommendation other threads.

editable jsfiddle | viewable jsfiddle

after playing around ton (and reading more questions), i've figured out. i'll detail solution means others come across this.

jsfiddle view solution | jsfiddle view solution

first here's final code. note javascript has document.ready extras working outside of jsfiddle.

it's worth noting took out ajaxify-html5.js , scrollto.js out, weren't needed (and breaking code somewhere).

html:

<div id="box"> <div id="count"></div> <div id="colour"></div> </div> <button id="back">back</button> <button id="forward">forward</button>

css:

#box { width: 300px; height: 300px; background-color: white; color: white; vertical-align: middle; text-align: center; display: table-cell; } button { width: 148px; height: 40px; } #count, #colour { background-color: black; font-family: "consolas"; }

javascript:

var history = window.history; var = 0; var colour = getcolour(); var colourname = getcolourname(); $(document).ready(function() { if (history.enabled) { changehistory(); } else { homecoming false; } // bind statechange event history.adapter.bind(window,'statechange', function(){ state = history.getstate(); = state.data.count; colour = state.data.colour; colourname = state.data.colourname; changehistory(); }); // trigger alter $(document).on("click", "#box", function() { = + 1; colour = getcolour(); colourname = getcolourname(); changehistory(); }); $(document).on("click", "#back", function() { history.back(); }); $(document).on("click", "#forward", function() { history.forward(); }); }); function getcolour() { var colours = ["rgb(220,45,45)", "orange", "rgb(230,230,50)", "rgb(15,210,80)", "rgb(100,220,220)","rgb(50,80,210)", "rgb(140,20,180)", "rgb(230,70,110)","grey"]; if (i > colours.length - 1) { = 0; } if (i < 0) { = colours.length - 1; } homecoming colours[i]; } function getcolourname() { var colournames = ["red","orange","yellow","green","light blue","blue","purle","pink","grey"]; homecoming colournames[i]; } // create changes function changehistory () { $("#colour").html(colourname); $("#count").html(i); $("#box").css('background-color', colour); history.pushstate({count:i, colour: colour, colourname: colourname},"a shade of " + colourname,"?colour=" + colourname); }

so going wanted accomplish question:

clicking box add together history each history hold variables required impact global variables

its worth noting solution specifically uses variables each iteration of history powerfulness global variables, whereas programme uses global variables. variables used powerfulness interface never access ones stored in history.

let's break programme separate , simpler processes , functions. much other history.js solutions, there's things require working:

history.getstate(): gets latest history item "from stack" history.adapter.bind(window,'statechange', function() {}: event listener trigger function when window has statechange (history alter in case) history.pushstate({data}, title, url): pushes state "history stack". holds object (data), title (of tab/window) , url display. setting history:

when user clicks on box, programme should:

increment counter (i) change colour , colourname add new history stack object in

i decided separate first 2 features lastly one. function changehistory() responsible updating contents of box (from global variables) , pushing new history object in (using global variables).

changehistory() gets called whenever want add together new item of history in , update contents in box reflect new history - @ launch @ when box clicked.

when box clicked, first 2 criteria met. using existing global variables , functions, new colour , name retrieved , set global variables.

this how should behave:

box click -> increment i, alter variables -> force history

listen history change:

once history alter has been made (either clicking box, pressing back/forward buttons or browser buttons), alter needs occur.

by creating variable state = history.getstate(), have easy way of accessing info latest history stack object.

we'll utilize info history object.data assign global variables. after updating variables, we'll update view using changehistory().

this how model should work:

history changed -> update globals history -> update view

history alter occur whenever presses back, forwards or box, accounting possible changes.

javascript jquery history.js

apache - How to make a .htaccess redirect with header and folders -



apache - How to make a .htaccess redirect with header and folders -

how .htaccess code redirects

http://www.example.com/folder http://example.com/folder?

insert rule below rewritebase /:

rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule ^ http://%1%{request_uri} [r=301,l,ne]

apache .htaccess mod-rewrite

php - 100% cpu usage with wordpress theme customizer suPHP -



php - 100% cpu usage with wordpress theme customizer suPHP -

i running single core 512mb do(digital ocean) droplet , cent os 6 have configured php utilize mod_suphp security reasons. running multiple sites off box @ point, want isolate them eachother. suphp setup went perfectly, able install wordpress , set databases, ftp etc. issue having actions spike php-cgi process 100% , timeout. wordpress customizer hangs on save while accessing admin-ajax.php file. 1 of themes using (the x theme) when trying upload json file ended hanging , timing out on line 30 of wp-includes/compat.php on cpanel servers, used suphp without issue, , same actions , themes work fine. difference notice php process on cpanel machines "php" whereas mine "php-cgi". have no thought if part of issue, help @ identifying why , how wordpress scripts overloading cpu helpful. of import note site not under traffic when happens, in development. there on 50% of ram used while cpu spiking not running out of memory

suphp processes file every single time called, due this, causes lot of cpu usage. suphp in general uses lot of cpu, adding wordpress mix makes cpu usage more. recommend using fastcgi php handler uses low amount of cpu high amount of memory. in add-on able utilize opcode caching such apc or memcached, causing wordpress faster. in regards security concern, fastcgi has same security suphp , can upload things no problem. 1 little thing note though going need tweak settings quite bit before right, there errors @ first possibly, answers of can courtesy of google. also, not sure how operates if need prepare permissions , have cpanel, here nice article: http://boomshadow.net/tech/fixes/fixperms-script/

php wordpress centos digital-ocean suphp

Custom jQuery sorting on HTML navigation. How to order elements based on title? -



Custom jQuery sorting on HTML navigation. How to order elements based on title? -

i have custom navigation built apply specific sort order based on title. how go sorting menu instead of:

site 1, site 2, site 3, site 4

we site 3, site 2, site 4, site 1

<div class='navgroup' > <ul class='navsites'> <li> <a>site 1</a><span class='exspand'>[+]</span> <ul class='navsecondlevelsite'> <li><a href='/home.aspx' >home</a></li> <li><a href='/feedback.aspx' >feedback</a></li> <li><a href='/officesmaps.aspx' >offices maps & meeting rooms</a></li> <li><a href='/systemalerts.aspx' >system alerts</a></li> </ul> </a> </li> <li> <a>site 2</a><span class='exspand'>[+]</span> <ul class='navsecondlevelsite'> <li><a href='/page1.aspx' >page1</a></li> <li><a href='/page2.aspx' >page2</a></li> <li><a href='/page3.aspx' >page3</a></li> </ul> </a> </li> <li> <a>site 3</a><span class='exspand'>[+]</span> <ul class='navsecondlevelsite'> <li><a href='/page1.aspx' >page1</a></li> <li><a href='/page2.aspx' >page2</a></li> <li><a href='/page3.aspx' >page3</a></li> </ul> </a> </li> <li> <a>site 4</a><span class='exspand'>[+]</span> <ul class='navsecondlevelsite'> <li><a href='/page1.aspx' >page1</a></li> <li><a href='/page2.aspx' >page2</a></li> <li><a href='/page3.aspx' >page3</a></li> </ul> </a> </li> </ul> </div>

fiddle:

http://jsfiddle.net/colbs/uydll/

here's 1 approach requires array based on text. removes elements , appends them in order defined array

var navorder=['site 3','site 2','site 4','site 1']; var $nav=$('.navsites'); /* detach list items */ var $items=$nav.children().detach(); /* loop on navorder array */ $.each(navorder, function(_, txt){ $items.filter(function(){ homecoming $(this).children('a').text() == txt; }).appendto($nav);/* append list item matches array element value*/ });

demo

jquery sorting navigation

ember.js - Is there a difference Ember getJSON if I am using Swagger JS? -



ember.js - Is there a difference Ember getJSON if I am using Swagger JS? -

to pull json model api, this:

return ember.$.getjson('http://....');

however there difference in syntax if using swagger?

i got introduced other day @ work. back-end developers starting utilize it... new of don't know how utilize on front-end?

i'm not familiar swagger @ all, can utilize promise , hook results way.

assuming swagger connection

swagger = new swaggerapi({ url: "http://petstore.swagger.wordnik.com/api/api-docs", success: function() { if(swagger.ready === true) { // upon connect, fetch pet , set contents element "mydata" } } }); model: function(){ homecoming ember.rsvp.promise(function(resolve, reject){ swagger.apis.pet.getpetbyid({petid:1}, function(data) { resolve(data.content.data); }); }); });

ember.js swagger

Yeoman sub generator: using answers to prompts from main generator -



Yeoman sub generator: using answers to prompts from main generator -

i have written yeoman sub generator , want access answers acquired prompts in main (parent) generator. format access answers in main generator's index.js file this.promptname. possible retrieve answers within sub generator?

this have (obviously) doesn't work:

var componentgenerator = yeoman.generators.namedbase.extend({ init: function () { if (this.wordpress) { // this.wordpress set main generator console.log('is wp'); } else { console.log('not wp'); } } }); module.exports = componentgenerator;

you need pass them options sub generator:

this.composewith('subgenerator', {options: {name: 'some-name'}});

then in sub generator:

this.option('name', {/* settings */});

see total documentation here:

composewith: http://yeoman.io/authoring/composability.html options/arguments: http://yeoman.io/authoring/user-interactions.html

yeoman yeoman-generator

php - Send Links with POST Data via E-Mail -



php - Send Links with POST Data via E-Mail -

i want know how send link in e-mail contains $_post data. it's e-mail reset function in php. don't want send e-mail link like

http://example.reset.com/reset.php?token=5e51b695b8260632e55cad464039c2b4d7ec2cbca0331b881fabc4ada71cffac3808aa105ec5e9a9b693768774ddb6c3160359f9195c2e442c7c7a82ed849033

so possible realize this?

i check if token in database , if $exp_date_time info not old. user has 30 minutes alter password, after getting mail. if 1 of these steps doesn't work person tried connect reset.php redirected index.php.

now don't want have bot accidentally positive response this.

for info token length 128 , generated generated random password modified sha512 hash.

how can create more secure?

cheers

sven

additional information:

my database:

create table if not exists `email` ( `kasuser` varchar(12) not null default '', `be_mail` varchar(100) not null default '', `ba_mail` varchar(100) not null default '', `exp_date` varchar(19) not null default '2000-01-01 01:01:01', `token` varchar(200) not null default '', primary key (`kasuser`), unique key `be_mail` (`be_mail`), unique key `ba_mail` (`ba_mail`) )

to link 1 above, need fill in form, checks, if backup_mail (ba_mail) in database , bound be_mail, have send form. date generated +30min , token generated password generator hashes password , saves end product database. e-mail send ba_mail link above.

i wonder if it's possible generate "link" hidden form, sends token php $_post requires it. doubt, work in e-mail clients , there people see plain text. have @ to the lowest degree send them token or?

you generate token , store email in db, pass both of in email link.

reset.php?token=5e51b_etc&email=test%40example.com

$email = urldecode($_get['email']); $token = $_get['token'];

you craft query check token , email match in db.

edit: check time of access less $exp_date_time.

edit 2: noticed 'i don't want send e-mail link like'. can avoid link looks in email `password reset. utilize info process request , redirect either valid attempt/change password, or parameters wrong or request old. wouldn't worry url in scenario. it's not going visitor going homecoming unless sent email reset.

php email post hyperlink

how to send javascript values in html table -



how to send javascript values in html table -

i got values throw sdocstr. , need send sdocstr values html table.. can help me.

function myfunction() { document.write(sdocstr); mytable += "<html><table>"; mytable += "<tr><td style='font-family:trebuchet ms;font-size:12px;font-weight:bold;font-style:italic;'>sdocstr</td></tr>"; mytable += "</table></html>"; }

you can :

function myfunction() { document.write(sdocstr); mytable += "<html><table>"; mytable += "<tr><td style='font-family:trebuchet ms;font-size:12px;font-weight:bold;font-style:italic;'>" + sdocstr + "</td></tr>"; mytable += "</table></html>"; }

is ok ?

javascript html

c - GCC flags during linking -



c - GCC flags during linking -

is there situation in flags such -ansi, -wall, , -pedantic might relevant during linking part of process?

what -o optimization flags? relevant during compile steps or relevant during linking?

thanks!

in practice, no - in theory, -ansi dialect option, conceivably impact linking. i've seen similar behaviour older versions of clang utilize libc++ or libstdc++, when using c++11 or c++03 respectively. find easier set these flags in cc variable: cc = gcc -std=c99 or cc = gcc -std=c90 (ansi).

i invoke c++ (or c) $cxx or $cc out of habit. , passed default configure scripts.

i'm not aware of beingness issue c, long abi , calling conventions haven't changed. c++, on other hand, requires changes c++ runtime back upwards new language features. in either case, it's compiler invokes linker relevant libraries.

c gcc compilation linker

ios - UIButton setImage in UITableViewCell crashes app -



ios - UIButton setImage in UITableViewCell crashes app -

as of right now, table loads 3 cells. 2 of cells' labels include string "test". when search "test" first time, expected cells load , right images, label texts , button backgrounds displayed. nil overlaps. far there.

however, app crashes when cancel search , go , search "test" 1 time again (as come in lastly character "t").

i error:

-[uiimageview setimage:forstate:]: unrecognized selector sent instance 0x9128140 2014-06-19 14:12:19.982 appname[5171:60b] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uiimageview setimage:forstate:]: unrecognized selector sent instance 0x9128140'

i made sure instance uibutton , not uiimageview in cell. read on other answers add together 100 button tags, nil changed. way, button tags right when search. (i checked alert every button click)

below code cells.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { // register cell identifier custom cell nib static nsstring *cellidentifier = @"friendcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; // avatar settings uiimageview *imvavatar = [[uiimageview alloc] initwithframe:cgrectmake(3, 3, 45, 45)]; [imvavatar setimage:[uiimage imagenamed:@"btnavatar2.png"]]; imvavatar.layer.cornerradius = imvavatar.frame.size.height/2; imvavatar.layer.maskstobounds = yes; // befriend button settings uibutton *btnbefriend = [[uibutton alloc] initwithframe:cgrectmake(281, 14, 36, 22)]; [btnbefriend addtarget:self action:@selector(btnbefriendpressed:event:) forcontrolevents:uicontroleventtouchupinside]; if (tableview == self.searchdisplaycontroller.searchresultstableview) { friend = [searchresults objectatindex:indexpath.section]; } else { friend = [arrfriends objectatindex:indexpath.section]; } // collect friend info nsstring *user_id = (nsstring *)[friend objectatindex:0]; // user id nsstring *username = (nsstring *)[friend objectatindex:1]; // username nsstring *fname = (nsstring *)[friend objectatindex:2]; // first name nsstring *lname = (nsstring *)[friend objectatindex:3]; // lastly name nsstring *full_name = (nsstring *)[friend objectatindex:4]; // total name uiimage *picture = (uiimage *)[friend objectatindex:5]; // image (img) nsstring *type = (nsstring *)[friend objectatindex:6]; // type nsstring *arrindex = (nsstring *)[friend objectatindex:7]; // arrfriends index // configure cell if (!cell) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; // set width depending on device orientation cell.frame = cgrectmake(cell.frame.origin.x, cell.frame.origin.y, tableview.frame.size.width, cell.frame.size.height); // name settings uilabel *lblname = [[uilabel alloc] initwithframe:(cgrectmake(60, 3, 215, 45))]; [lblname setfont:[uifont systemfontofsize:14]]; // update name, status, picture, befriend button lblname.text = full_name; // total name imvavatar.image = picture; // image (img) if ([type isequaltostring:@""]) { [btnbefriend setimage:[uiimage imagenamed:@"btnbefriend.png"] forstate:uicontrolstatenormal]; } else { [btnbefriend setimage:[uiimage imagenamed:@"btnbefriended.png"] forstate:uicontrolstatenormal]; } // cell subviews imvavatar.tag = 1; lblname.tag = 2; btnbefriend.tag = [arrindex intvalue]; [cell.contentview addsubview:imvavatar]; [cell.contentview addsubview:lblname]; [cell.contentview addsubview:btnbefriend]; cell.clipstobounds = yes; } else { // create sure images, buttons , texts don't overlap // avatar uiimageview *imvavatar = (uiimageview *)[cell viewwithtag:1]; imvavatar.image = picture; // name uilabel *lblname = (uilabel *)[cell.contentview viewwithtag:2]; lblname.text = full_name; // befriendbutton uibutton *btnbefriend = (uibutton *)[cell.contentview viewwithtag:[arrindex intvalue]]; if ([type isequaltostring:@""]) { [btnbefriend setimage:[uiimage imagenamed:@"btnbefriend.png"] forstate:uicontrolstatenormal]; } else { [btnbefriend setimage:[uiimage imagenamed:@"btnbefriended.png"] forstate:uicontrolstatenormal]; } } homecoming cell; }

help much appreciated. in advance!

i believe problem on line:

uibutton *btnbefriend = (uibutton *)[cell.contentview viewwithtag:[arrindex intvalue]];

you're expecting uibutton actual view beingness returned uiimageview. it's possible [arrindex intvalue] has same tag image view that's subview of cell's content view.

ios objective-c uitableview uibutton

XPath how to get Python -



XPath how to get Python -

i'm trying xpath text in illustration below "7061 main st"

<td rowspan="2"> <font face="arial,helvetica" size="-1"> 7061 main st </font> </td>

however it's not working me. tried next below , won't work. on search in source that's 1 has attribute rowspan="2"

searchresults = tree.xpath('//*[@rowspan="2"]/@text') self.response.out.write(searchresults) searchresults = tree.xpath('//*[@rowspan="2"]/font/@text') self.response.out.write(searchresults) searchresults = tree.xpath('//*[@rowspan="2"]/font[text()]') self.response.out.write(searchresults)

what shoudl text?

thanks!

searchresults = tree.xpath('//td[@rowspan="2"]/font/text()')

will create searchresults equal list

['\n\n\n 7061 main st\n\n ']

(note may want utilize str.strip method remove whitespace both ends of string.)

@text refers attribute text. example, rowspan attribute of td, , face attribute of font. here, want actual text, not attribute. utilize text() instead.

also, if omit font xpath, in

//td[@rowspan="2"]/text()

then retrieving text associated td tag. empty in html posted. want text associated font tag, include font in xpath:

//td[@rowspan="2"]/font/text() finally, know brackets [...] indicate "such that" relationship in xpath. example, td[@rowspan="2"] matches td tags such that rowspan attribute equals "2". font[text()] matchs font tags such that contains text(). returns font tag itself. since want text, not tag, utilize font/text() instead of font[text()].

python xpath

android - ProgressBar inside a Fragment in ViewPager does not get updated -



android - ProgressBar inside a Fragment in ViewPager does not get updated -

i have progressbar on fragment_main.xml.

<progressbar android:id="@+id/progress_total" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@android:style/widget.progressbar.horizontal" android:indeterminate="false" /> <textview android:id="@+id/progress_text" android:layout_width="wrap_content" android:layout_height="wrap_content" />

and have code in fragment bound via adapter viewpager.

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { int random = new random().nextint(100); view rootview = inflater.inflate(r.layout.fragment_main, container, false); progressbar progresstotal = (progressbar) rootview.findviewbyid(r.id.progress_total); progresstotal.setprogress(random); textview progresstext = (textview) rootview.findviewbyid(r.id.progress_text); progresstext.settext(integer.tostring(random)); homecoming rootview; }

the progress bar , text loads first time. reset adapter on button click create fragments reload. random progress updated in text, never on progress bar. tried custom drawables, invalidating, setting progress 0 first, setting max values, etc nil seem work.

what missing here?

ps: how reset adapter activity

viewpager.setadapter(new fragmentsadapter(getsupportfragmentmanager()));

found out setting adapter not instantiate new fragments , all. doh!

had removing of fragments manually until started showing correctly.

basically had phone call below method before setting adapter again.

private void reinitializefragments() { fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmenttransaction transaction = fragmentmanager.begintransaction(); list<fragment> fragments = fragmentmanager.getfragments(); (fragment fragment : fragments) { transaction.remove(fragment); } transaction.commit(); }

android android-fragments android-viewpager android-progressbar

r - Encoding in Shiny -



r - Encoding in Shiny -

i'm working rstudio version 0.98.507. short info initial working instruments:

r version 3.1.0 (2014-04-10) platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] lc_collate=german_germany.1252 lc_ctype=german_germany.1252 [3] lc_monetary=german_germany.1252 lc_numeric=c [5] lc_time=german_germany.1252 other attached packages: [1] shinyapps_0.3.53 rjsonio_1.2-0.2 shiny_0.9.1.9013 loaded via namespace (and not attached): [1] bitops_1.0-6 cairo_1.5-5 catools_1.17 digest_0.6.4 [5] htmltools_0.2.4 httpuv_1.3.0 rcpp_0.11.1 rcurl_1.95-4.1 [9] shinysky_0.1.2 tools_3.1.0 xtable_1.7-3

i have problem deploying shiny app on shiny server. problem @ point solved, after appears again. cannot prepare more. problem high german letters in helpers.r. unfortunately, cannot avoid using them. i'm sourcing help scrpits helpers.r server.r shown , taught in shiny tutorial. r-scripts saved under utf-8 format. cannot utilize command

options(encoding="utf-8")

because after executing it, command deployapp("app") doesn't work. set location using

sys.setlocale(category = "lc_all", locale = "german")

it doesn't work. cannot understand, why letters in mainpanel , sidebarlayout readable, helpers.r not. can help me solve paradox?

example

ui.r

library(shiny) shinyui(fluidpage(withmathjax(), titlepanel("währung"), sidebarlayout(position="right", sidebarpanel( h5("bedienfenster"), sliderinput('x', 'x axis', value=50, min=3, max=150, step=1,) ), mainpanel( plotoutput("plot") ) ) ))

server.r

shinyserver(function(input, output){ output$plot <- renderplot({ x <- rnorm(input$x) hist(x, main="", xlab="", ylab="") title(main="schätzgerade", xlab="währung", ylab="dichte") }) })

after deploying next app.

as workaround (which haven't tested), have tried using escaped unicode characters, such "w\u00e4hrung" instead of "währung"? can can find details of how ?quotes, , there list of unicode characters @ http://en.wikipedia.org/wiki/list_of_unicode_characters.

r utf-8 shiny shiny-server

c# - Linq Expression Slow - Optimization needed if possible -



c# - Linq Expression Slow - Optimization needed if possible -

i have list of integers "numberrangelist" containing 31 integers 62 92 in sequential order, extracting sec list of integers "extractedlist" contain 10 integers sum equal "total". problem take 30 seconds compute, there way of speeding up??

var numberrangelist = new list<int>() { 62, 63, ...92 }; var total = 772; var extractedlist= (from n1 in numberrangelist n2 in numberrangelist n3 in numberrangelist n4 in numberrangelist n5 in numberrangelist n6 in numberrangelist n7 in numberrangelist n8 in numberrangelist n9 in numberrangelist n10 in numberrangelist n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 == total select new list<int> { n1, n2, n3, n4, n5, n6, n7, n8, n9, n10 }).take(1).first();

the performance issue not in linq, in problem itself. problem known in cs literature , it's called subset sum http://en.wikipedia.org/wiki/subset_sum_problem . it's known problem belongs np-complete class of time-complexity ( http://en.wikipedia.org/wiki/np-complete ). should research sub-optimal solution if don't want explore (exponential) problem complexity.

c# performance linq time-complexity

php - Mysqli multiple prepared statements with temp table and stored function. Last prepared statement not binding -



php - Mysqli multiple prepared statements with temp table and stored function. Last prepared statement not binding -

# using combination of php prepared statements mysql. have created stored functions work fine. creating temp table. when hardcode lastly prepared query result table sorted correctly when seek utilize prepared bind parameters doesn't sort correctly. here flow of going on # $createtemptable = ' create temporary table if not exists table2 ( select st.songs_id, st.num_of_votes, st.song_title, st.date_released, st.musiclink, st.ytvideoid, " " artists, " " genres songs_table st inner bring together songs_genres_crossover sgc on sgc.song_id = st.songs_id inner bring together song_genres sg on sgc.genre_id = sg.genre_id , sg.genre_label = ? st.date_released >= ? && st.date_released <= ? ); '; $stmt1 = $mysqli -> prepare("$createtemptable"); $stmt1->bind_param('sss', $genrelabellowercase, $starttime, $endtime); $stmt1->execute(); $stmt1->close(); //this calls stored function , requires no params $updatetemptable = ' select populatesongidswithartistsandgenres(); '; $stmt2 = $mysqli -> prepare("$updatetemptable"); $stmt2->execute(); $stmt2->close(); //this function doesn't seem bind correctly //notice if hardcode , not utilize ? in query executed fine $gettemptableresult = ' select songs_id, num_of_votes, song_title, date_released, musiclink, ytvideoid, artists, genres table2 order ? limit ? , ? ; '; $stmt3 = $mysqli -> prepare("$gettemptableresult"); $topvotedorderby = 'num_of_votes desc, artists asc, song_title asc'; $firstsong = 0; $songstouse = 100; $stmt3->bind_param('sii', $topvotedorderby, $firstsong, $songstouse); $stmt3->execute(); /* bind results */ $stmt3 -> bind_result($songid, $numofvotes, $songtitle, $datereleased, $musiclink, $ytvidid, $artists, $genres); while ($stmt3 -> fetch()) { //use results } $stmt3->close(); i hope info needed help. need figure out why stmt3 not executing correctly. thanks! looking int mysqli_multi_query create query work way protects prepared statements before venture multi_query. guys using query in way workaround. messier works fine # $createtemptable = ' create temporary table if not exists table2 ( select st.songs_id, st.num_of_votes, st.song_title, st.date_released, st.musiclink, st.ytvideoid, " " artists, " " genres songs_table st inner bring together songs_genres_crossover sgc on sgc.song_id = st.songs_id inner bring together song_genres sg on sgc.genre_id = sg.genre_id , sg.genre_label = ? st.date_released >= ? && st.date_released <= ? ); '; $stmt1 = $mysqli -> prepare("$createtemptable"); $stmt1->bind_param('sss', $genrelabellowercase, $starttime, $endtime); $stmt1->execute(); $stmt1->close(); $updatetemptable = ' select populatesongidswithartistsandgenres(); '; $stmt2 = $mysqli -> prepare("$updatetemptable"); $stmt2->execute(); $stmt2->close(); if($sort === 'date released(newest first)') { //newest released $datereleasednewestfirstorderby = 'date_released desc, artists asc, song_title asc'; $gettemptableresult = ' select songs_id, num_of_votes, song_title, date_released, musiclink, ytvideoid, artists, genres table2 order '.$datereleasednewestfirstorderby.' limit '.$firstsong.' , '.$songstouse.' ; '; } else if ($sort == 'artist(a-z)') {//all artists z //artist a-z $artistatozorderby = 'artists asc, song_title asc'; $gettemptableresult = ' select songs_id, num_of_votes, song_title, date_released, musiclink, ytvideoid, artists, genres table2 order '.$artistatozorderby.' limit '.$firstsong.' , '.$songstouse.' ; '; } else if ($sort == 'title(a-z)') { //title a-z $songtitlesatozorderby = 'song_title asc, artists asc'; $gettemptableresult = ' select songs_id, num_of_votes, song_title, date_released, musiclink, ytvideoid, artists, genres table2 order '.$songtitlesatozorderby.' limit '.$firstsong.' , '.$songstouse.' ; '; } else { //top voted $topvotedorderby = 'num_of_votes desc, artists asc, song_title asc'; $gettemptableresult = ' select songs_id, num_of_votes, song_title, date_released, musiclink, ytvideoid, artists, genres table2 order '.$topvotedorderby.' limit '.$firstsong.' , '.$songstouse.' ; '; } $stmt3 = $mysqli -> prepare("$gettemptableresult"); $stmt3->execute(); $stmt3 -> bind_result($songid, $numofvotes, $songtitle, $datereleased, $musiclink, $ytvidid, $artists, $genres); while ($stmt3 -> fetch()) { //use results } $stmt3->close();

see: http://ca3.php.net/manual/en/mysqli.prepare.php

...[prepared statements] not allowed identifiers (such table or column names)...

if you're using prepared statements order clause, contains column names, because expect order determined user input looks need validate user input and/or utilize mysqli_real_escape_string.

:)

php mysqli

Entity Framework model first conflicting table name -



Entity Framework model first conflicting table name -

i have database table named system. when import model first approach have conflict scheme namespace in .net framework. there way workaround it?

i needed check _code.escape(entity) in *.tt files , set right name table.

entity-framework ef-model-first

jenkins - regex exclude hit if text contains a second string match -



jenkins - regex exclude hit if text contains a second string match -

i trying search thru log files see if warnings have appeared can warn in jenkins pipeline using jenkins plug in "text finder".

however, have case not want hits on string "crit" int logfile if string contains plms.

e.g. have next text in log file:

<crit> 23-jun-2014::10:57:13.649 upgrade committed <crit> 23-jun-2014::10:57:13.703 no registration found callpoint plmsview/get_next of type=external

i not interested in having warning sec line, have added next regex text finder in jenkins:

warn|error|<err>|/^(?=<crit>)(?=^(?:(?!plms).)*$).*$/

this should nail on crit if string not contain plms, i.e first line, not nail on either line.

i got code here: combine regexp

could please help me right this? thanks!

you should utilize this:

warn|error|<err>|<crit>(?!.*?no registration found)

change no registration found part match <crit> message want exclude.

this look matches line:

<info> user warner registered

so should consider using like:

^(warn|error|<err>|<crit>(?!.*?no registration found))

that matches if tokens @ origin of line (change tokens accordingly).

regex jenkins

How to deploy existing MySql Data to Amazon AWS -



How to deploy existing MySql Data to Amazon AWS -

i migrate existing web database (developed using mysql) godaddy server amazon aws. please suggest best way achieve.

any pointer or help appreciated. give thanks you.

there 2 ways in can run mysql server in aws

amazon rds mysql in ec2

in either of case you, in perspective of backup , restore, can consider them yet mysql instance. migrate existing there several tools ( open source ) perform backup , restore.

the steps backup , restore go way

take ddl dump ( db , schema ) , execute in aws rds / ec2 instance take info dump ( .sql file ) existing mysql instance ( godaddy ) execute info dump in new mysql instance

these few links provide

mysql backup & recovery - link mysql dumper - link mysql backup , restore command line - link mysql backup , restoration - link

amazon-web-services amazon-ec2 amazon amazon-cloudfront

c# - ASP.NET MVC 4 Routing issues -



c# - ASP.NET MVC 4 Routing issues -

i trying url in browser:

http://localhost:41359/account/login

here routes routeconfig.cs:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using system.web.routing; namespace cthrc.roti.web.ui { public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "account", url: "account/{action}/{id}", defaults: new { controller = "account", action = "login", id = urlparameter.optional } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } } }

but when seek goto url in browser, error:

{"message":no http resource found matches request uri 'http://localhost:41359/account'.","messagedetail":"no type found matches controller named 'account'."}

everything seems right here, still error. here accountcontroller:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using webmatrix.webdata; using cthrc.roti.domain.api.services; namespace cthrc.roti.web.ui.controllers { public class accountcontroller : controller { [httpget] public actionresult login() { if (!websecurity.initialized) { websecurity.initializedatabaseconnection("modelcontext", "users", "id", "username", autocreatetables: true); } homecoming view(); } [httppost] public actionresult login(formcollection form) { bool success = websecurity.login(form["username"], form["password"], false); if (success) { string returnurl = request.querystring["returnurl"]; if (returnurl == null) { response.redirect("/home/index?userid=" + websecurity.currentuserid); } else { response.redirect(returnurl); } } homecoming view(); } [httpget] public actionresult register() { if (!websecurity.initialized) { websecurity.initializedatabaseconnection("userdb", "users", "id", "username", autocreatetables: true); } homecoming view(); } [httppost] public actionresult register(formcollection form) { websecurity.createuserandaccount(form["username"], form["password"], new { email = form["email"], language = form["language"] }); response.redirect("/account/login"); homecoming view(); } public actionresult logout() { websecurity.logout(); response.redirect("/account/login"); homecoming view(); } } }

i have been struggling issue days now, have cleaned solution, re-built solution , built solution , still error. if can help me much appreciated. in advance.

c# asp.net asp.net-mvc-4 asp.net-mvc-routing

entity framework - How to determine reason for slow inserts SQL Server Compact Edition 4.0? -



entity framework - How to determine reason for slow inserts SQL Server Compact Edition 4.0? -

i have application using code first model entity framework 6.1 , sql server compact edition 4. inserting simple table id, 1 datetime 2 singles, 2 doubles, , 3 ints slow, ranging 8 15 inserts per sec on scheme ssd.

what best tools , techniques track downwards reason slow inserts in sql server ce 4?

entity framework not designed fast inserts, can utilize sqlcebulkcopy library fast inserts, , pass collection of ef objects

entity-framework sql-server-ce-4

r - renderMarkdown locally vs. shiny-server -



r - renderMarkdown locally vs. shiny-server -

for shiny application, have little issue rendermarkdown.

consider text file next simple contents:

markdown test file + item 1 + item 2

let's save file "markdown test.txt". now, let's read in , process it, using next r code:

filename <- "markdown test.txt" text.in <- readlines(filename) text.out <- rendermarkdown(text=text.in)

when run locally - i.e. on windows machine - get:

> text.out [1] "<p>markdown test file</p>\n\n<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n"

this looks good. however, running same code on machine hosts shiny server, get:

> text.out [1] "<p>markdown test file+ item 1+ item 2</p>\n"

as can see, markdown conversion far perfect; e.g. list not converted.

on windows machine have:

> sys.getlocale() [1] "lc_collate=english_united states.1252;lc_ctype=english_united states.1252;lc_monetary=english_united states.1252;lc_numeric=c;lc_time=english_united states.1252"

on shiny machine, get:

> sys.getlocale() [1] "lc_ctype=en_us.utf-8;lc_numeric=c;lc_time=en_us.utf-8;lc_collate=en_us.utf-8;lc_monetary=en_us.utf-8;lc_messages=en_us.utf-8;lc_paper=c;lc_name=c;lc_address=c;lc_telephone=c;lc_measurement=en_us.utf-8;lc_identification=c"

so, i'm assuming has encoding, little know encoding wish didn't... experiments dos2unix , sys.setlocale() allow nil frustration.

would happen have clever "one liner" can prepare this? help appreciated!

thanks, philipp

i'm not sure if r has dedicated bundle prepare line encodings, 1 way utilize sub replace \r\n \n (or strip \rs).

r markdown shiny-server

c# - getting timeout error on dbtransaction -



c# - getting timeout error on dbtransaction -

i getting timeout error thrown. how can increment amount of time before transaction times out?

database dbsvc = databasefactory.createdatabase(); //use 1 connection using (dbconnection conn = dbsvc.createconnection()) { conn.open(); dbtransaction transaction = conn.begintransaction(); seek { .... } grab (exception ex) { transaction.rollback(); ret.issuccess = false; ret.exceptioninfo = ex; } { ret.invoiceinfo = invoiceout; }

thanks!

if using ado.net add together timeout property connection string. increment accordingly until no longer times out, if adding timeout property should looking @ db , analyzing weaknesses such lack of indexes can done via analyzing queries via sql profilier.

c# asp.net sql-server connection-timeout

.net - Clarification on in process side by side execution -



.net - Clarification on in process side by side execution -

this extract this msdn article:

targeting , running apps older versions

the .net framework versions 2.0, 3.0, , 3.5 built same version of clr (clr 2.0). these versions represent successive layers of single installation. each version built incrementally on top of before versions. not possible run versions 2.0, 3.0, , 3.5 side side on computer. when install version 3.5, 2.0 , 3.0 layers automatically, , apps built versions 2.0, 3.0, , 3.5 can run on version 3.5. however, .net framework 4 ends layering approach, apps built 2.0. 3.0, or 3.5 not work on version 4 or later. starting .net framework 4, can utilize in-process side-by-side hosting run multiple versions of clr in single process.

from above paragraph:

it not possible run versions 2.0, 3.0, , 3.5 side side on computer.

this certainly not true it? can have applications using 2.0 , 3.5 run on same machine.

starting .net framework 4, can utilize in-process side-by-side hosting run multiple versions of clr in single process.

this biggest problem. can confirm, 1 time , all, whether in process side side execution, introduced in .net 4.0, applicable .net processes or native com applications using managed com add together ins? several msdn articles create generic statement seen above, com add together ins. 1 it?

.net 2.0 brand-new version of clr not compatible either of older versions, .net 1.0 or 1.1. however, .net 3.0 , 3.5 extensions built on top of .net 2.0 clr. added features (e.g., wpf , linq) not there in 2.0, , fixed bugs in clr, strictly designed supersets. in sense, not possible have .net 2.0, 3.0, , 3.5 installed side-by-side on same machine. there no .net 3.0/3.5 without .net 2.0. latest version of install replace other. apps target older version go on run on newer version because required pieces still there.

so statement documentation:

it not possible run versions 2.0, 3.0, , 3.5 side side on computer.

is true. interpretation of incorrect. can have different applications installed target 2.0 , 3.5, , go on run. they'll utilize same clr.

as sec question, regarding side-by-side execution, all versions of .net framework have supported side-by-side hosting managed applications. have .net 1.0, 1.1, , 2.0 installed simultaneously, , applications whichever version of framework targeted.

the problems started when had add-ins targeted different version of clr host application. these either ran on wrong/unexpected version of clr , had unexpected behavior (i.e. bugs), or refused load altogether.

this problem punted versions 3.0 , 3.5 because, explained above, built on top of .net 2.0 clr—the so-called "layer cake" model. version 4.0 introduced in process side-by-side execution, allows multiple versions of clr hosted in single process. way, app gets version of clr targets , add-ins hosts version(s) of clr request in app.config file(s). inproc sxs available all processes load clr. confusion in reading documentation stems fact com add-ins mutual , hence subject of articles. mutual utilize case native applications consume multiple managed add-ins, each targeting different versions of clr.

this article msdn magazine has interesting , relevant tidbits.

oh, , way, .net 4.5 uses totally different model yet. in-place replacement of .net 4.0 dlls. whole other answer.

.net .net-4.0 side-by-side

ios - How to post message to friends wall in Twitter using ID -



ios - How to post message to friends wall in Twitter using ID -

i want send invite message user friend using twitter id, can not thought how can point me right direction code or tutorial

the sttwitter api find great resource implementing twitter in app. "readme" file contains lot of informative code snippets , descriptions developer video: sttwitter developer video. youtube , google great resources type of thing, can find lot of help , tutorials.

ios twitter

Hadoop 2.4: java.lang.NoClassDefFoundError: org/apache/hcatalog/mapreduce/InputJobInfo -



Hadoop 2.4: java.lang.NoClassDefFoundError: org/apache/hcatalog/mapreduce/InputJobInfo -

i have upgraded recent hadoop hortonworks:

hadoop 2.4.0.2.1.2.1-471 subversion git@github.com:hortonworks/hadoop.git -r 9e5db004df1a751e93aa89b42956c5325f3a4482 compiled jenkins on 2014-05-27t18:57z compiled protoc 2.5.0 source checksum 9e788148daa5dd7934eb468e57e037b5 command run using /usr/lib/hadoop/hadoop-common-2.4.0.2.1.2.1-471.jar

before upgrading wrote java mrd programme uses hive tables both input & output. in previous version of hadoop worked, notwithstanding got deprecation warnings @ compile time code:

job job = new job(conf, "foo"); hcatinputformat.setinput(job,inputjobinfo.create(dbname, inputtablename, null));

now, after updating dependencies new jars in hadoop 2.4.0.2.1.2.1-471 , runing same code next error:

exception in thread "main" java.lang.noclassdeffounderror: org/apache/hcatalog/mapreduce/inputjobinfo @ com.bigdata.hadoop.foo.run(foo.java:240) @ org.apache.hadoop.util.toolrunner.run(toolrunner.java:70) @ org.apache.hadoop.util.toolrunner.run(toolrunner.java:84) @ com.bigdata.hadoop.foo.main(foo.java:272) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.apache.hadoop.util.runjar.main(runjar.java:212) caused by: java.lang.classnotfoundexception: org.apache.hcatalog.mapreduce.inputjobinfo @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:425) @ java.lang.classloader.loadclass(classloader.java:358) ... 9 more

to run code utilize next settings:

export libjars=/usr/lib/hive-hcatalog/share/hcatalog/hive-hcatalog-core.jar,/usr/lib/hive/lib/hive-exec.jar,/usr/lib/hive/lib/hive-metastore.jar,/usr/lib/hive/lib/libfb303-0.9.0.jar,/usr/lib/hive/lib/jdo-api-3.0.1.jar,/usr/lib/hive/lib/antlr-runtime-3.4.jar,/usr/lib/hive/lib/datanucleus-api-jdo-3.2.6.jar,/usr/lib/hive/lib/datanucleus-core-3.2.10.jar

export hadoop_classpath=/usr/lib/hive-hcatalog/share/hcatalog/hive-hcatalog-core.jar,/usr/lib/hive/lib/hive-exec.jar,/usr/lib/hive/lib/hive-metastore.jar,/usr/lib/hive/lib/libfb303-0.9.0.jar,/usr/lib/hive/lib/jdo-api-3.0.1.jar,/usr/lib/hive/lib/antlr-runtime-3.4.jar,/usr/lib/hive/lib/datanucleus-api-jdo-3.2.6.jar,/usr/lib/hive/lib/datanucleus-core-3.2.10.jar

any ideas why java.lang.noclassdeffounderror: org/apache/hcatalog/mapreduce/inputjobinfo ?

i think should add together next dependency in pom.xml.

<dependency> <groupid>org.apache.hcatalog</groupid> <artifactid>hcatalog-core</artifactid> <version>0.11.0</version> </dependency>

java hadoop hive hcatalog

apache - How can I forward HttpResponse to an open client socket? (Java Program acts as a proxy) -



apache - How can I forward HttpResponse to an open client socket? (Java Program acts as a proxy) -

i using httpclient lib apache. managed httpresponse sending request server. trying send response got clientsocket output stream.

so want send whatever received server open client connection. since using httpclient response in form of httpresponse object. tried following:

private void forwardrequest(string header, string url){ seek { closeablehttpclient httpclient = httpclients.createdefault(); httpget httpget = new httpget(url); closeablehttpresponse response; //adding request headers httpget string lines[] = header.split("\\n"); (string str : lines) { string parts[] = str.split(":", 2); httpget.addheader(parts[0], parts[1]); } httpresponse respone; response = httpclient.execute(httpget); //it works till here can read response , print out html page //but after don't know how send client outputstream bos = clientsocket.getoutputstream(); printwriter pw = new printwriter(bos); bufferedreader rd = new bufferedreader(new inputstreamreader(response.getentity().getcontent())); while ((line = rd.readline()) != null) { pw.println(line); //bos.write(line.getbytes()); //this doesn't work } response.close(); }

also clientsocket global variable associcated serversocket like:

clientsocket = serversocket.accept();

i don't expect total solution. point me in right direction.. ton!

edit:

i tried next based on ejp suggested.. it's still not working. wondering if correctly implemented?

int portnumber = 8012; // port on programme listens serversocket serversocket = new serversocket(portnumber); //the socket @ programme listens socket clientsocket = serversocket.accept(); //clientsocket of programme socket toserver = new socket("localhost", 8089); //proxy server programme connects printwriter out = new printwriter(toserver.getoutputstream(), true); printwriter outclient = new printwriter(clientsocket.getoutputstream(), true); bufferedreader in = new bufferedreader( new inputstreamreader(clientsocket.getinputstream())); bufferedreader inserver = new bufferedreader( new inputstreamreader(toserver.getinputstream())); ) { string inputline; while ((inputline = in.readline()) != null) { out.println(inputline); //writing proxy server outclient.println(inserver.readline()); //writing original request sender system.out.println(inputline); }

the client made http request, expecting http response. if global clientsocket raw tcp socket , not httpclient, need add together http response protocol header yourself.

you have content server, you'll want first homecoming http response 200 ok, empty line carriage homecoming + linefeed (cr+lf), content-length: , document. if proxying text documents, convert string here, otherwise, pass mime type, charset, , entity through raw bytes web server responded, way can proxy document, including images or binary files.

it this:

http/1.1 200 ok content-type: text/html content-length: length <html> ... </html>

to pass http headers through server:

httpentity entity = response.getentity(); // technically should check http response rather assume 200 int statuscode = httpresp.getstatusline().getstatuscode(); if(statuscode != 200) ... // non 200 responses ? clientsocket.write("http/1.1 200 ok\r\n"); header[] responseheaders = response.getallheaders(); for(header header : responseheaders) { clientsocket.write(header.tostring() + "\r\n"); } clientsocket.write("\r\n"); // empty line required // utilize bufferedinputstream deal in bytes bufferedinputstream input = new bufferedinputstream(entity.getcontent()); byte[] buf = new byte[8192]; int bytesread; while ((bytesread = input.read(buf, 8192)) > 0) { clientsocket.write(buf, bytesread); }

i "something this", don't take literal, uncertainty compiles. don't have dev station in front end of me, general idea.

note: since using apache client lib, should able utilize specific http client instead of writing raw protocol. abstract http protocol away somewhat. i'll update reply later if nobody else provides improve one.

java apache sockets proxy httpresponse

php - Drupal Preprocess/Hook Confusion -



php - Drupal Preprocess/Hook Confusion -

i'm having difficulty grasping semantics in implementing hook themes, , consequently understanding way in preprocess/process functions created. i'm using "the definitive guide drupal 7", states(technically) next code should implement/define/ , output theme function.

/** * implements hook_theme(). **/ <?php // core/module_urtheme() - kiwi themesname function node_kiwi(){ homecoming array( 'addblock' => array( 'block' => 'content' ), ); } //define theme_functionname/ should theme_addblock? function kiwi_addblock($block){ homecoming '<div class="kiwi-block">'.$block.'</div>';} //use print theme('addblock',$block)

my problem lies in utter confusion in regards syntax preprocess functions have:

<?php /** * implements template_preprocess_themehook(). */ function hook_preprocess_themehook(&$variables) { // changes go here. }

ultimately i'm aware both hook , themehook placeholders, should replace them, hook module/template/theme? themehook - function's name/the theme/? tried comparing the theme hook implementation above, made me more confused. apologize in advance naive mistakes might have made/said. , help much appreciated :) .

as far know, hook name of module or theme, , themehook hook defined within hook_theme(), typical ones "block", "node"... etc. example: yourmodule_preprocess_node(&$variables).

php drupal-7 drupal-modules drupal-theming drupal-hooks

jquery - KnockoutJS UI not binding on first load -



jquery - KnockoutJS UI not binding on first load -

this first stab @ knockoutjs. code below. getjson phone call working. can see response in fiddler , have validated jslint (ie json response). can see array beingness populated in chrome console, reason ui not updating info fetch server. can see i've missed?

<script type="text/javascript"> function section(data) { this.id = ko.observable(data.id); this.name = ko.observable(data.name); this.selected = ko.observable(data.selected); } function sectionsviewmodel() { var self = this; self.viewname = ko.observable(); self.sections = ko.observablearray([]); // initial load $.getjson("/service/view/getjson?viewid=@viewbag.viewid", function (alldata) { self.viewname = alldata.viewname; var mappedsections = $.map(alldata.sections, function (item) { homecoming new section(item) }); self.sections = mappedsections; }); } ko.applybindings(new sectionsviewmodel()); </script> <h2>edit view</h2> <table class="dataentrytable"> <thead> <tr> <th>id</th> <th>name</th> <th>selected</th> </tr> </thead> <tbody data-bind="foreach: sections"> <tr> <td data-bind="text: id()"></td> <td data-bind="text: name()"></td> <td><input type="checkbox" data-bind="checked: selected()" /></td> </tr> </tbody> </table>

update ko observables function:

self.viewname(alldata.viewname); var mappedsections = $.map(alldata.sections, function (item) { homecoming new section(item) }); self.sections(mappedsections);

also in binding, remove parenthesis (you binding value of observable instead of observable itself):

<td data-bind="text: id"></td> <td data-bind="text: name"></td> <td><input type="checkbox" data-bind="checked: selected" /></td>

finally, need phone call ko.applybindings(new sectionsviewmodel()); after html has rendered bind loaded html view model (either set script after html, or utilize event phone call on document ready).

jquery knockout.js

How to replace string with variable in PowerShell? -



How to replace string with variable in PowerShell? -

i have code struggling little bit with:

$numberofprofiles = read-host "enter number of profiles" $directory = "c:\users\apple\folder(1..howmuchprofilescreated\text.txt" variable1 = "plane" variable2 = "yacht" variable100 = "bike" while ($numberofprofiles -gt 0) { (get-content $directory) | %{$_.replace("car", "don'tknowwhattoputhere")} | set-content $directory $numberofprofiles--

the text.txt file same in folders , contains same string wish alter (e.g. "car" in case), new string should come variables have declared before and(or may improve utilize array?)

e.g. $numberofprofiles = 10 , create 10 folders same text.txt , need "car" replaced variable1 in folder1, variable2 in folder2 , on.

if can build name of variable, can utilize get-variable. illustration illustrate:

$variable1 = "bike" $folderid = 1 get-variable -name "variable$folderid" -valueonly

will result in

bike

powershell

string - How to insert a text with single quots to sqlite db in android? -



string - How to insert a text with single quots to sqlite db in android? -

i facing issue in inserting issue in inserting text single quotes in sqlite db in android. returning next error.

06-21 15:21:55.644: e/androidruntime(16328): android.database.sqlite.sqliteexception: near "re": syntax error (code 1): , while compiling: select * tbl_chathistory chat_date = '1.403344315631e12' , chat_time = '1.403344315635e12' , chat_text = 'you're'

please help.

**************** edited *************************

public boolean checkchatexists(string date, string time, string chat) { boolean result = false; string selectquery = "select * tbl_chathistory chat_date = '"+date+"' , chat_time = '"+time+"' , chat_text = '"+chat+"'"; sqlitedatabase database = this.getwritabledatabase(); cursor cursor = database.rawquery(selectquery, null); if (cursor.movetofirst()) { result = true; } else { result = false; } cursor.close(); homecoming result; }

in sql string literals can escape ' ''.

it improve utilize parametrized queries. replace string literals ? , provide values in bindargs array. example:

string selectquery = "select * tbl_chathistory chat_date = ? , chat_time = ? , chat_text = ?"; cursor cursor = database.rawquery(selectquery, new string[] { date, time, chat });

android string sqlite

java - Must I have a return statement in a method when I already have it in the if statement? -



java - Must I have a return statement in a method when I already have it in the if statement? -

i got function below:

public double getcost(string bookname) { if(bookname.equals(arrayofbook[2])) { homecoming arrayofcost[2]; } }

arrayofcost array of double. have statement homecoming double value here. compiler still says missing homecoming statement in function. that's why?

yes, need homecoming statement (in fact, compiler tells so). because method must homecoming regardless of condition. in other words, programme needs specify happens when status false. example, homecoming zero, infinity, "not number" constant, et cetera.

the exception void methods: not require homecoming statement @ end, , allowed have returns in other branches.

java

c++ - memcpy extremely unexpected behavior -



c++ - memcpy extremely unexpected behavior -

i'm using memcpy re-create info , array getting written on disk. i'm storing a char* of 256 bytes (name array)*, 3 long numbers, , a short number. thought going work correctly until tried , didn't. when saving info disk, seems work fine. when trying read off information, memcpy malfunctions, leaving variable straight after name array @ 0, , when programme needs load else, end seg fault.

at first thought info could've been getting corrupted when written disk, or when beingness loaded it, couldn't find huge issues saving or loading procedures, did next print out every single byte on array (with qt's qdebug), see if spot wrong it.

needless say, didn't work out planned since qdebug printed non null characters, , "name array" has lot of those, did ridiculously surprising: somehow made memcpy work , not work, since re-create first long number, corrupt sec long number. thing is, whole thing pretty much unrelated!

char* block = new char[freeblock::tablamtd_v]; //3958 bytes long fread.seekg(toload, ios::beg); //toload beingness unsigned long file pointer, fread beingness working ifstream fread.read(block, freeblock::tablamtd_v); //reading 3958 bytes block fread.close(); short bsize = 0, pos = 0; memcpy(&bsize, block, 2); pos+=2; for(short = 0; < bsize; i++){ char* tname = new char[257]; unsigned long ptrmtd = 0, ptrdt = 0, ptrind = 0; unsigned short indmtd = 0; memcpy(tname, &block[pos], 256); tname[256] = 0; pos+=256; memcpy(&ptrmtd, &block[pos], 8); //without qdebug loop, stays @ 0. otherwise, has right value pos+=8; memcpy(&ptrdt, &block[pos], 8); //with qdebug loop, stays @ 0. otherwise, has right value pos+=8; memcpy(&ptrind, &block[pos], 8); pos+=8; memcpy(&indmtd, &block[pos], 2); pos+=2; for(int = 0; < freeblock::tablamtd_v; i++){ qdebug()<<block[i]; //miracle solution, somehow } campomtdb* cmtd = nextcampomtdb(ptrmtd, true); //based on ptrmtd, if 0, returns null pointer unsigned long nextcmtdb = cmtd->next; //seg fault due null pointer

since loop thing have added, , commenting it/uncommenting changes outcome of entire procedure, i'm quite baffled. sort of sets new record me on "unexpected behavior" plane.

taking consideration i'm new c++, , i've until heard of random unsafe practices i'm using here apparently should not using, still don't see how or why adding random loop after memcpy operations have impact whatsoever on these operations, or why memcpy wouldn't work should in first place.

also note after saved file, didn't touch again, hasn't changed @ all, yet output reading changes.

in case helps know, i'm using vc2013 in qt 5.3, x64 windows 7

since you're using vc2013 under windows 7, size of unsigned long 4 bytes (not 8 bytes).

and in case, own safety, should utilize sizeof instead of constant values of 8 , 2.

change this:

memcpy(&ptrmtd, &block[pos], 8); pos+=8; memcpy(&ptrdt, &block[pos], 8); pos+=8; memcpy(&ptrind, &block[pos], 8); pos+=8; memcpy(&indmtd, &block[pos], 2); pos+=2;

to this:

memcpy(&ptrmtd, &block[pos], sizeof(ptrmtd)); pos+=sizeof(ptrmtd); memcpy(&ptrdt, &block[pos], sizeof(ptrdt)); pos+=sizeof(ptrdt); memcpy(&ptrind, &block[pos], sizeof(ptrind)); pos+=sizeof(ptrind); memcpy(&indmtd, &block[pos], sizeof(indmtd)); pos+=sizeof(indmtd);

c++

lazy io - reading files with references to other files in haskell -



lazy io - reading files with references to other files in haskell -

i trying expand regular markdown ability have references other files, such content in referenced files rendered @ corresponding places in "master" file.

but furthest i've come implement

createf :: ftree -> io string createf null = homecoming "" createf (node f children) = ifnexists f (_id f) (do childstrings <- mapm createf children withfile (_path f) readmode $ \handle -> fc <- lines <$> hgetcontents handle homecoming $ merge fc childstrings)

ifnexists helper can ignored, real problem happens in reading of handle, returns empty string, assume due lazy io.

i thought utilize of withfile filepath readmode $ \handle -> {-do stutff-}hgetcontents handle right solution i've read fcontent <- withfile filepath readmode hgetcontents bad idea.

another thing confuses me function

createft :: file -> io ftree createft f = ifnexists f null (withfile (_path f) readmode $ \handle -> allow thisparse = fparse (_id f :_parents f) children <-rights . map ( thisparse . trim) . lines <$> hgetcontents handle c <- mapm createft children homecoming $ node f c)

works charm.

so why createf homecoming empty string?

the whole project , directory/file test can found @ github

here datatype definitions

type id = string info file = file {_id :: id, _path :: filepath, _parents :: [id]} deriving (show) info ftree = null | node { _file :: file , _children :: [ftree]} deriving (show)

as suspected, lazy io problem. here's (awful) rule have follow utilize without going totally nuts:

a withfile computation must not finish until (lazy) i/o required evaluate result has been performed.

if forces i/o after handle closed, not guaranteed error, though nice. instead, undefined behavior.

you break rule return $ merge fc childstrings, because value returned before it's been evaluated. can instead vaguely like

let retval = merge fc childstrings deepseq retval $ homecoming retval

an arguably cleaner alternative set rest of code relies on results withfile argument. real reason not if bunch of other work results after you're finished file. example, if you're processing bunch of different files , accumulating results, want sure close each of them when you're done it. if you're reading in 1 file , acting on it, can leave open till you're finished.

by way, submitted feature request ghc team see if might willing create these kinds of programs more fail useful error messages.

update

the feature request accepted, , such programs much more produce useful error messages. see what caused "delayed read on closed handle" error? details.

haskell lazy-io

javascript - Dynamically set child View $el and have Backbone events fire -



javascript - Dynamically set child View $el and have Backbone events fire -

i have parent view (and associated model), several children views same associated model. parent view defined statically html. these events working fine.

the children views created dynamically, , different, have similar initial structure. #id s different each other (using view id number) can know 1 interacted user. have tried next reading around:

adding el declaration when create view (towards end of js) statically defining it, trying update it. using _.ensureelement() setting el in init()

but can't seem children views on fiddle.

fiddle

js: parent

//the view our measure parentmodule.view = backbone.view.extend({ // //this 1 static, can set directly, no problem, events working // el: $('#measure-container'), events: { 'click .test': 'test' }, test: function(){ alert('test'); }, initialize: function() { this.template = _.template($('#instrument-template').html()); }, render: function(){ $(this.el).append(this.template(this.model.tojson())); homecoming this; } }); homecoming parentmodule; });

js: kid

// kid views dynamic, how set id's dynamicall , still click events fire? // childmodule.view = backbone.view.extend({ // // set el here statically override? // events: { 'click .remove-rep' : 'removerepresentation', 'click .toggle-rep' : 'togglereptype', 'click .salert': 'showalert' }, initialize: function(options) { // //do set el here using ensure_element? // this.model=options.model; }, render: function(){ // // set here when renders? // this.template = _.template($('#rep-template').html()); $('#measure-rep-container').append(this.template()); homecoming this; }, showalert: function() { alert("this alert!"); } });

js: instantiation

define( "app", ["jquery", "backbone", "parentmodule", "childmodule"], function($, backbone, parentmodule, childmodule) { var app = {}; app.model = new parentmodule.model({ name: "snare", numofbeats: 4 }); app.view = new parentmodule.view({ model: app.model }); app.view.render(); app.firstrepchildmodel = new childmodule.model({ id: 1, type: 'circle', parentmodel: app.model }); // // add together el parameter when creating view? // app.firstrepchildview = new childmodule.view({ el:'#rep'+app.firstrepchildmodel.get('id'), model: app.firstrepchildmodel }); app.firstrepchildview.render(); app.secondrepchildmodel = new childmodule.model({ id: 2, type: 'line', parentmodel: app.model }); // // add together el parameter when creating view? // app.secondrepchildview = new childmodule.view({ el:'#rep'+app.secondrepchildmodel.id, model: app.secondrepchildmodel }); app.secondrepchildview.render(); homecoming app; });

html:

<h3>measure view</h3> <div id="measure-container"> </div> <!-- templates --> <script type="text/template" id="instrument-template"> <div class="instrument"> instrument. name <%=name%>. <br/> here children repviews: <br/> <div id="measure-rep-container"> <div class="btn btn-primary test">add rep</div> </div> </div> </script> <script type="text/template" id="rep-template"> <div class="rep" id="rep<%=this.model.id%>"> repview <br/> id 'rep<%=this.model.id%>' <br/> el '<%=this.$el.selector%>'<br/> type '<%=this.model.type%>' <br/> have many beats '<%=this.model.numofbeats%>' <br/> <div class="beatcontainer"></div> <div class="btn btn-danger remove-rep" id="">remove rep</div> <div class="btn btn-primary toggle-rep" id="">toggle rep type</div> <div class="btn salert">show alert</div> </div> </script>

every view has associated el, whether set straight or not, if don't set it's el empty div.

in code aren't modifying kid view's el or attaching dom.

try following

render: function(){ this.template = _.template($('#rep-template').html()); //this sets content of el, still isn't attached dom this.$el.html(this.template()); $('#measure-rep-container').append(this.el); homecoming this; },

updated fiddle

as separate point if going reusing same template multiple times might want compile once, example

childmodule.view = backbone.view.extend({ events: { 'click .remove-rep' : 'removerepresentation', 'click .toggle-rep' : 'togglereptype', 'click .salert': 'showalert' }, //get's called 1 time regardless of how many kid views have template: _.template($('#rep-template').html()), render: function(){ this.$el.html(this.template()); $('#measure-rep-container').append(this.el); homecoming this; },

javascript backbone.js backbone-views backbone-events

vbscript - Open file dialog to select XML file -



vbscript - Open file dialog to select XML file -

i have vbscript selects file c: drive , gets info tag on xml file want user able select file dialog cant seem done, here script:

dim xmldoc, objnodelist, plot, fin set xmldoc = createobject("msxml2.domdocument") xmldoc.load("c:\users\user\documents\vbscript\mlb.xml") set objnodelist = xmldoc.getelementsbytagname("league") set objfso=createobject("scripting.filesystemobject") ' create file outfile= "c:\users\user\documents\vbscript\leagues.txt" set objfile = objfso.createtextfile(outfile,true) if objnodelist.length > 0 each x in objnodelist plot= x.getattribute("name") 'write file objfile.write plot & vbcrlf next else msgbox " field not found." end if objfile.close

any help appreciated.

for windows xp can utilize useraccounts.commondialog object, see documentation more details in short it's this:

set dlg = createobject("useraccounts.commondialog") dlg.initialdir = createobject("wscript.shell").specialfolders("mydocuments") dlg.filter = "xml files|*.xml" if dlg.showopen <> 0 set xmldoc = createobject("msxml2.domdocument") xmldoc.load(dlg.filename) ' code end if

note i'm using wscript.shell object user's documents folder (so don't have hard-code it). i'd suggest same thing output file.

unfortunately object has been removed in windows 7 (maybe because of security issues) have utilize else. there many candidates, let's see of them.

easier method utilize comdlg32.dll this:

set dlg = createobject("mscomdlg.commondialog.1") dlg.initialdir = createobject("wscript.shell").specialfolders("mydocuments") dlg.filter = "xml files|*.xml"

this dll seems don't registered on every system, if case have download it in c:\windows\system32 , register com objects regsrv32.

a decent alternative utilize shell object (explore methods on msdn):

set dlg = createobject("shell.application") set selectedfile = objshell.browseforfolder(0, "xml file:", &h00004000&, "c:\") if not selectedfile nil set xmldoc = createobject("msxml2.domdocument") xmldoc.load(selectedfile.self.path) end if

that isn't true open file dialog browse folder dialog files, improve solution utilize getopenfilename, code longer please refer this article total source , details. in short have import function:

declare function getopenfilename lib "comdlg32.dll" alias "getopenfilenamea" (ofn openfilename) boolean

you may want take this code on github, handles of tricky cases (yes such simple task isn't simple!!!)

xml vbscript

c++ - Linking error in pcl EuclideanClusterExtraction -



c++ - Linking error in pcl EuclideanClusterExtraction -

i having strangest linking error when trying run illustration provided pcl:

http://www.pointclouds.org/documentation/tutorials/cluster_extraction.php

i have narrowed error downwards next line:

ec.extract (cluster_indices);

when remove line there no linking errors otherwise bunch this:

/usr/local/lib/libpcl_search.a(organized.cpp.o): in function `pcl::search::organizedneighbor<pcl::pointxyzl>::computecameramatrix(eigen::matrix<float, 3, 3, 0, 3, 3>&) const': organized.cpp:(.text._znk3pcl6search17organizedneighborins_9pointxyzlee19computecameramatrixern5eigen6matrixifli3eli3eli0eli3eli3eee [_znk3pcl6search17organizedneighborins_9pointxyzlee19computecameramatrixern5eigen6matrixifli3eli3eli0eli3eli3eee]+0xc): undefined reference `pcl::getcameramatrixfromprojectionmatrix(eigen::matrix<float, 3, 4, 1, 3, 4> const&, eigen::matrix<float, 3, 3, 0, 3, 3>&)'

ec of type pcl::euclideanclusterextraction<pcl::pointxyz> , of ascociated point clouds utilize pcl::pointxyz template. straight out of example.

i have had similar error before , turned out because attempting utilize pcl::pointxy sampleconsesus library not supported.

to effort solve problem used nm on libpcl_search.a link library , values included this:

_znk3pcl6search17organizedneighborins_11pointnormalee19computecameramatrixern5eigen6matrixifli3eli3eli0eli3eli3eee

which close include funcitons needed, seems pointxyz implementation doesn't exist? how can find out if case , why?

so looks cmake struggling dependencies. reason sure because of way forced include pcl. using operating scheme called qnx means cmakelists.txt needs this:

cmake_minimum_required(version 2.8 fatal_error) set (cmake_c_compiler /usr/qnx650/host/qnx6/x86/usr/bin/gcc) set (cmake_cxx_compiler /usr/qnx650/host/qnx6/x86/usr/bin/g++) project(cluster_extraction) find_package(pcl 1.7 required) include_directories(/usr/local/include /usr/local/include/pcl-1.7) link_directories(/usr/local/lib) add_definitions(${pcl_definitions}) add_executable (cluster_extraction testeuclideanclustering.cpp) target_link_libraries (cluster_extraction ${pcl_libraries})

if add together direct link pcl_search after link of ${pcl_libraries} compile. seems need create our own cmake rules pcl.

c++ static-linking point-cloud-library

python - Concatenation of items in list -



python - Concatenation of items in list -

i have such list:

['s/m - black', ' 93094-01']

it result of:

m['value'].split(',')[0:2:]

how can produce such string it:

's/m - black, 93094-01'

i have tried:

print [i + ', ' + in m['value'].split(', ')[0:2:]]

but gives me:

['s/m - black, s/m - black', ' 93094-01, 93094-01']

you should utilize bring together method:

",".join(m['value'].split(', ')[0:2:])

python string text concatenation string-concatenation