Posts

Showing posts from May, 2010

python - How websites identify my web browser doesn't have the plugin installed? -

i trying scrape things out of website. whenever access website using curl or python-requests, keeps showing me that,i need install plugin continue. when use web browser has plugin installed , works fine. i want understand, how website identifies web browser has plugin installed or not?

mysql - Fast selection of a block of following records -

is there implementation of sql database allowing select table block of n following records -- in respect of index -- starting specified index, performance o(n + log tables_size) ? allowing adding record in o(log tables_size) . if so, how it? i'm dreamer but, possible mysql? if id primary key on table, following return in order of time needed fetch records, plus initial index seek: select t.* t id >= someid order id limit <n>; adding record consists of 2 parts. first part finding available space , second part inserting index. b-tree index should require o(log table_size) insert. if pages full , inserting @ end of table, finding right page constant time. in other words, if understand question correctly, primary key clustered indexes asking for.

c# - Format price in Danish with curency symbol on right -

how can format price in eval() method price in danish , currency symbol on right c# ? i have following in .aspx page display price: <td class="text-right price-col"><%# eval("price", "{0:c}") %></td> but display price e.g. kr. 79,00 .. want 79,00 kr. i saw post changing currency symbol location in system.globalization.numberformatinfo , added method in codebehind gives me result want: <td class="text-right price-col"><%# priceformat(79) %></td> protected string priceformat(decimal price) { system.globalization.cultureinfo danish = new system.globalization.cultureinfo("da-dk"); danish = (system.globalization.cultureinfo)danish.clone(); // adjust these suit danish.numberformat.currencypositivepattern = 3; danish.numberformat.currencynegativepattern = 3; decimal value = price; string output = value.tostring("c", danish);

php - How to sort an SplFixedArray? -

is there way perform sorting on integers or strings in instance of splfixedarray class? converting php's array , sorting, , converting being option? firstly, congratulations on finding , using splfixedarrays! think they're highly under-utilised feature in vanilla php ... as you've appreciated, performance unrivalled (compared usual php arrays) - come @ trade-offs, including lack of php functions sort them (which shame)! implementing own bubble-sort relatively easy , efficient solution. iterate through, looking @ each consecutive pairs of elements, putting highest on right. rinse , repeat until array sorted: <?php $arr = new splfixedarray(10); $arr[0] = 2345; $arr[1] = 314; $arr[2] = 3666; $arr[3] = 93; $arr[4] = 7542; $arr[5] = 4253; $arr[6] = 2343; $arr[7] = 32; $arr[8] = 6324; $arr[9] = 1; $moved = 0; while ($moved < sizeof($arr) - 1) { $i = 0; while ($i < sizeof($arr) - 1 - $moved) { if ($arr[$i] > $arr[$i + 1]) {

javascript - setTimeout produces a scope error -

my question simple. i'm using settimeout inside loop, during runtime error produced saying: uncaught typeerror: cannot call method 'setattribute' of undefined my experience javascript slim (i'm skipping jquery sake of learning) , assume has way i'm calling settimeout. take @ function, know why "elements" not available inside anonymous function. function hide_visable_elements() { // remove body eventlistener var body = document.getelementsbytagname("body"); body[0].removeeventlistener("click", hide_visable_elements, true); var elements = document.getelementsbyclassname("visible"); (var = 0; < elements.length; ++i) { elements[i].removeattribute("class"); settimeout(function() { elements[i].setattribute("class", "hidden") }, 300); } } here's example of how capture current value of iteration when executed after loop has completed (it

android - how to get the number of the most frequent value entry in callLog.calls? -

call log calls entry - name number type date called - jed 12345 incoming 7-18-2013 - roger 14611 incoming 7-18-2013 - jed 12345 incoming 7-18-2013 - jed 12345 incoming 7-18-2013 - kevin 11111 incoming 7-18-2013 hi, want query in android such retrieve jed, 12345 << since has repetitive value in list, im suppose in sqlite (android query) dont know functions invoke code used, able recent number called instead of 1 entries. how do query? date date=new date() ; cursor c = contxt.getcontentresolver().query(calllog.calls.content_uri, null, calllog.calls.type + " , " + calllog.calls.incoming_type + " , " + calllog.calls.date + ">=" + date.getdate() , null, calllog.calls.date + " desc limit 1"); if(c!=null) do{ int ca

wpf - how to pass composite object to view model -

i'm using mvvm light wpf. currently can pass string parameter viewmodel's command below: <textbox height="23" textwrapping="wrap" text="textbox" name="textbox1"/> <button command="{binding showmessage}" content="click me" commandparameter="{binding elementname=textbox1, path=text}" /> my question how pass composite type person command of viewmodel? thanks <textbox height="23" textwrapping="wrap" text="textbox" name="textbox1" tag="{binding person}"/> <button command="{binding showmessage}" content="click me" commandparameter="{binding elementname=textbox1, path=tag}" /> you can make use of tag property of textbox think there wrong mvvm implementation,it viewmodel holds data view. here sending view vm . mean person should automatically there in vm instead of sending view.

Jquery before() with animation -

i'm trying make appear result of ajax request using before(). works well, i'd make appear result animation (toggle, slidedown or something). here code use: jquery.ajax({ type: "post", url: "/postcom", datatype:"text", data:mydata, success:function(response){ $("#results_com").before(response); $("#formcomtext").val(''); }, error:function (xhr, ajaxoptions, thrownerror){ console.log(thrownerror); } }); html: <div id="results_com></div> thanks if use insertbefore , might easier: $(response).insertbefore("#results_com").animate({}, 400);

c++ - How does compiler allocates memory to this struct? -

this question has answer here: structure padding , packing 8 answers i trying use namespaces , structs & encountered issue. c++ #include<iostream> using namespace std; namespace 1 { struct data { int val; char character; }; } namespace 2 { struct data { int val; bool boolean; }; } void functionone(void) { using namespace one; cout << "functionone()" << endl; cout << "the size of struct data : "; cout << sizeof(data) << endl; } void functiontwo(void) { using namespace two; cout << "functiontwo()" << endl; cout << "the size of struct data : "; cout << sizeof(data) << endl; } int main() { functionone(); functiontwo(); } output functionone() size of struc

Android - ExpandableListView isn't showing the groupIndicator icon -

i have expandablelistview in xml , i'm setting adapter custom baseexpandablelistadapter. xml: <expandablelistview android:id="@+id/expanlist_estatisticaarsenal" android:divider="@null" android:layout_width="fill_parent" android:layout_height="fill_parent" android:transcriptmode="alwaysscroll" android:cachecolorhint="#000000" android:listselector="@android:color/transparent" android:visibility="gone"> </expandablelistview> android:visibility="gone" because make visible after stuff adapter custom class: public class adapter_expanestatistica extends baseexpandablelistadapter { private context c; private list<blocoarsenal> listblocos; public adapter_expanestatistica(context ctx, list<blocoarsenal> listblocos) { c = ctx; listblocos = listblocos; } @override public vie

Can't play audio in Android device -

i want make : <audio controls> <source src="media/blablabla.mp3" type="audio/mpeg"></source> </audio> i run app on local host :8080/console , worked (the music can played). when run apps on device, music can't played. my device os android 4.1.2 see question answer: ibm worklight 6.1 - unable play local media file using cordova copy-paste of answer: ... playing local media file, need provide full path media file's location where it'll in generated android project . example, if create common\audio folder in worklight application , place .mp3 file in it, need use following path (in html or javascript, or you'd like...): <a href="#" onclick="playaudio('/android_asset/www/default/audio/mymediafile.mp3');">play audio</a> sample project: android cordova media api

html - Relative DIV with auto width -

i have div image , label in it. label must ontop of image made outer container div relative . but want container div has same width image. can set 100% width on label. don't know width of image before hand. loaded dynamically. but container div has 100% width set it. there way let have width of image inside? example: http://jsfiddle.net/sbnzu/391/ do 1 of following rules container: add display:inline-block add float:left either shrink container div fit contents.

vb.net - Send webrequest after spliting data in Listbox in ":" format -

hello have listbox contains different lines in user:pass format how can split them in such way to send webrequest each item in listbox . have tried send request first item in listbox want send webrequest items in . for each item in listbox1.items dim z = item.split(":").getvalue(0) dim zz = item.split(":").getvalue(1) next put webrequest inside loop , use , dim z() string = item.split(":") . z(0) user , z(1) pass , change each iteration of loop. a suggestion though, dictionary(of string, string) might better storage option data, since won't expose straying eyes. or listview 2 columns. using view option, list, show first column, data second column still accessible. update: a dictionary collection of key,value pairs. if want can think of in terms of array. array can described being collection of key,value pairs. index of item key , value of item value. dictionary works same way, additional flex

how to use: from __future__ import division with django -

i'm trying use __future__ import division django operation won't work in views.py. under django shell great same python shell: >>> __future__ import division >>> result = 37 / 3 >>> result 12.333333333333334 >>> the same thing in django views.py don't works when try use it. error message: unsupported operand type(s) /: 'int' , 'instancemethod' views.py : from __future__ import division def show_product(request, product_slug, template_name="product.html"): review_total_final = decimal.decimal('0.0') review_total = 0 product_count = product_reviews.count # number of product rated occurences if product_count == 0: return review_total_final else: product_torate in product_reviews: review_total += product_torate.rating review_total_final = review_total / product_count return review_total_final return review_total_fin

c# - Sequence contains no elements - IList<T> having items -

foreach (var in model.items) { string s = "abc" + i.name; } above code giving me invalidoperationexception, message sequence contains no elements. model.items of type ilist , contains 2 elements, despite of giving me exception in foreach loop. i applied watch on i.name, shows value, when line inside foreach loop gets executed gives exception. what issue ? stack trace @ system.linq.enumerable.first[tsource](ienumerable`1 source) @ asp._page_views_country_hotels_cshtml.execute() in d:\app\mycontroller\items.cshtml:line 15 @ system.web.webpages.webpagebase.executepagehierarchy() @ system.web.mvc.webviewpage.executepagehierarchy() @ system.web.webpages.startpage.runpage() @ system.web.webpages.startpage.executepagehierarchy() @ system.web.webpages.webpagebase.executepagehierarchy(webpagecontext pagecontext, textwriter writer, webpagerenderingbase startpage) @ system.web.mvc.razorview.renderview(viewcontext viewcontext, textwriter wr

Java calling a method from a different class -

i'm doing pretty basic coding, trying call method different class reason i'm getting null pointer exception whenever try call method different class. think i've created instances of class correctly i'm not sure. if can explain what's going wrong me i'd appreciate it. here class makes call: public class menu extends jpanel implements actionlistener{ skeleton skeleton; board board; public menu(){ setbackground(color.black); jbutton button = new jbutton("hello"); button.addactionlistener(this); this.add(button); } public jpanel getpanel(){ return this; } @override public void actionperformed(actionevent e) { board.boardtest(); } } and here class containing method public class board extends jpanel{ public board(){ setbackground(color.white); } public jpanel getpanel(){ return this; } public void boardtest(){ system.out.print("hello"); } } as can see, whenever user clicks button should prin

html - PHP Cleaning special characters from string -

so made scrapper , returns strings multiple sites. want check if strings match, use php clean string , check. however, & , other special characters appear in 2 ways, 1 &amp; , other &#38; . how go removing each type. preg_replace("/[^a-za-z0-9]+/", "", $string); i have that, doesn't take out special characters. thanks. try function removespecialchar($string) { $string = str_replace('', '-', $string); // replaces spaces hyphens. return preg_replace('/[^a-za-z0-9\-]/', '', $string); // removes special chars. } echo removespecialchar(html_entity_decode('&amp;khawer&#38;')); //will output khawer

ruby on rails - Send back data from activerecord model on create -

i wondering if there way can send data model on create. in app have model that on create generates keys , hashes them in database. unhashed form of key , send user , allow them view once , have them save elsewhere. tried setting flash message inside model isn't working. you can add non-persisted fields models using attr_accessor regular ruby class. activerecord won't pick on these. can add field , put there, , present life of object (or until cleared). don't reload .

VBA for Word - inserting images on the first page of a section -

i trying set script set business headers , footers on word documents. header omitted on first page, set sections accordingly different. since footer same on every page, wrote script go through section , add business name , page numbers. not add image (logo) first page, following 'set headers , footers different each page activedocument.pagesetup.differentfirstpageheaderfooter = true 'set footer activedocument.sections(1) .footers(wdheaderfooterfirstpage).range.insertafter text:="first page text" .footers(wdheaderfooterfirstpage).shapes.addpicture filename:="c:\logo.png", linktofile:=false, savewithdocument:=true .footers(wdheaderfooterprimary).range.insertafter text:="later pages text" .footers(wdheaderfooterprimary).shapes.addpicture filename:="c:\logo.png", linktofile:=false, savewithdocument:=true end any appreciated! edit: think bug, based on reading article: http://scottonoffice.wordpress.com/2009/1

java 7 - Android Studio - IntelliJ No JDK found even though its installed and in path -

i did complete re-install of windows 7 ultimate 64 bit today due fact computer starting lag on me. can tell title having issue jdk not being recognized when install android studio got intellij install little no issues @ when try start project tells me there no sdk installed either. any tips me , running? have tried manually adding jdk default project configuration? you can choosing file > other settings > default project structure menu. go under sdks heading , add jdk clicking green + symbol , choosing jdk, browse jdk folder. can add android platforms here if needed. also, i'm not sure this, on x64 system use both 64-bit , 32-bit jdk. android studio/intellj uses 64-bit (in program files ) version run, build uses 32-bit jdk (in program files (x86) ). not sure if required, might worth shot if still having trouble getting work.

backbone.js - Using regions in a CompositeView for subview -

i'm using compositeview create grid of images had events on it. how looks like: backbone.marionette.compositeview.extend({ events: { 'click li.feed-thumb': 'clickelement', }, template: _.template(template), itemview: itemfeedview, itemviewcontainer: "#feed ul.feed", clickelement: function(event) { var profile = new profilefeedview(); } }); my template compositeview contains <li> element render profile when click on image. use same <li> events of click image. handle region, because understand doing region marionette handle opening , closing of views. i think compositeview not support regions: {profileregion: '#feed-profile'} , what's options? thanks in advance! you should use layout view in can specify many regions want, can create list region in can put composite view , profile region in can put item view render profile. marionette's docs -- layout view

c# - Expander IsExpanded method -

i want know if expander expanded or not. this: boolean getexpanderstatus= myexpander.isexpanded() but not work "non -invocable 'system.windows.controls.expander.isexpanded' cannot used method. i'm sure there'll annoyingly simple answer this. thanks in advance. isexpanded property , not method. properties behave variables; don't use parentheses.

jquery - Hide and show is not working -

i have problem jq script , cannot find bug. when select yes option selection box website should display "type email address" , hide "type new username". here's code: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"> </script> <script> $(function () { $('#am').on('change', function () { var stringt = $('#am :selected').val(); if (stringt === "yes") { $("#campos1").hide(); $("#campos2").show(); } else { $("#campos1").show(); $("#campos2").hide(); } }); }); </script> </head> <html> <li>are member? <select name="am"> <option value="1" selected="selected">yes</option> <option value="2">no</option> </select> </li> <

php - Regex for finding url -

Image
<a href="http://newday.com/song.mp3">first link</a> <div id="right_song"> <div style="font-size:15px;"><b>pitbull ft. chris brown - pitbull feat. chris brown - international love mp3</b></div> <div style="clear:both;"></div> <div style="float:left;"> <div style="float:left; height:27px; font-size:13px; padding-top:2px;"> <div style="float:left;"> <a href="http://secondurl.com/thisoneshouldonlyoutput" rel="nofollow" target="_blank" style="color:green;">second link</a></div>'; i want out second link html using pregmatch_all. current regex looks this: preg_match_all("/\<a.+?href=(\"|')(?!javascript:|#)(.+?)\.mp3(\"|')/i", $html, $urlmatches); this works fine , 2 links output, want second 1 output without .mp3

Python NameError: global name 'assertEqual' is not defined -

i'm following learn python hard way , i'm on exercise 47 - automated testing ( http://learnpythonthehardway.org/book/ex47.html ) i using python3 (vs book's use of python 2.x) , realize assert_equals (which used in book) deprecated. using assertequal. i trying build test case reason, when using nosetests in cmd, error: nameerror: global name 'assertequal' not defined here code: from nose.tools import * ex47.game import room def test_room(): gold = room("goldroom", """ room has gold in can grab. there's door north. """) assertequal(gold.name, "goldroom") assertequal(gold.paths, {}) def test_room_paths(): center = room("center", "test room in center.") north = room("north", "test room in north.") south = room("south", "test room in south.") center.add_paths({'north': north, 'south&

c++ - Serializing floats to bytes, when already assuming __STDC_IEC_559__ -

if test code following: #ifndef __stdc_iec_559__ #error warning: __stdc_iec_559__ not defined. code assumes we're using ieee 754 floating point binary serialization of floats , doubles. #endif ...such described here , guaranteed this: float myfloat = ...; unsigned char *data = reinterpret_cast<unsigned char*>(&myfloat) unsigned char buffer[4]; std::memcpy(&buffer[0], data, sizeof(float)); ...would safely serialize float writing file or network packet? if not, how can safely serialize floats , doubles? also, who's responsible byte ordering - code or operating system? to clarifiy question: can cast floats 4 bytes , doubles 8 bytes, , safely serialize , files or across networks, if i: assert we're using iec 559 convert resulting to/from standard byte order (such network byte order). __stdc_iec_559__ macro defined c99/c11, didn't find reference whether c++ guarantees support it. a better solution use std::numeric_limits&

macros - notepad++ replace a string in next (3 or 4 ) lines -

i have text file of 183419 lines, replace entire line of: 3 _type photo with: 3 _type document but if 3 or 4 lines after line begins with: 3 file d:\genie\grogan\doc\...... for example: 3 file d:\genie\grogan\doc\mills\mills albert 1884 birth partial transcript.jpg 3 titl mills albert 1884 birth partial transcript 3 _scbk y 3 _type photo or: 3 file d:\genie\grogan\doc\mills\mills albert 1884 deathtranscript.jpg 3 titl mills albert 1884 deathtranscript 3 _scbk y 3 _prim y 3 _type photo but not situation: 3 file d:\genie\grogan\photos\grogan edward\grogan thelma simpson jim.jpg 3 _scbk y 3 _type photo this task required run monthly. do regular expression search , replace, ensure dot matches newline not selected. setting find what ^(3 file d:\\genie\\grogan\\doc\\(.*\r\n){3,4})3 _type photo$ , replace with \13 _type document . the (.*\r\n){3,4} part matches end of genie\\grogan\\doc line plus 2 or 3 more complete lines.

android - callback issue in Facebook while user clicks anywhere while Facebook login page is loading -

i have 1 activity(login) , 1 class(facebooklogin). public void loginwithfacebook(boolean fetchuserinfo) { log.d(tag, "logging facebook."); string applicationid = utility.getmetadataapplicationid(activity .getbasecontext()); mcurrentsession = session.getactivesession(); if (mcurrentsession == null || mcurrentsession.getstate().isclosed()) { session session = new session.builder(activity.getbasecontext()) .setapplicationid(applicationid).build(); session.setactivesession(session); } else { log.d(tag, "session open"); } mcurrentsession = session.getactivesession(); if (!mcurrentsession.isopened()) { session.openrequest openrequest = null; openrequest = new session.openrequest(activity); if (openrequest != null) { openrequest.setdefaultaudience(sessiondefaultaudience.friends); openrequest.setpermissions(arrays.aslist("user_birthday", "email", "user_homet

javascript - accessing objects property dynamically (appending a string) -

i have loop in underscore _.each(questions,function(data){ a="reason"+data.choosen; %> <%= data.a; %> <% count++; }); %> the data.choosen gets either 1 or 2 or 3 or 4. based on want display data.reason1 or data.reason2 or data.reason3 or data.reason4 property of data object. i tried above approach doesn't work. in javascript x.y is equivalent to x["y"] so can change code to data[a]

java - Using Math.cos() to find cosine of angle in degrees -

this question has answer here: java: questions radians, math.cos, math.sin, double , long 3 answers i want give result math.cos() method in java in degrees.i have tried methods converting radians degrees. discovered number pass math.cos() method being treated radians,irrespective of whether convert.please can make give me result in degrees.thanks. i discovered number pass math.cos() method being treated radians, irrespective of whether convert. the discovery quite correct, , precisely why convert. once you've done conversion, pass resultant angle (which in radians) math.cos() , , happy.

php - Flash Audio Recorder and Player on a website -

i'm newbie in website designing , i'm stuck problem. want accomplish following , don't know flash: i want create webpage can record users voice using microphone , save on server. once it's done access same recording , play on browser. i want step step approach. here tips: look developing flash flex variant. then start example this . some keywords use in bing search flex , flash , actionscript , or spark .

wix - Text template stop working after manual edit -

in installer want user connect database. support 4 database types in product. in connect database dialog created, there combobox control supported database types, edit control user suppose enter connection string , pushbutton, when pressed show connection string text template in edit control according selected database type in combobox. now, problem is: user clicks show template button when mssql selected user alters manually place holder in text template connection string in edit control user realize needs mysql connection user change value in combobox mysql , clicks show template button , nothing happens. to summarize this, after edit control manually altered, show template stops working. here wix code use: <fragment> <!-- supported databases templates --> <property id="mssqltemplate" value="data source=localhost;initial catalog=[database];integrated security=yes"/> <property id="mysqltemplate" value=&quo

c# - Converting date time to string with separator "T" -

how convert date object "t" separate date , time e.g., 2013/07/22t09:43:21 instead of 2013/07/22 09:43:21 use datetime.tostring custom format string contains t @ desired position. var date = new datetime(2013, 07, 22, 09, 43, 21); var output = date.tostring("yyyy/mm/ddthh:mm:ss", cultureinfo.invariantculture); note i've used cultureinfo.invariantculture avoid / gets replaced actual culture's date-separator. demo 2013/07/22t09:43:21

exception - android.view.InflateException - Error inflating class android.widget.EditText -

hello i'm trying show custom alertdialog on screen. i'm inflating layout dialog, layout includes 2 textviews, 1 ratingbar , 1 edittext. when try popup dialog i'm getting exception : e/androidruntime(12989): android.view.inflateexception: binary xml file line #25: error inflating class android.widget.edittext important point error occurs on android 2.3.x devices, works great on android 4.x dialog_comment.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ratingbar android:id="@+id/dialogcommentratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:

android - Twitter Integration with Twitter 4j not working -

Image
i`ve updated twitter 4j library 2.2.4 3.0.3 run application , click share when clicked twitter respond following page does body have issue before if how solve thank in advance could lot of things: connection problem; temporary unreachable servers; wrong/invalid/expired oauth token first try again later, give @ settings page of twitter page. use these urls in app: public static final string request_url = "http://api.twitter.com/oauth/request_token"; public static final string access_url = "http://api.twitter.com/oauth/access_token"; public static final string authorize_url = "http://api.twitter.com/oauth/authorize"; try log , debugging, maybe can find error directly code.

rest - JQuery RestFul Put request -

i'm trying call restful service developed in servicestack. i've been able call get(s), i'm struggling call put or post. script client. function savepartner(e) { $.ajax({ type: "put", contenttype: "application/json; charset=utf-8", headers: { 'x-http-method-override': 'put' }, url: "http://localhost:49190/test", data: partnerinfotojson(), complete: function (data) { alert("complete"); }, success: function (data) { alert("done"); }, error: function (data) { alert("failed");}, datatype: "json" }); } function partnerinfotojson() { return json.stringify({ "name": "test" }); }; my test ensure api

Navigation from page1.xaml to page2.xaml in windows phone 8 -

i have 2 pages: page1.xaml , page2.xaml . have created 1 button on page1.xaml; on click event navigate page2.xaml . when run application, fails , debugger drops me in app.xaml.cs . below code: private void rootframe_navigationfailed(object sender, navigationfailedeventargs e) { if (debugger.isattached) { // navigation has failed; break debugger debugger.break(); } } my page1.xaml.cs code behind is: public partial class mainpage : phoneapplicationpage { // constructor public mainpage() { initializecomponent(); // sample code localize applicationbar //buildlocalizedapplicationbar(); } private void btndownloded_click(object sender, routedeventargs e) { navigationservice.navigate(new uri("/downloadedbooksportrait.xaml", urikind.relative)); } } sou

Delphi, cxGrid as Pie chart -

i have port delphi6 application xe3. under xe3 don't have advchart components. because want use cxgrid in future, need help, how create simple piechart these component. have dataset "name" , "value" fields (they % values). the existing demos complex. could explain steps how create cxgrid contains piechart these percentage values, , names in legend (+ colorizing)? just how start it, because i'm totally confused produce beginning.. thank help, documentation, information. i'd assume question overly broad , vote close, nevertheless short example how done programmatically, explaning usual way using ide won't fit here. var view:tcxgriddbchartview; level:tcxgridlevel; series:tcxgriddbchartseries; begin view := cxgrid1.createview(tcxgriddbchartview) tcxgriddbchartview; view.name := 'mychart'; level:=cxgrid1.levels.add; level.gridview := view; view.datacontroller.datasource := thedatasource; view.diagrampie.activ

C program only in two loops -

i want write c program having following output. there condition. should done maximum 2 loops only. output * * * * * * * * * * * * * * * any appreciated. thanks here code without loop. int main() { printf(" *\n"); printf(" * *\n"); printf(" * * *\n"); printf(" * * * *\n"); printf("* * * * *\n"); return 0; }

c++ - save mesh with RGB in vtk -

i have mesh (with color) loaded , want write .ply file , store rgb information well. have code below, uses vtkplywriter class, saves vertices , not rgb info. there built in way this? code vtksmartpointer<vtktransformpolydatafilter> rotate_and_save_mesh(vtksmartpointer<vtkplyreader> mesh_reader, double rotation_angle, double x, double y, double z, std::string& out_name, bool should_write = true){ vtksmartpointer<vtktransform> transform = vtksmartpointer<vtktransform>::new(); transform->rotatewxyz(rotation_angle, x, y, z); vtksmartpointer<vtktransformpolydatafilter> transformfilter = vtksmartpointer<vtktransformpolydatafilter>::new(); transformfilter->settransform(transform); transformfilter->setinputconnection(mesh_reader->getoutputport()); transformfilter->update(); if(should_write){ vtksmartpointer<vtkplywriter> writer = vtksmartpointer<vtkplywriter>::new();

c - What is the principle of pcap_setdirection? -

i want use libpcap capture incoming ethernet frame. here problem. use pf_packet , raw socket revise mac header. remove mac address header specific implementation. use pcap_setdirection capture incoming packets errors cannot understand. want know how libpcap distinguish incoming of outgoing packets? judge mac address or can directly receiving buffer on duplex mode. os linux, centos 5.5. nic set promiscuous mode.

random - randomseed in LUA -

i working on code randomizes numbers. put math.randomseed(os.time()) inside loop. code goes this: for = 1, 1000 math.randomseed( os.time() ) j = math.random(i, row-one) u[i], u[j] = u[j], u[i] k = 1, 11 file:write(input2[u[i]][k], " ") end file:write"\n" end and when run several times, whole output same. isn't randomseed supposed prevent repeats when re-run? call math.randomseed once @ start of program. no point calling in loop.

iphone - Add sound to AVMutableVideoComposition multiple times -

i'm using avmutablevideocomposition add video , audio. i have multiple video , audio files stitch together, works fine. i'm using code add audio: avurlasset *audioasset = [[avurlasset alloc] initwithurl:[nsurl fileurlwithpath:path] options:nil]; [compositionaudiotrack inserttimerange:titlerange oftrack:[audioasset trackswithmediatype:avmediatypeaudio][0] attime:partzerotime error:&err]; the path correct (used nslog check) , partzerotime insertion point every audio track (the audio played @ beginning of video only). audio file same (some m4a file). this works first audio, though. every subsequent audio isn't played. not receive error adding audio asset. i tried create separate track music, same result. any ideas? [edit] i might not entirely clear want do, here's more information: have video composition of several clips stitch avmutableco

android - How to generate Listview with button? -

i want implement listview 3 button below. xml given code below problem position of button. in first time used linear in time action of buttons inversed. ought use relative layout <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="3dp" > <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="3dp" > <listview android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margintop="5dp" android

BizTalk schemas not in referenced assembly -

i trying reference schemas part of biztalk project in biztalk project not part of same solution. referencing source project adding source dll reference in 'destination' project (i.e. 'add reference', 'browse' point required biztalk schema assembly). however, when in referenced assembly in object browser small subset of schemas available - none of wcf generated schemas form part of project visible. comparing schema properties in source project between ones visible via object browser , missing, identical (other file name , type name) in have same build action (btscompile), set propertyschema , belong same namespace. does have suggestions around please? i've experienced behaviour before when had older version of assembly in gac, , visual studio referencing version rather version on disk. check isn't case, review gac , remove references faulty schema, restart visual studio before re-trying re-compilation. i tempted check referencing correc

java - Creating file with empty title -

i tried creating file empty title or space , worked cannot find file in directory. not delete or rename file. file dir1 = new file("dir1"); dir1.mkdir(); file file1 = new file(dir1, ""); file1.createnewfile(); system.out.println(file1.exists()); returns true if execute file1.delete() or file1.renameto(...) since passing empty string child, file1 same dir1 , you're doing file1 happening directory created. here sample: public static void main(string[] args) { file directory = new file("/home/test"); directory.mkdir(); file file = new file(directory, ""); system.out.println(file.exists()); system.out.println(file.getabsolutepath()); system.out.println(directory.getabsolutepath()); file.delete(); system.out.println(directory.exists()); system.out.println(file.exists()); } output: true /home/test /home/test false false

android - Resize text in Textbutton -

helo guys! i'm trying set size of text in textbutton using libgdx , scene2d. here's how create , initialize textbutton object: skin skin = new skin(); skin.add("white", new texture(gdx.files.internal("data/texture.jpg"))); skin.add("default", new bitmapfont()); textbutton.textbuttonstyle textbuttonstyle = new textbutton.textbuttonstyle(); textbuttonstyle.up = skin.newdrawable("white"); textbuttonstyle.down = skin.newdrawable("white", color.dark_gray); textbuttonstyle.checked = skin.newdrawable("white", color.blue); textbuttonstyle.over = skin.newdrawable("white", color.light_gray); textbuttonstyle.font = skin.getfont("default"); skin.add("default", textbuttonstyle); textbutton newgame = new textbutton("hello button",skin); after button text in created perfectly, don't understand how can change it's text size. i've tried every method of label object: ne

hibernate - JPA Mapping of Project Entity with Employee Entity -

i know how can map following requirements using jpa i have project entity following attributes projectno (auto generated) projectrequestedby approvedby employee entity employeenumber (primary key) employeename employeetitle employeephone i know how can efficiently map employeenumber projectrequestedby , approvedby attributes in project entity? and know how possible display employeename , employeetitle , employeephone attributes when execute query against project entity class? ideally want have following record if try fetch project record projectno projectrequestedbyname projectrequestedbytitle approvedbyname approvedbytitle any highly appreciable. update 1 project entity @entity @table(name = "project") public class project private long projectno; @manytoone @joincolumn(name="emp_number", insertable =false, updatable=false) private employees employees; employees entity @entity @table(name = "employees") public class

r - Remove Plot Margins in ggplot2 -

Image
i'm trying produce png chart using ggplot2 , ggsave (with cairo) in r. i'm having issue customising theme remove margins. currently i'm using: ... + theme(plot.margin=unit(c(0,0,0,0),"mm")) this seems work 2 out of 4 sides of plot, removes top , right hand side margin completely, there still large margin on left , bottom sides. there way remove these? image below illustrate problem: if reproducible example useful let me know , i'll put 1 together. edit: library("ggplot2") library("scales") library("cairo") library("grid") # set chart values line.width = 0.45 axis.font.size = 2.9 # generate random data start.date <- as.date("2011-07-01") x.month <-seq.date(start.date, = "month", length.out = 24) end.date <- max(x.month) period.a <- rnorm(12, mean=50, sd=2) period.b <- rnorm(12, mean=55, sd=2) x.value <- c(period.a,period.b) # combine dataframe x.data <

jsf - ClassCastException Java with list iterator -

i have strange error in code. using iterators since beginning of project , never had problems here can't understand what's going on. i have model class public class myobject implements serializable{ private static final long serialversionuid = 1l; private int field1; private string field2; private list<otherobject> field3; private date field4 ... // + getters , setters // + override equals method } a class parameters of myobject type public class fooclass implements serializable{ private static final long serialversionuid = 1l; private list<myobject> list; // + getters , setters } and have other class using myobject public class mycontroller { ..... public static void amethod(fooclass value) { list<myobject> mylist = value.getlist(); iterator<myobject> iterator = mylist.iterator(); while(iterator.hasnext()) { myobject temp = iterator.next(); // error

Android speech to text for robot control -

i thinking making app can use control arduino robot (over bluetooth/wifi) using voice commands. make experience fluid, need android app speech recognition continuously running. if want robot stop, don't want press button, wait speech recognition dialog appear, command "stop", release button, wait parser parse it, , send stop command. i rather have speech text in continuous listen mode when controlling robot. , when hears keywords, sends them. can in android? did googling, , found recognizer intent, of examples found use button trigger , pretty followed scenario described above. it can done. @ link. has example code :) can make listen , when speeches word see if keyword , make robot want. http://viralpatel.net/blogs/android-speech-to-text-api/

arrays - Get javascript fields with specific names in object -

i have object such fields: { d_name: { field_name: true }, d_date: { field_date: isodate() }, status: 'success' } i need fields starting d_ , push them 1 array.. i need fields... do mean need keys? if so: var d_keys = object.keys(obj).filter(function (key) { return !key.indexof("d_"); }); if want values: var d_values = object.keys(obj).filter(function (key) { return !key.indexof("d_"); }).map(function (key) { return obj[key]; }); note uses various es5 methods ( object.keys , array.prototype.filter , array.prototype.map ), depending on environment may need appropriate shims. here working examples of both snippets.

c++ - deleting a node from linked list, when we are already pointing to that node -

1->2->3->4 list, want delete 3rd node. list *temp = *list; list *local = null; if (temp->next != null) { while(temp->next->data != data) temp = temp->next; local = temp->next; temp->next = temp->next->next; delete local; local = null; } else { delete (*list); *list = null; } here using local node store node address temporarily , want remove, there way delete node without taking temporary variable ?

ColdFusion Regex Match for Digits of Exact Length -

i need assistance constructing regular expression in coldfusion application. apologize if has been asked. have searched, may not asking correct thing. i using following search email subject line issue number: rematchnocase("[0-9]{5}", mailcheck.subject) the issue number contains numeric values, , should 5 digits. working except in cases have longer number appears in string, such 34512345. takes first 5 digits of string valid issue number well. what want retrieve 5 digit numbers, nothing shorter or longer. placing these list looped on , processed. perhaps need include spaces before , after in regex desired result? thank you. the general way exclude content occurring before/after match use negative lookbehind before match , negative lookahead afterwards. numeric digits be: (?<!\d)\d{5}(?!\d) (where \d shorthand [0-9] ) cf's regex supports lookaheads, unfortunately not lookbehinds, wouldn't work directly in rematch - doesn't matte

iphone - Custom calender with add event in ipad -

how create our own calendar in ipad , there api ? please suggest me. i'm searching lots of in google not api create custom calendar , add event in calendar... thank you. for creating/ managing calendar events have @ ekeventstore . http://developer.apple.com/library/ios/#documentation/eventkit/reference/ekeventstoreclassref/reference/reference.html you can ofcourse, create own calendar, need play dates , have draw calendar youself. may use open source calendar, if dont want draw yorself: klazuka_calendar https://github.com/klazuka/kal

node.js - Require usage techniques -

i've seen node.js boilerplates autoload model files using "require()" in several different ways. i'm used using "var variable_name = require('app/models/model.js') , model = require('app/models/model.js') i'm wondering how use model when required this: require('app/models/model.js') let's suppose model.js has attribute "name" , method ".save()". how model can used? if don't assign object returned require, can't access later. here examples notes: this run top-level code, not keep reference module object require('app/models/model.js') this run top-level code , 1 instance (note i'm assuming model.js exports constructor function common opposed name , save properties describe directly, think unlikely what's there). var mymodel = new require('app/models/model.js') this store model constructor can make many instances need. var model = require('app/mo

reporting services - Report Builder 2.0: Display certain rows based on certain conditions -

i have table has, apart others, 2 columns named partition_name , xkey. want is, when user logs in system, has xkey found in xkey column, display rows "linked" xkey (the rows have xkey). moreover, have check partition_name column. if user logs in, , corespondend of xkey in partition_name ep, have display rows, not related xkey. i've done first part (display rows based on xkeys) can`t figure out how display rows if partition_name of xkey ep. this how in rb 3.0; don't know how 2.0 different, may work. i don't know how system set up, we'll assume there's way determine user , user's partition_name is. need set hidden parameter set value of user's partition_name; we'll call parameter pn_param; need set hidden filter, we'll call xkey_param. set filter on dataset. set value [xkey] or whatever name of column is. make sure type text. set operator = set expression following: =iif(parameters!pn_param.value = "ep", "

vba - MS Access two-listbox control -

Image
what side-by-side listbox control called? can used in ms access 2010, or have make scratch? (this question has nothing query wizard--i trying see if can make control listboxes application) the scratch pretty way go. guess around ready control, haven't been able find 1 within 10-15 minutes of searching. simple own. if follow these articles achieve want under 30 minutes youtube tutorial - uses worksheet forms can adapt work on userform - logic remains same. web tutorial - seems nice tutorial lots of screenshots , description of steps.

c# 4.0 - asp.net unable to retrieve metadata -

hi having issue mvc make controller after reading tips. adding constructor on dbcontext, deleting non worked, changing providername="system.data.sqlclient" , on. my model class this: public class recruitermodel { public string companyname { get; set; } public string website { get; set; } public string companysize { get; set; } public string linkedincompanyurl { get; set; } public string linkedinid { get; set; } public string specialities { get; set; } public string category { get; set; } public string location { get; set; } public int contactphone { get; set; } public string contactemail { get; set; } } public class recruiterdbcontext : dbcontext { public dbset<recruitermodel> recruiters { get; set; } } and web.config connectionstrings looks this: <add name="applicationservices" connectionstring="data source=.\sqlexpress;integrated security=sspi;attachdbfilename=|datadirectory|aspnetdb.md