Posts

Showing posts from March, 2011

qt creator - libvlc_new (0, NULL); segmentation fault -

i have problem when use line : vlcinstance = libvlc_new(0, null); vlcinstance declare in header: libvlc_media_player_t *vlcplayer; i using qt 5.0.1 , have error: the inferior stopped because received signal operating system. signal name : sigsegv signal meaning : segmentation fault can me? i using qt creator 2.7.2 qt 5.1.0 on 64-bit kubuntu 13.04. i'm using vlc-2.2.0-git. i created new qt project. i added new project file (change vlc paths needed): includepath += /home/linux/vlc/install/include libs += -l"/home/linux/vlc/install/lib" -lvlc bare-bones main.cpp (including code apparently segfaults): #include <qtdebug> #include "vlc/libvlc.h" #include "vlc/libvlc_media.h" #include "vlc/libvlc_media_player.h" int main(int argc, char *argv[]) { qdebug() << "starting..."; libvlc_instance_t* p_instance = libvlc_new(0, null); qdebug() << "p_instance" <&l

java - ActionBar up button transition effect -

i have created method animation when changing activities when button pressed. problem actionbar button has default transition effect previous activity , can't find way override animation , use new one. ideas? in advance preferably hardcoded in java just event "home back" @override public boolean onoptionsitemselected(menuitem item) { if (item.getitemid() == android.r.id.home) { finish(); overridependingtransition(r.animator.anim_left, r.animator.anim_right); return true; } return false; }

Editing an svg file -

i have svg file maps out theater seating area. draws each seat circle. change square. here code have id="path7" title="f46" d="m 281.9461,86.766 c -2.796,0 -5.071,-2.275 -5.071,-5.071 0,-2.796 2.275,-5.072 5.071,-5.072 2.797,0 5.072,2.276 5.072,5.072 0,2.796 -2.275,5.071 -5.072,5.071 z" inkscape:connector-curvature="0" fill="#cdcdcd" stroke="#cdcdcd" stroke-width="3" /> if on great you have 2 options: use library svg http://www.svgjs.com/ manipulate text specifications. change d=m 281.9461, 86.766 c <list of coordinates> d=m 281.9461, 86.766 c <top left coord>, <top right coord>, <bottom right coord>, <bottom left coord>

android - Gradle plugin, running tasks twice during build -

i'm trying extend functionality of gradle android plugin . point is, need run same tasks twice on 1 build (in fact whole chain of tasks till connectedinstrumenttest), , couldn't manage how using gradle, decided write own plugin extention existing android plugin. so, i'm trying use functionality of android plugin in my, using such groovy code: void apply(project project) { project.plugins.apply(javaplugin.class) project.plugins.apply(androidplugin.class) this.project = project this.logger = project.logger androidplugin = new androidplugin() a.apply(project) but, trying compile it, error: import com.jvoegele.gradle.plugins.android.androidplugin i'm using such build.gradle compile plugin: buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4.2' } } apply plugin: 'groovy' dependencies { compile gradleapi() compile localgroovy() } also, i'm first time using

asp.net - Controls.Remove() does not work after CreateChildControls? -

i developing sharepoint 2010 non-visual webpart displays kind of data in big table. table rows should filtered selecting filter criterium dropdownlist part of webpart. the onselectedindexchanged event of dropdownlist fired after createchildcontrols , before onprerender. because cells of table contain linkbuttons onclick event attached, must created in createchildcontrols in order onclick events fired. i don't know rows of table hide until onselectedindexchanged of dropdownlist fired, create possible table rows in createchldcontrols , try remove filtered ones later in onselectedindexchanged event directly or in onprerender. rows physically removed parent table's control collection, nevertheles displayed. as test, tried remove random rows @ end of createchildcontrols method after creating them, worked , rows not rendered. how remove rows: table mt = findcontrol("matrixtable") table; helpers.log("controls in table: " + mt.controls.count);

sql server - Why are these DMVs returning rows for all databases except one? -

Image
i trying query dmvs in sql server 2008 r2. on server 2 user databases called histrx , openlink . prove have names correct: select db_id('histrx') -- returns 5 select db_id('openlink') -- returns 7 if run following query, picking out entries histrx database, 25 rows in result set: select top 25 total_worker_time/execution_count avg_worker_time, total_logical_reads/execution_count avg_logical_reads, db_name(s.dbid) [db_name], object_name(s.objectid, s.dbid) [object_name], execution_count, plan_generation_num, last_execution_time, creation_time, [text], p.query_plan sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text(qs.plan_handle) s cross apply sys.dm_exec_query_plan(qs.plan_handle) p db_name(s.dbid) = 'histrx' order avg_logical_reads desc if change where clause following, no rows returned: where db_name(s.dbid) = 'openlink' i know there significant amount of ac

gis - Compass direction (North, West ...) of polygon in R -

i have polygon of gis object,e.g. rectangle. extract of edges according compass orientation. how can that? here simple example poly = polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) polygons = polygons(list(poly), "s3") spp = spatialpolygons(list(polygons)) plot(spp) the upper edgs eg. related north. how can identify via script?

If inputs exist, dont insert, else insert PHP mysql -

i've started php, , wondered if can help. have this $sql="insert $tbl_name set date='$mydate' , event='$myevent'"; $result=mysql_query($sql); i need know how make see if event exists, , if need nothing, if doesn't insert it! split 2 queries: 1) check if event exists. if yes nothing, else insert new event 2) continue query. way event allays exist when inserting data

regex - How can I get digit after 0 with php -

i have number following format. 100034, 100345, 103456, i want digit after 0 this. 34, 345, 3456 how can get?help me plz. how using modulo maths: $str = '103456'; $n = (int) $str % pow(10, strlen($str)-1); // 3456

performance - Measuring execution time in the D language -

i'm new d language , need measure execution time of algorithm. options? there built-in solution? not find conclusive on web. one way use -profile command line parameter. after run program, create file trace.log can find run time each function. of course slow down program compiler insert time counting code each function. method used find relative speed of functions, identify should optimize improve app speed minimum effort. second options use std.datetime. stopwatch class. see example in link. or better suited might directly use std.datetime. benchmark function. don't forget: when benchmarking use these dmd compiler flags achieve maximum optimization -release -o -inline -noboundscheck . never benchmark debug builds. make sure don't call library code inside benchmarked functions - benchmarking performance of library implementation instead of own code. additionally may consider using ldc or gdc compilers. both of them provide better optimizat

currency - Rails 2 - Absolute of money -

how absolute value of money? e.g: -2.to_money.? = 2.to_money 2.to_money.? = 2.to_money i have attribute total_price , may positive or negative. want calculate absolute value of total_price. try taking absolute value before converting money. 2.abs.to_money

ios - Set exclusive touch on multiple UIViews of the same class -

i creating random number of custom uiviews of same class, , i'm adding them in uiviewcontroller's view. i'm assigning them uitapgesturerecognizer, can't seem make exclusive touch work: for (int = 0; <= n; i++) { iccatalogproductview *catalogproductview; catalogproductview = [[iccatalogproductview alloc] init]; [self.view addsubview:catalogproductview] uitapgesturerecognizer *tapgesture = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(testtouch)]; [catalogproductview addgesturerecognizer:tapgesture]; [catalogproductview setexclusivetouch:yes]; } if tap uiviews simultanously, method called twice (not behaviour want). there elegant method of solving this, or method @ all? from apple documentation: exclusivetouch prevents touches in other views during time in there's active touch in exclusive touch view. is, if put finger down in exclusive touch view touches won't start in other views until lift

php - Display data in Android with the help of web service -

i trying display data in android of php web service, think problems code data not displayed. giving here code of both file code of web service : <?php $dbhandle = mysql_connect($hostname, $username, $password,$datbase_name) or die("unable connect mysql"); $selected = mysql_select_db("code_lessions",$dbhandle) or die("could not select examples"); $final_data = array(); $query="select * lessiondetail"; if ($query_run = mysql_query($query)) { $i=0; while($query_row = mysql_fetch_assoc($query_run)) { $username = $query_row['lessionname']; $password = $query_row ['categoryname']; $id = $query_row ['lessionid']; //echo $username .'`s password : '. $password.'<br>'; $data = array('lessionid'=>$id , 'lessionname'=>$username ,'categoryname'=>$password);

javascript prototype throw the error as "Object [object Object] has no method" -

i doing prototype inheritance method test.. getting error, after copied instance existing object... what wrong here.. my test : var human = function(name){ this.name = name; } human.prototype.say = function(){ alert(this.name); } var male = function(gender){ this.gender = gender; } male.prototype.gender = function(){ alert(this.gender); } var inst1 = new human('nw louies'); inst1.say(); var inst2 = new male("male"); inst2.prototype = new human("sa loues philippe"); //i copying instance of human inst2.gender(); inst2.say(); // throw error "undefined" what wrong here.. 1 me understand mistake? live demo here you need say var male = function(gender){ this.gender = gender; } male.prototype = new human(); don't forget need set name property of male objects. expose setname method on human , call in male constructor function, example.

jquery - AJAX Posting ValidateAntiForgeryToken without Form to MVC Action Method -

i've been looking @ examples of how on , far can tell i've tried examples can find no success far. i've tried altering of implementations scenario has far failed well. i have on page in _layout.cshtml have token available: <form id="__ajaxantiforgeryform" action="#" method="post"> @html.antiforgerytoken()</form> i have method in javascript utils file: addantiforgerytoken = function (data) { data.__requestverificationtoken = $('#__ajaxantiforgeryform input[name=__requestverificationtoken]').val(); return data; }; this working expected , anti forgery token. actual posting code is: mypage.savedata = function() { var saveurl = '/exercises/postdata'; var mydata = json.stringify(mypage.contextsarrays); $.ajax({ type: 'post', async: false, url: saveurl, data: addantiforgerytoken({ myresults: mydata }), success: function () {

html - vertical-align doesn't center the text -

Image
i have following css: #header-notification { color: #7b6f60; font-size: 13px; font-weight: bold; float: left; text-align: center; vertical-align: middle; height: 20px; width: 20px; background-color: #e5e5e5; } and declared label as: <label id="header-notification"></label> however doing gives me following: as can see text here not vertically centered. doing wrong? as using single character align vertically, can use line-height property here vertically align in middle of element demo #header-notification { color: #7b6f60; font-size: 13px; font-weight: bold; float: left; text-align: center; vertical-align: middle; height: 20px; width: 20px; background-color: #e5e5e5; line-height: 20px; } for making vertical-align: middle; work, need use display: table-cell; align middle vertically.. won't need here specified trying align single character. display: ta

c - Search g_slist_find_custom() function in GLib -

how use g_slist_find_custom() , when im working single list. , every node of list structure. typedef struct { int number; int price; char* title; }books; gslist *list =null, g_slist_find_custom(list, /*?*/, (gcomparefunc)compp/*?*/); you can find items in gslist using function compare: gint comp(gpointer pa, gpointer pb) { const books *a = pa, *b = pb; /* compares title, can compare index or price */ return strcmp(a->title, b->title); } gslist *list = null; books temp, *item, *abook = g_malloc(sizeof(books)); strcpy(abook->title, "don quijote"); list = g_slist_append(list, abook); /* more code */ temp.title = "don quijote"; item = g_slist_find_custom(list, &temp, (gcomparefunc)comp); /* item contains abook */ furthermore can compare constants using null second parameter: gint comp(gpointer p) { const books *x = p; return strcmp(x->title, "don quijote"); } item = g_slist_find_custom(list,

php - Facebook app in tab, how to create a link/button to like the page -

i'm creating facebook app php sdk, displayed in tab. it's contest, , check if user likes page. if does, gets see contest immediately, if doesn't, should see custom button, page. i've been searching long time , haven't found out how can create custom button/link page. if point me right direction, fantastic.

highcharts - Is it possible to select a different color for one candlestick? -

usually candlesticks bars 2 differentiating colors: blue , white or red , green in pairs etc...however, know if possible highlight 1 of candlestick bars within chart third color? let chart has selection color pair blue , white , color last candlestick in chart red. possible? you can add point object , define color. http://jsfiddle.net/sbochan/gydue/ { x: 1147910400000, open: 65.68, close: 66.26, low: 63.12, high: 63.1, color: 'red' }

indexing - Why isn't SQL Server using my index? -

in our database have table 200.000 rows create table dbo.usertask ( usertask_id int not null identity (1, 1), usertask_sequencenumber int not null default 0, usertask_identitat uniqueidentifier not null, usertask_subject varchar(100) not null, usertask_description varchar(500) not null, ..... ..... constraint [pk_usertask] primary key clustered ( [usertask_id] asc ) on [primary] ) on [primary] i have created index on usertask_identitat column with create nonclustered index ix_usertask_identitat on dbo.usertask ( usertask_identitat ) executing following query, execution plan shows index on usertask_identitat used query: select usertask_id usertask usertask_identitat = @identitat order usertask_lastsendsystemdatetime desc but if add column in select list, index not used select usertask_id, usertask_sequencenumber, usertask_identitat, ....., usertask_subject usertask usertask_identitat

javascript - Angular-UI dropdown doesn't open -

i'm generating html javascript object. example have following object: var e = [{'element' : 'button', 'innerhtml' : '<span class="dropdown-toggle">more<span class="caret"></span></span><ul class="dropdown-menu"><li>menu item</li></ul>', 'attrs' : {'class' : 'btn dropdown'}}]; and js function generates following string $scope.my_template : <button class="btn dropdown"> <span class="dropdown-toggle">more <span class="caret"></span> </span> <ul class="dropdown-menu"> <li>menu item</li> </ul> </button> than i'm trying apply template html page with: <div ng-bind-html-unsafe="my_template"> </div> i see dropdown button in page when i'm clicking on it, doesn't open.

mysql - Clearing DataTable Automatically Before Filling -

i had quick question. i'm new .net. there way set datatable clear everytime before fill it? looking @ tableadapter , saw 'clearbeforefill property' , thinking existed dataadapter or datatables specifically. 'construct query dim queryaccountdata$ = "select * " & tablename & " accountnumber=" & accountnumber 'execute query , fill datatable in dataset using adapter new mysqldataadapter(queryaccountdata, connection) adapter.fill(ds, "holdings") end using ds.tables("holdings") 'assign variables rows_lastindex = .rows.count - 1 if rows_lastindex = -1 throw new applicationexception("account number not found in database") etc.... thanks!

jquery - Submenu on click -

i found question jquery show submenu if parent have been clicked here on stackoverflow. made jsfiddle, http://jsfiddle.net/jtaeh/4/ try out css , html. worked! in wordpress theme i'm using, they've got script overrules new custom script. is possible overrule script in parent theme custom script in child theme in elegant manner? or else: how can change script: var mobile_menu = function() { if( $(window).width() < 600 && $('body').hasclass('responsive') ) { $( '#nav > ul, #nav .menu > ul' ).mobilemenu({ submenudash : '-' }); $( '#nav > ul, #nav .menu > ul' ).hide(); } } mobile_menu(); var show_dropdown = function() { var options; containerwidth = $('#header').width(); marginright = $('#nav ul.level-1 > li').css('margin-right');

code completion in pydev (eclipse) when the variable type is unknown -

for varible type unknown (not during runtime), codecomplete following statement working assert isinstance(variable, class) variable. {codecomplete works} while following statement not assert isinstance(self.variable, class) self.variable. {codecomplete not working} how make codecomplete work "self.*" variables?

c# - How to download large files, stored in database...fluent nhibernate -

using: c#, .net 3.5 web forms application, fluent nhibernate 1.1.0.685, sql server 2008r2 i have web app allows users upload files , attach them "cases" working. files stored in database varbinary(max). here code i'm using download files: ... if (!siteuserservice.haspermission(domain.siteuserservice.sitepermissions.modifycase, currentuser)) this.accessdenied(); string attachmentid = request.querystring["f"].tostring(); downloadfileresponse response = caseservice.retrieveattachment(attachmentid, currentuser.id); downloadattachment(response.attachment.contenttype, response.attachment.filename, response.filebytes); ... protected void downloadattachment(string mimetype, string filename, byte[] file) { response.clear(); response.contenttype = mimetype; response.addheader("content-disposition", string.format("attachment;filename=\"{0}\"", filename)); response.binarywrite(file); response.flush();

rails 4 modelname_params doesn't exist -

i trying make contact form in rails 4 , ruby 2. i've added model , migrated db , made form etc, code gives error. @newsupport = support.new(support_params) adminmailer.contact_email(@newsupport.name, @newsupport.email, @newsupport.subject, @newsupport.message).deliver rails debugger says that: undefined local variable or method `support_params' #<maincontroller:0x007f9f8a0dcb28> why support_params undefined? can define it? didn't scaffold it, when scaffold, saw can link form values variable in controller via "modelname_params", in case undefined. thanks reading. it's wanting use strong_parameters ( http://weblog.rubyonrails.org/2012/3/21/strong-parameters/ ) sanitize params in controller. not sure why undefined, should defined in controller private method. private #assuming you're using params[:support] def support_params params.require(:support).permit(:attributes, :you, :want, :to, :allow) end

url rewriting - Newrelic isn't recognizing my Slim PHP routes -

i have set new relic on php web app. working great except 1 thing... of transactions show going through "index.php". the reason because i'm using slim framework (there are many alternatives for routing ) url rewriting can have nice human urls "/user/settings" without folder every controller , action. but still leaves me index.php name every new relic web transaction. you can use hook set transaction name name or pattern of router. here example setting pattern: $app->hook('slim.before.dispatch', function() use ($app) { newrelic_name_transaction($app->router()->getcurrentroute()->getpattern()); });

php - Easier way than using a switch case to change color -

on website , use switch case give color navigation bar's active link. i first declared array $case possible links in navigation bar. then, check see if it's function clicked on 1 of pages (if query string isn't empty) and if put $case array (to keep changing color when other links inside other pages clicked.) if true, $current value docs_zamo or akuut_wgakuut --> filename_query. want change color when have declared before (in $case array) otherwise, filename (without '.php') i find piece of code rather unwieldy. there way job? i'm pretty new php. thought; if there's function checking whether case exists inside switch, wouldn't need $case array, because would've declared existence of link inside switch case already. the code check if it's filename_query link: $case = array("index","medica","praesidium","akuut","sponsors","docs","docs_zamo","kalender&

.net - How do set IMessageFormatter when using the Send method of IBus in NServiceBus? -

i sending object msmq via nservicebus: public void sendmessage(availinfo message) { var bus = configure.with() .defaultbuilder() .log4net() .usetransport<msmq>() .xmlserializer() .unicastbus() .createbus() .start(() => configure.instance.forinstallationon<windows>().install()); bus.send(message); } everything working fine, except consumer of queue requesting explicitly use activexmessageformatter. question: how/where set when sending message in snippet above. thanks in advance! the nservicebus message formatter supposed used messaging endpoints communicate each other. there 4 built nservicebus: xml (default, not same .net xmlserializer), json, bson, , binary. the activexmessageformatter system.messaging class , not related formatters above. it sounds you're trying use nservicebus client api msmq, , that's not is. technically implement own message formatter

c# - Structuring Task Processing Pipeline with the Task Parallel Library -

i come objective-c background, use grand central dispatch or nsoperations solve problem trivially. unfortunately think i'm stuck in way of thinking when trying structure problem in c#. i have high-level tasks, each of have multiple parts can happen in parallel. each of these parts need go through several stages in pipeline. need construct pipeline, know when high-level task completes, , execute callback. with gcd, create queues perform parts on, each chaining next part of process. of these parts grouped based on high level task part of, callback triggered @ end. i'm struggling work out how work in c#. i've been researching task parallel library, have no particular preference use. 1 issue have run far completion callbacks seem possible tpl pipelines if finish processing, have multiple tasks wouldn't happen. at overview sort of level, how problem best structured? wonder if might better write system rx providing concurrency? i don't quite understa

c# - Creating non visual-component vs2012 -

i switched vs2012 , c# month delphi i'm having problem. i started creating class talk plc via serial port , works fine convert non-visual component , can drag , drop form instead of having add .cs file use. i've created usercontrol in case want non-visual component (so should inherit component ) timer example. i've looked around on google can't find relate or explains me how it. can point me in right direction. why not encapsulate functionality in class, , add code reference class? update seems can add custom dll toolbox, , decorate this. disclaimer, have not tested this... [toolboxbitmap(@"d:\targetbitmap.bmp")] public class customgridview : gridview {

c# - Is a singleton constructor idempotent? -

i'm still trying grasp both concepts, if i'm misunderstanding kindly explain. i've read few sources on idempotent operations (namely so entry ) , yesterday senior dev @ workplace sent article around singleton's. while reading singleton article wondering, constructor object implements singleton pattern idempotent? my understanding because calling singleton.instance() (v. 6 singleton article) more 1 time not change because singleton cannot instantiated more once, i'm not entirely sure if i'm combining 2 topics correctly. when operation described idempotent means calls made same parameters should result in no additional state change. example, in rest api delete request idempotent means if make subsequent requests delete resource , it's gone still success back. users point of view appears has happened, system isn't changing it's acknowledging request i.e. user: "please delete resource a" system: "check status of re

java me - extract text from HTML textbox using j2me -

i know question might sound silly there way extract text html textbox using j2me . you can use java html dom parser library. recommend jsoup: java html parser . download library file here . documentation located here .

Add a MySQL field of type "bit" to a FuelPHP model -

my schema has column of type "bit(1)". haven't found way can expressed in fuel. don't seem support "bit" type , can't build insert queries. is there way (possibly undocumented) fuel support this? hmm... orm supposedly accepts bit field. i have created model database. migration script , model, maybe can you. model class model_test extends \orm\model { protected static $_properties = array( 'id', 'whatever', ); protected static $_table_name = 'tests'; } migration script builded existing table using command: oil refine fromdb:model test namespace fuel\migrations; class create_tests { public function up() { \dbutil::create_table('tests', array( 'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true), 'whatever' => arr

parse.com - Is there an Android equivalent of iOS' UIViewContentModeScaleAspectFit; -

i've got image loaded parse.com , on xhdpi , xxhdpi devices, image displayed tiny. i've tried playing xml layout. can stretch background image border downloaded image full width of screen. height of image never exceeds physical size of image stored on parse. i'm trying image scale fit width of device on, while maintaining aspect ratio. i'm using parseimageview subclass of imageview. accomplished on ios resizing image fill width, , setting imageview.contentmode=uiviewcontentmodescaleaspectfit; there equivilant android? you can achieve using picasso library. using picasso library, can width , height of image web casting bitmap , scaling imageview aspect ratio. related post below: getting image width , height picasso library

how to change the type of a field in a model(a table) of the official module (hr) OpenERP -

i wanna use official hr module, wanna use own fields. need change type of many fields. eg. in hr.employee, wanna change field:address_home_id type "many2one" "char". how can ? i know 2 ways: first:settings->custom->model->edit.. seems change correctly, not changed in view. second: go source of module;change code: 'address_home_id': fields.many2one('res.partner.address', 'home address'), to 'address_home_id': fields.char('home address',size=32), but when create new record, failed! can tell me how right? thank in advance! you can postgresql side. doing wrong. there many other relations or field related other records, cause error. try add new fields it.

Jquery UI sliders - 2 working together to calculate an amount -

i've got 2 jquery sliders , when them working break. first slider measures weight, , second exercise. i'm trying code final value, 'outcome' displays outcome of both. when 1st weight slider increases, outcome value. when 2nd exercise slider increases, final outcome goes down. i'm using simple number values until head around it, how them working together? $(function() { $( "#slider_1" ).slider({ value:100, min: 0, max: 500, step: 50, slide: function( event, ui ) { $( "#amount" ).val( "+" + ui.value ); } }); $( "#amount" ).val( "+" + $( "#slider_1" ).slider( "value" ) ); }); $(function() { $( "#slider_2" ).slider({ value:100, min: 0, max: 9, step: 5, slide: function( event, ui ) { $( "#amount2" ).val( "+" + ui.value ); } }); $( "#amount2"

string - endsWith in JavaScript -

how can check if string ends particular character in javascript? example: have string var str = "mystring#"; i want know if string ending # . how can check it? is there endswith() method in javascript? one solution have take length of string , last character , check it. is best way or there other way? update (nov 24th, 2015): this answer posted in year 2010 (six years back.) please take note of these insightful comments: shauna - update googlers - looks ecma6 adds function. mdn article shows polyfill. https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/endswith t.j. crowder - creating substrings isn't expensive on modern browsers; may have been in 2010 when answer posted. these days, simple this.substr(-suffix.length) === suffix approach fastest on chrome, same on ie11 indexof, , 4% slower (fergetaboutit territory) on firefox: jsperf.com/endswith-stackoverflow/14 , faster across board when result fal

Resizing a excel pasted object in powerpoint with vba -

i've cobbled vba script (i'm no expert, kind folks around here, i've been able , working) copy multiple excel sheets powerpoint file (used template, see code. sub atestpptreport() dim ppapp powerpoint.application dim ppslide powerpoint.slide dim pppres powerpoint.presentation set ppapp = createobject("powerpoint.application") dim slidenum integer dim ppshape powerpoint.shape set xlapp = getobject(, "excel.application") ''define input powerpoint template dim strprespath string, strexcelfilepath string, strnewprespath string ''# change "strprespath" full path of powerpoint template strprespath = "c:\template.ppt" ''# change "strnewprespath" want save new presentation created strnewprespath = "c:\macro_output-" & format(date, "dd-mmm-yyyy") & ".ppt" set pppres = ppapp.presentations.open(strprespath) pppres.application.activate ppapp.vis

javascript - How select default option of dynamically added dropdown list -

i string server using jquery: <option value='1'>1</option><option value='2'>2</option> <option value='3'>3</option><option value='4'>4</option> then create dropdown within div: $.get('server.php', function(data) { $('#mydiv').html('<select id="mysel" name="mysel">'+data+'</select>'); }); problem when create this, want select 1 option so: $("#mysel").val("3"); but doesn't work! if add alert before calling line, works! alert('test'); $("#mysel").val("3"); can not find problem. note: can not change way data server. assuming line $("#mysel").val("3"); outside of $.get() {} ... the response $.get asynchronous $("#mysel").val("3"); executes before html <option> elements added. adding alert() delays execution

scala - Conditional trait mixins -

say have class a should mixed in trait b , b should either b1 or b2 based on flag b1 : val b1: boolean type b = if (b1) b1 else b2 // impossible scala code class extends b is there way "dynamically" mixin trait based on condition? types static things definitions fixed @ compile time. can create instances of variant anonymous classes using if / else logic, though: val = if (b) new b1 else new b2

c# 4.0 - How to change value in listview of lable in asp.net -

hello need listview control here listview code below: <asp:listview runat="server" id="listview1" groupitemcount="3" onitemcommand="listview1_itemcommand"> <layouttemplate> <div> <asp:placeholder runat="server" id="groupplaceholder" /> </div> </layouttemplate> <grouptemplate> <div style="clear: both;"> <asp:placeholder runat="server" id="itemplaceholder" /> </div> </grouptemplate> <itemtemplate> <div class="store-l"> <p class=&quo

android - Single method to implement onTouchListener() for multiple buttons -

i trying see if there way create single method implement touch listener multiple buttons, seeing have quite few buttons same thing. difference in message send through sendmessage() method, , how long button needs held down message sent. if there way it, might be? , also, why wouldn't work? //within oncreate method... button mbutton = (button) findviewbyid(r.id.three_sec_button); mbutton = addtouchtimer(mbutton, 3, 3); calls - private button addtouchtimer(button button, final int sec, final int messagenum){ button.setontouchlistener(new view.ontouchlistener() { boolean longenough = false; long realtimeleft = sec * 1000; @override // make message sent if button held down 3 seconds // otherwise won't send. sent during hold down process, releasing returns false // value , no message sent. public boolean ontouch(view arg0, motionevent arg1) { log.d("button"

Soap web-service not working (PHP) -

i have looked on stack overflow , found couple threads related did not solve problem. also, it's worth, ltl carrier name of estes trying work through. here's code i'm using: $url = "http://www.estes-express.com/rating/ratequote/services/ratequoteservice?wsdl"; $username = 'un'; $password = 'pw'; $client = new soapclient($url); //prepare soapheader parameters $cred = array( 'user' => $username, 'password' => $password ); $headers = new soapheader('http://ws.estesexpress.com/ratequote', 'auth', $cred); $client->__setsoapheaders($header); $params = array( "requestid" => "20131724", "account" => "9252066", "originpoint" => array('countrycode' => 'us', 'postalcode' => "43537"), &quo

sendmail - Incoming E-mail intercepted by PYTHON's ( sys.stdin.read(1024) ) is missing title and body content -

i use /etc/aliases redirect incoming emails username "ooo" python script ( handled sendmail ) ooo: "|/usr/bin/python /2/a.wsgi" this a.wsgi looks like. import os import sys = sys.stdin.read(1024) f = open('/2/email.txt','w') f.write(a) i sent test e-mail myself yahoo e-mail account whole title , body missing. on purpose created long title consisting of lot's of o's , body consisting of lot's of o's multiple lines see it. when intercepted e-mail python.. email.txt file looks like. [root@a 2]# cat email.txt a*****@ymail.com thu jul 25 09:41:49 2013 received: nm23-vm1.bullet.mail.bf1.yahoo.com (nm23-vm1.bullet.mail.bf1.yahoo.com [98.139.213.141]) domain.tld (8.14.4/8.14.4) esmtp id r6p9fm88005190 <ooo@*****.tld>; thu, 25 jul 2013 09:41:48 gmt received: [98.139.215.142] nm23.bullet.mail.bf1.yahoo.com nnfmp; 25 jul 2013 17:26:26 -0000 received: [98.139.212.228] tm13.bullet.mail.bf1.yahoo.com nnfmp

rollback/cancel the android-gcm notification -

is there way rollback notification request placed gcm server? as in, consider gcm-message-request placed gcm server. if user sees message in web before coming online in mobile, gcm request should rolled back. , user should not see notification in mobile. there no built in mechanism such rollback in case describe. can try implementing - when server notices message viewed in web, can send gcm message device data represents need rollback. when process message, should clear notifications created app on device (i'm not sure if that's possible, you'll have check). there such mechanism in similar case - if user has multiple android devices, , send gcm message of them (using new user notifications feature), once user views notification on 1 device, automatically removed other devices. if message has been handled on 1 device, gcm message on other devices dismissed. example, if user has handled calendar notification on 1 device, notification go away on user

c++ - vector iterating over itself -

in project have vector wit relational data (a struct holds 2 similar objects represent relationship between them) , need check relationships combinations between data in vector. what doing iterating on vector , inside first loop iterating again relationships between data. this simplified model of doing for(a=0; a<vec.size(); a++) { for(b=0; b<vec.size(); b++) { if(vec[a].something==vec[b].something) {...} } } my collection has 2800 elements means iterating 2800*2800 times... what kind of data structure more suitable kind of operation? using for_each faster traversing vector this? thanks in advance! vec has 2 structs made of 2 integers , nothing ordered. no, for_each still same thing. using hash map make problem better. start empty hash , iterate through list. each element, see if it's in hash. if it's not, add it. if is, have duplicate , run code. in c++, can use std::map. in c, there no built in map datastructur

jquery - SlideDown once* then Animate depending on clicks. -

my code both animations simultaneously. slidesdown animate div i slidedown animation occur first, , when complete, animation. note: first slidedown animation occurs once , while remaining animations reoccurring . i.e: clicking on other tags. p.s: have tried doing callback stops remaining code working due me wanting do first slidedown animation once. please see jsfiddle demo proper demo. thanks in advance! please have @ code below. have left comments reference. $(function() { var content = $('#content'), contentheight = content.height(), nav = $('#nav'), count = 0; // on load content height shorter content.height(100); nav.find('a').on('click', function() { var $this = $(this), parent = $this.parent(), targetelement = $this.attr('href'); //does slide down animation once if (count === 0) { content.animate({'he

Java BoxProject using two classes -

im trying code print out new boxes based on original box class , im stuck. not sure variables need specify in grid class. nor know put in following class. public void actionperformed(actionevent evt) { // maybe stuff here repaint(); } here both of classes. ---the code has been updated since first reply--- box class import java.awt.*; public class box{ int upperleftx = 0; int upperlefty = 0; int height = 20; int width = 20; color color = color.red; //constructor public box(int i, int j, int k, int l, color m) { upperleftx = i; upperlefty = j; height = k; width = l; color = m; } // paints box on screen public void display(graphics g) { g.setcolor(color); g.fillrect(upperleftx,upperlefty,width, height); } // getters , setters public int getupperleftx() { return upperleftx; } public void setupperleftx(int upperleftx) { this.upperleftx = upperleftx; } public int getupperlefty() {

c# - i want to make conditional trigger in sql server...... -

i have table named test , table named trigg..... want is.... whenever data having 'name' 'rakesh' being inserted test...it should fire trigger insert age in 'trigg' table.... i tried self.... chk it... create trigger trigger1 on test after insert if((select name test) 'rakesh') begin insert trigg(age) select name test end but didnt worked.. whenever inserting in test ..getting error : subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. help me out.... you selecting test when should selecting inserted . want statements take effect based on being inserted, not based on table may contain. even after changed, trigger fires once per statement, not once per row. if insert affects multiple rows, inserted pseudotable contain multiple rows, , subselect therefore fail. suggested revision: create trigger trigger1 on test after insert if exists (sel

php - Get insights from specific page -

i'm trying insights out specific facebook-page, doesn't matter, user request page. can't figured out how it. i've made code insights user-accesstoken generated in graph explorer. require 'facebook/src/facebook.php'; $facebook = new facebook(array( 'appid' => '551080774957462', 'secret' => 'f821960b551440b80eecd2dc0a0eff2e', )); //accesstoken graph explorer $user_access_token = "caah1nh3vezaybagbezaemgwwloxkkmuqtutbxt6kao........"; $facebook->setaccesstoken($user_access_token); $facebook->getuser(); //gets pages $user_accounts = $facebook->api("/me/accounts/"); $pageaccesstoken = ""; //find right page foreach ($user_accounts["data"] $page) if ("476015619078252" == $page["id"]) $pageaccesstoken = $page["access_token"]; $facebook->setaccesstoken($pageaccesstoken); $insights = $facebook->api("

javascript - Altering Specific Text with jQuery -

here html/php: <p> <span data-good="<?php echo $row['good']; ?>" data-wasvoted="<?php echo $row['wasvoted']; ?>" data-review="<?php echo $row['review_id']; ?>" class="upvote">votes (<span class="good"><?php echo $row['good']; ?></span>)</span> </p> this looks mess, apologize test code. to user in output: votes (3) // 3 example number. this clickable. want user click on it, , if have voted on this, 3 becomes 2. if have not, 3 becomes 4. determined data-wasvoted attribute. 1 if have , 0 if haven't. (there styling user can identify if have upvoted or not). sending info server , getting need set up. can't figure out way grab right number since looped list of generated html. there string of dynamic vote buttons. here jquery: var review_id = $(this).data('review'); var was_voted = $(this).data('was