Posts

Showing posts from August, 2015

html - Marking up the "BBC pattern" in HTML5 -

i'm looking @ bbc site, , putting following similar overall pattern, , determining how mark appropriately stumping me somewhat. the bbc consists of several considered sites in own right: http://www.bbc.co.uk http://www.bbc.co.uk/comedy/ http://www.bbc.co.uk/news/ www.bbc.co.uk/[a-lot-more-stuff] (these subdomains instead - indeed, case me - urls not important) each of these self-contained, own content, menu , , feel. of them tied use of (slightly variable mostly) static header bar. contains header "bbc" along links of various sub-sites. so question is, how should marked up. see several different options: the main bbc header site's main <header> , <nav> . sort of correct, because ends de-emphasising importance of sub-site's actual content. when boils down (to use examples above), title "comedy" , associated menu main content of page, not bbc bar. make sub-sites' header , navigation ones marked within <header>

Examples of Java frameworks which don't play well with Scala -

has run across java/java ee framework causes problems if used scala? don't know of specific one, pre-java 5 framework uses raw types may cause trouble @ point in scala, if have raw type in hierarchy of class must implement. here few questions related issue: implementing methods having raw types in scala why scala complain illegal inheritance when there raw types in class hierarchy? scala class cant override compare method java interface extends java.util.comparator

ruby on rails - Restricting admin from destroying own account using cancan -

here snippet of code ability class if user.admin? can :manage, :all can :destroy, :all if != current_user i sure can figure out trying here. realize destroy included in manage , repeating myself there. suggestions? edit yjerem's answer correct 1 , changed fit code. looks like. if user.admin? can :manage, :all cannot :destroy, user, :id => user.id as yjerem said, in cancan, ability precedence states ability defined lower down trump ones on them admin can manage except defined under using code above. read ability precedence , there's example there you! basically want cannot method: if user.admin? can :manage, :all cannot :destroy, user, :id => current_user.id because cannot rule below more general one, overrides it.

c# - Is a static variable shared across all instance? -

in public class, have private static dictionary. since dictionary static, mean shared across other instance of same object (see example below). public class tax { private static dictionary<string, double> taxbrakets = new dictionary<string, double>(stringcomparer.ordinalignorecase) { { "individual", 0.18 }, { "business", 0.20 }, { "other", 0.22 }, }; public string type { get; set; } public double computetax(string type, double d) { return d * taxbrakets[this.type]; } } is acceptable use dictionary in way (as static variable)? your static variable taxbrakets not associated instance. this.taxbrakets not compile. occurrences of taxbrakets refer same dictionary. in general, it's totally acceptable use static dictionaries. particular use seems little funny though, i'd need see more code suggest changes.

php - Convert array values to a comma-delimited string, with numbers replaced by '?' -

my array: $numbers = array(1, 3, 5); simply, need change numbers ? question mark , separated , comma. // output (array has 3 items): $string = '?, ?, ?'; you can use combination of str_repeat , count . use rtrim clean trailing comma: $numbers = array(1, 3, 5); $str = str_repeat('?, ', count($numbers)); $str = rtrim($str, ', '); echo $str; // output: ?, ?, ?

Doctrine 2 mysql FIELD function in order by -

i'm trying use mysql field function in order clause in query. i'm assuming doctrine 2 doesn't support field function out of box - true? if so, how can use it? have turn whole query native query? there doctrine 2 extension adds functionality? jeremy hicks, your extension . didn`t know how connect function doctrine, find answer. $doctrineconfig = $this->em->getconfiguration(); $doctrineconfig->addcustomstringfunction('field', 'doctrineextensions\query\mysql\field'); i need field function order entities select in expression. can use function in select, where, between clause, not in order by . solution: $qb ->select("r, field(r.id, " . implode(", ", $ids) . ") hidden field") ->from("entities\round", "r") ->where($qb->expr()->in("r.id", $ids)) ->orderby("field"); to avoid adding field alias re

c# - Performing Inserts and Updates with Dapper -

i interested in using dapper - can tell supports query , execute. not see dapper includes way of inserting , updating objects. given our project (most projects?) need inserts , updates, best practice doing inserts , updates alongside dapper? preferably not have resort ado.net method of parameter building, etc. the best answer can come @ point use linqtosql inserts , updates. there better answer? we looking @ building few helpers, still deciding on apis , if goes in core or not. see: http://code.google.com/p/dapper-dot-net/issues/detail?id=6 progress. in mean time can following val = "my value"; cnn.execute("insert table(val) values(@val)", new {val}); cnn.execute("update table set val = @val id = @id", new {val, id = 1}); etcetera see blog post: that annoying insert problem update as pointed out in comments, there several extensions available in dapper.contrib project in form of these idbconnection extension methods:

html - Firefox 4 <sections> and headers -

from question started looking: firefox screwing headings sizes h1 h2 h3 here html snippet show issue: <html> <head> </head> <body> <section> <section> <h1>this h1</h1> <h2>this h2</h2> <h3>this h3</h3> <h4>this h4</h4> </section> </section> </body> </html> so save test.html , open in firefox 4 , in chrome, h1 tag shows way smaller in firefox 4. can explain me how fix ? it possible use <h1> tag multiple times in same document part of html5. <h1> tag used title section. apparently, firefox implements nested section indication reduce size of <h1> sub-section, makes sense, while chrome not. more info http://brugbart.com/references/html-section-tag http://brokensyllabus.blogspot.com/2008/02/proper-use-of-h1-tag.html

Storing multiple graphs in Neo4J -

i have application stores relationship information in mysql table (contact_id, other_contact_id, strength, recorded_at). fine if need show contact's relationships or generate list of mutual contacts 2 contacts. but need generate stats like: 'what total number of 2-way connections of strength 3 or better in january 2011' or (assuming each contact part of group) 'which group has number of connections other groups' etc. i found sql generating these stats became unwieldy real fast. so wrote script given date generate graph in memory. run whatever stat wanted against graph. easier understand , in general, more performant -- except generating graph part. my next thought cache graphs call on them whenever needed run new stat (or generate later graph: eg today's graph take yesterday's graph , apply changes happened since yesterday). tried memcached worked great until graphs grew > 1 mb. so i'm thinking using graph database neo4j. only problem

Fastest way to build form - PHP/jQuery/CodeIgniter -

there tons of ways handle forms in general, i'm wondering if has solid solution use of apps, can build out forms , include types of form elements. what i'm using ci's built-in form validation , building out form, this, feel takes long... suggestions? there jquery plugin (called "dform") take json input build form dynamically. have been using while now. please take @ following url: http://neyeon.com/p/jquery.dform/doc/files2/readme-txt.html quick usage: var formdata = { "action" : "index.html", "method" : "get", "elements" : [ { "name" : "textfield", "label" : "label textfield", "type" : "text", "value" : "hello world" }, { "type" : "submit", "value" : "submit" } ] }; $("#myform").buildform(formdata); /

Django: Custom "add only" inline -

i want inline form show fields contents, , not let users edit or remove entries, add them. means values similar when using readonly_fields option, , "add ..." link @ bottom make form appear, letting users add more entries. the can_delete option it's useful here, readonly_fields lock both add , change possibilities. imagine building new inline template do. in case, how show field values each entry , put form @ bottom? edit: got until now: # models.py class abstractmodel(models.model): user = models.foreignkey(user, editable = false) ... more fields ... class meta: abstract = true class parentmodel(abstractmodel): ... fields ... class childmodel(abstractmodel): parent = models.foreignkey(parentmodel, ... options ...) ... fields ... # admin.py class childmodelinline(admin.tabularinline): model = childmodel form = childmodelform can_delete = false class parentmodeladmin(admin.modeladmin): ... options ... inlines = (childm

ajax - Dynamic Fancybox forms in Rails -

can point me towards simple step step guides me understand how couple fancybox , ajax together? i have 3 models: class event belongs_to :site belongs_to :operator end class site has_many :events end class operator has_any :events end users can add new event, , select site or operator select boxes. i've created quick-add partials site , operator. these rendered in div on event form, , displayed in fancybox when link clicked. <%= link_to_box "add", "#site" %> <%= link_to_box "add", "#operator" %> <div id="site"> <%= render 'sites/quickadd' %> </div> <div id="operator"> <%= render 'operators/quickadd' %> </div> so far good. now have 2 questions. 1- how hide quick-add divs on event form, display them in fancybox. css classes such display:none or visibility:hidden result in partials not displaying in either location. par

Php two forms one page -

i have deleteimage.php page @ top has includes 'functions.php' <== has functions okk , in deleteimage.php page have form looks this: <form action="#" method="post" id="delform"> <input type="submit" name="deleteimg" id="deleteimg" value="delete image"/> </form> then in include page have function has: foreach ($lines $line) { $images = explode(":", $line); if ($user == $images[2]) { $imgpath = $images[0]; $content .= '<div class="private"> <img class="yourgal" src="'; $content .= $imgpath . '"'; $content .= 'width="200" alt="$title" /><form action="#" method="post"><input type="checkbox" name="delete[]" value="'.$imgpath .'"/>delete</form></div>';

fftw - Problem with FFTW2 routine in C -

i'm working fftw2 (fastest fourier transform in west) library, , after writing successful routine in fortran, moving on c. however, i'm having trouble data assigning when try input data transform (ie, values of sin(x)). currently, code is: #include <stdio.h> #include <fftw.h> #include <math.h> #include <complex.h> void compute_fft(){ int i; const int n[8]; fftw_complex in[8]; fftwnd_plan p; in[0]->re = 0; in[1]->re = (sqrt(2)/2); in[2]->re = 1; in[3]->re = (sqrt(2)/2); in[4]->re = 0; in[5]->re = -(sqrt(2)/2); in[6]->re = -1; in[7]->re = -(sqrt(2)/2); for(i = 0; < 8; i++){ (in[i])->im = 0; } p = fftwnd_create_plan(8, n, fftw_forward, fftw_esimate | fftw_in_place); fftwnd_one(p, &in[0], null); fftwnd_destroy_plan(p); printf("sin\n"); for(i = 0; < 8; i++){ printf("%d\n", n[i]); } } i've been using http://fftw.org/fftw2_doc/ link docum

ios4 - Edit image, using openGL -

i have been doing searching last couple of days , have been curious how this. have uiimagepickercontroller. so want add effect black , white, sepia, etc. creating custom uiimagepickervcontroller , curious. can done opengl es? if so, how? this possible through use of pixel shaders using opengl-es 2.0. write objective-c++ routine gets pixels of image array applies custom algorithm modify color of image. edit: here links might started. http://www.sunsetlakesoftware.com/2010/10/22/gpu-accelerated-video-processing-mac-and-ios http://www.dreamincode.net/forums/topic/76816-image-processing-tutorial/ http://www.efg2.com/lab/library/imageprocessing/algorithms.htm

iphone - How to add a UIToolbar to a UITableViewController programmatically? -

i have opted use uitableviewcontroller without nib. need uitoolbar @ bottom 2 buttons. simplest way of doing that? p.s. know can use uiviewcontroller , add uitableview want things consistent across app. can help? i saw following example , not sure on validity: (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; //initialize toolbar toolbar = [[uitoolbar alloc] init]; toolbar.barstyle = uibarstyledefault; //set toolbar fit width of app. [toolbar sizetofit]; //caclulate height of toolbar cgfloat toolbarheight = [toolbar frame].size.height; //get bounds of parent view cgrect rootviewbounds = self.parentviewcontroller.view.bounds; //get height of parent view. cgfloat rootviewheight = cgrectgetheight(rootviewbounds); //get width of parent view, cgfloat rootviewwidth = cgrectgetwidth(rootviewbounds); //create rectangle toolbar cgrect rectarea = cgrectmake(0, rootviewheight - toolbarhei

java - Challenge in Asynchronous Javascript Loading -

background: i'm working on gwt based application deployed on google app engine. application uses custom library, requires 6-7 big core javascript files (~3 mb total size) loaded front. load application's home page, takes anywhere 20-40 secs depending upon bandwidth. set upon task address slow page load issue. i made plain html home page, without gwt or custom library's components. home page contains login button , simple jquery based image slider. i'm using google accounts based authentication. on home page, use "asynchronous ordered" javascript loading technique presented here: http://stevesouders.com/efws/loadscript.php?t=1303979716 load core .js files. while user looking @ home page or interacting image slider, .js files quietly download in background. after user logs in, control redirected main html file, retrieves .js files cache, , loads app. time loading of app faster. so, home page loads in 2-5 secs , main app loads pretty fast. it's need

objective c - iPhone best design for 70 different views? -

i new iphone development... trying figure out best design 70+ views. have 1 navcontroller , 70 views or what? i thought have 10 xibs each own navcontroller , views, haven't found seems think correct or not. i think understand iphone not handle memory dealloc assuming bit choice on how make work. if going implement 70+ views means have use both navigation controller tabbar controller. user can access views. if using 1 navigation controller , 70+ views means difficult user view views.

Convert Military Time from text file to Standard time Python -

i having problems logic on how convert military time text file standard time , discard wrong values. have got point user asked input file , contents displayed text file entered. please me python's datetime.time objects use "military" time. can things this: >>> t = datetime.time(hour=15, minute=12) >>> u = datetime.time(hour=16, minute=44) >>> t = datetime.datetime.combine(datetime.datetime.today(), t) >>> t datetime.datetime(2011, 5, 11, 15, 12) >>> u = datetime.datetime.combine(datetime.datetime.today(), u) >>> t - u datetime.timedelta(-1, 80880) with little twiddling, conversions ones describe should pretty simple. without seeing code, it's hard tell want. assume this: raw_time = '2244' converted_time = datetime.time(hour=int(raw_time[0:2]), minute=int(raw_time[2:4])) converted_time = datetime.datetime.combine(datetime.datetime.today(), converted_time) now can work converted_time

c# - Accessing Gridview columns by Row.Cells -

hai using following code access columns in row displays empty string when using row.cells[1].text using code in gridview unload event handler. thanks inn advance. foreach (gridviewrow row in grvsearchringtone.rows) { string coltext = row.cells[1].text; } it done in gridviews rowdatabound event ie protected void gvusers_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.header) { string coltext = e.row.cells[1].text } else if(e.row.rowtype == datacontrolrowtype.datarow) { string coltext = e.row.cells[1].text } } hope helps.

iphone - How to access the checkboxes in the Tableview Cell? -

hai,iam printing checkbox every row.but when select checkbox last cell checkbox selecting.below 1 code printing checkboxes , daily,weekly,monthly data. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [[uitableviewcell alloc]init]; cell = [self getcellcontentview:cellidentifier]; uilabel *lbltemp1 = (uilabel *)[cell viewwithtag:1]; uilabel *lbltemp2 = (uilabel *)[cell viewwithtag:2]; uilabel *lbltemp3 = (uilabel *)[cell viewwithtag:3]; uilabel *lbltemp4 = (uilabel *)[cell viewwithtag:4]; checkbutton=[uibutton buttonwithtype:uibuttontypecustom]; checkbutton.frame = cgrectmake(5,30, 15, 10); [checkbutton addtarget:self action:@selector(selectcheckbox) forcontrolevents:uicontroleventtouchupinside]; pictureimageview=[[uiimageview alloc]initwithframe:cgrectmake(20, 5, 100, 60)]; //pictureimageview=[[uii

javascript - When a tree loads it is stealing focus -

i have tree panel text field within top toolbar. after keystrokes tree reloaded, stealing focus away textbox here code: ext.define('search_tree', { extend:'ext.tree.panel', rootvisible:false, autoscroll:true, store:ext.create('ext.data.treestore', { root:{ id:'node', nodetype:'async' }, proxy:{ actionmethods:{ 'read':'post' }, type:'ajax', url:'myurl' } }), tbar:['search:', { xtype:'textfield', id:'search_combo', listeners:{ keyup:{buffer:150,fn:function(field, e) { var val = this.getrawvalue(); if(val.length != this.valuelength){ var thistree = this.up('treepanel');

filesystems - How to access files in my hosting server using silverlight app -

i'm developing silverlight app needs create files in hosting server whenever there updation in data. googled scenario of no luck...pls advice on approach. thanks, magz you can create web service serve bridge between silverlight app , hosting server.

Prevent Tcl from crashing on unknown command -

i'm doing eval on content of file. file made out of labels parse. each line has label, , have proc defined each label, eval succeeds. however, users add new labels , eval command fails, because of unknown command. is there way prevent tcl crashing when trying eval unknown command? ideally, should allow me substitute own defined behaviour - such priting error , continuing eval . edit : unfortunately, can use tcl 8.4. tried doing following, as suggested here : proc handle_unknown_label {cmd args} { ... } and then: rename unknown _old_system_unknown rename handle_unknown_label unknown catch {set ret [eval $x]} err rename unknown handle_unknown_label rename _old_system_unknown unknown but still same behavior eval , , prints following errors: procedure unknown protected proc , not renamed procedure unknown protected proc , not overriden procedure unknown protected proc , not renamed procedure unknown protected proc , not overriden i

csv - How to save performance counter data to disc -

i want monitor performance of server , want save data of counters in csv file can analyze same later. can using perfmon have manually. there way or tools can me automatically? first create counter file, e.g. counter.txt containing counters interested in. add counter perfmon. use following commands to: create counter logman create start collecting data logman start stop collecting data logman stop remove counter logman delete logman create accepts several switches , 1 of them logfile path , format. in instances may have create empty logfile otherwise logman complain can not create log file.

Enabling PHP Code Assist for different PECL extensions in Eclipse -

i'm using few pecl installed extensions in php environment. developing eclipse , useful have eclipse's code assist / auto-completion support these extensions. procedure worked quite solr extension: i additionally downloaded latest solr-php pecl sources , put them separate folder. i added folder "external folder" 1 of user libs (prefrences -> php -> php libraries). i added user lib project's php include path (properties -> php include path -> libraries -> add library) i had new classes/methods available in editor's auto-completion. the problem is: doesn't seem work extensions. e. g. extension adding mongodb support php. why that? comparing folders' contents notice mongo extension missing php file docs/documentation.php (which contained in solr extension). whereas relevant *.h , *.c files available. do have generate file(s) myself? thanks in advance hints, cheers! after posting question @ mongodb's user g

Django threadedcomments - how do I reply to a comment? -

i trying integrate threadedcommetns django app , having trouble in uderstanding how works. here how template looks (based on example tutorial ): <h3>comments on post:</h3> {% get_threaded_comment_tree post tree %} {% comment in tree %} <div style="margin-left: {{ comment.depth }}em;" class="comment"> {% link_to_profile comment.user %} {% auto_transform_markup comment %} </div> {% endfor %} <p>reply original:</p> <form method="post" action="{% get_comment_url post %}"> {% csrf_token %} <ul> {% get_threaded_comment_form form %} {{ form.as_ul }} <li><input type="submit" value="submit comment" /></li> </ul> </form> so, if threaded comments, how reply comment left someone? form that? managed reply original form, this, comments not threaded @ all. i grateful help. p.s. actually,i not

visual studio 2010 - How can I register OCX after build -

how set project automatically register ocx file created ? i think there's option in properties somewhere, cant find it... i'm using vs2010 the answer is: project -> properties -> configuration properties -> linker -> general -> register output see linker property pages in msdn

Anti-Bot comment system - PHP -

update: question posted @ codereview: https://codereview.stackexchange.com/questions/2362/anti-bot-comment-system with advice [see details on previous questions if interested] developed system, think quite strong bot automatically post comment ! i'm posting code can view , post valuable comments !! kind of constructive suggestion welcome :) index.php <html> <head> <script type="text/javascript" src="jquery.js"></script> <script> function main() { var str=$("#key").load("gettoken.php",function (responsetext) { $("#key").val(responsetext); } ); settimeout("main()", 100000); } </script> </head> <body onload='main()'> <form name="f" action="poster.php" method="post"> <input type="text" name=&q

graphics - paint event in c#.Net -

i have following controls in application, a user control consists of panel an 'open' button use paint event draw image(browsed , selected using openfiledialog) on user control. works fine first image. if use openfiledialog open second image, part size of openfiledialog not shown in control. problem using paint event ? use control handle paint event.if control usercontroll after dialog: myusercontrol.invalidate() invalidate method calls paint event specified control again automatically.

XML code snippets to browser friendly HTML -

is there online tool convert xml code snippets browser friendly html? i want post xml code forum viewing purposes , nothing else tags mess html. to display strings containing reserved characters in html ( < , > , & ), need convert characters html entities. for example, html entity < &lt; . there tools in languages converting reserved html characters entities. example, in php, can use htmlentities() function. you'll need tell language(s) you're working before can give more language-specific advice though. but in general, it's case of replacing instances of 3 characters entity alternatives, simple set of string replacements need.

Java (Android) threads , accessing same list -

i'm new java , android bear me. i have 1 arraylist of strings filling on main ui. i have thread sending 1 one strings of arraylist through socket, , after sending each 1 erases list. so it's fifo , 2 different threads accessing same arraylist. how can make reading , writing on same list, thread safe? because read have to, preventing future errors. my first thought creating synchronized method access arraylist. this method created access arraylist both threads. public synchronized string accessarraylist(boolean add, boolean get, string utt) { if(add){ mstrings.add(utt); return null; } else if(get){ return mstrings.get(0); } else{ mstringsuttcomm.remove(0); return null; } } the main thread add's strings list. the second thread : runnable runner = new runnable() { public void run() { while(!mstring.isempty()){ //socket sends strin

sql server - How to catch SQLException in C#? -

here tried catch sql exception using innerexception in smo ojects.in sqlserver getting error message msg 121, level 15, state 1, procedure test_sp_syntaxtext, line 124 select list insert statement contains more items insert list. but using code catch (exception ex) { errorflag = true; //ex.source.tostring(); e2dinsertandgenerateerrorlog(ex.innerexception.message.tostring(), filename, "checkinapply", pathname, "errorlog.err"); } i getting the select list insert statement contains more items insert list. i need cache line also msg 121, level 15, state 1, procedure test_sp_syntaxtext, line 124 any suggestion? edit: streamreader str = new streamreader(filetextbox.text.tostring()); string script = str.readtoend(); str.dispose(); sqlconnection conn = new sqlconnection("data source=xx;database=xxx;user id=sx;password=xxxx"); server server = new server(new serverconnection(co

Showing multiple markers on map : Titanium -

i making app in have show map in application. able show map , able add markers using annotation on mapview. problem 1> not able show multiple markers on map. so body can me how can add multiple markers on map. thanks, rakesh here map class use. include map.js file in window , call map.init , pass in array of map annotations add, center lat/long, top , bottom positions of map, , optionally lat/long delta. if want dynamically add annotations after map has been created can call other functions in class so: var path = ti.platform.name == 'android' ? ti.filesystem.resourcesdirectory : "../../"; var map = { top: 0, bottom: 0, latitude: 0, longitude: 0, latitudedelta: 0.1, longitudedelta: 0.1, display: "map", init: function (annotations, latitude, longitude, top, bottom, delta) { if (top) map.top = top; if (bottom) map.bottom = bottom; if (delta) {

google calendar api asp.net c# delete event -

i have function private static void deleteevent(calendarservice service, string ptitle,datetime pdate) { feedquery query = new feedquery(); query.uri = new uri("http://www.google.com/calendar/feeds/default/private/full"); atomfeed calfeed = service.query(query); foreach (atomentry entry in calfeed.entries) { if (ptitle.equals(entry.title.text)) { entry.delete(); break; } } } how can delete event title , date ? these might help: http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#deletingevents http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#retrievingevents i'd guess following might work: eventquery query = new eventquery("https://www.google.com/calendar/feeds/default/private/full"); query.startdate = ...; query.enddate = ...; eventfeed feed = service.query(query); foreach (var en

Memory never released when using Python classes and numpy -

basically not going post of code here provide generic example. have class has function run , create large array of values. array shouldn't bigger 10mb estimates. within functions makes new , modifies arrays should collected after functions within train run. not used elsewhere besides returned temparray put large array. repeated. memory used keeps growing , growing. there issue code or way around this. have read here memory leaks malloc in linux: http://pushingtheweb.com/2010/06/python-and-tcmalloc/ . what trying do? temp = self.largearray = zeros((1000,1000,10,20)) y in temp.size: x in temp1.size: self.largearray[x,y] = train() temp.size equals 200,000,000. how can store largearray[x,y] if second dimension of array 1000?

c# - How do I wrap a primitive data type like int to uint8_t? -

i need able wrap primitive data type. i'm not sure how proceed. using clause (as below) works fine if 1 file, need able use in whole project. eg. using int8_t = system.sbyte; using uint8_t = system.byte; using int16_t = system.int16; using uint16_t = system.uint16; any appreciated. updated comments: we using enterprise architect generate our code (c#, c++, java). , need code bases same. need able wrap base types able that. c/c++ easy, use "typedef short int16_t;". need able in c# well.

c# - Slow WPF 4 Datagrid Refresh -

i using wpf datagrid component .net 4 framework, bound thread safe observable collection found here : http://www.deanchalk.me.uk/post/thread-safe-dispatcher-safe-observable-collection-for-wpf.aspx the program system admin tool pings each ip address in range, if there response creates object in collection details computer. the problem having, poor performance. initially, updating collection , letting datagrid pick changes. caused issue datagrid control wasn't refreshing , showing data unless scrolled. so added timer call grids refresh method, timer ticks every 750ms. worked brilliantly, until realised programs ui unresponsive while timer enabled , scanning. without timer, performance acceptable, without it, terrible. have tried several values timeout period (up 2000ms) without luck , have made sure columns fixed width (i read autogenerated columns , widths can cause performance issues). the amount of row's in grid 300 - 400 5 columns, not huge grid. does have sug

rss - Github pages blog + feedburner feed doesn't work -

i forked tpw's blog github , built blog around it. it's rough version i'd customize. changed rss feed details mine can't feedburner feed work. feedvalidator.org gets me error: "it looks web page, not feed. looked feed associated page, couldn't find one. please enter address of feed validate." so don't redirected standard feedburner page subscribe, rather css-less version of homepage. the new version of google feedburner gets me error: "error on line 57: entity "raquo" referenced, not declared." i have no clue means don't have entity named "raquo" anywhere on website. the old feedburner version gets me similar error (redirected newer google version): "the url entered not appear valid feed. encountered following problem: error on line 57: entity "raquo" referenced, not declared." what problem here? solved deleting , re-creating feed.

cuda - Is any optimization done if one run the same kernel with the same input again and again? -

if run same kernel with same input several times, this #define n 2000 for(int = 0; < 2000; i++) { mykernel<<<1,120>>>(...); } what happens? timed , played around n : halving n (to 1000), halved time took. yet i'm bit cautious belive runs kernel 2000 times because speed non-cuda code dramatic (~900 sec ~0.9 sec). kind of optimization cuda in case? caching results? setting cuda_launch_blocking=1 didn't change nothing. mykernel replaces inner loop in non-cuda code. hardware geforce gtx 260 cuda doesn't optimization of kind, or caching of results. if launch 2000 kernels, runs 2000 kernels. however, kernel launches asynchronous, measuring time taken launch 2000 kernel instances in loop isn't same total execution time of 2000 kernel instances. seeing artifact of incorrect time measurement , not true speed-up.

C Beginner question: Pointer arithmetic > cleaning up once you are done -

i'm getting hang of pointers. there still questions have. is possible cause memory leaks when using pointer arithmetic because shifting actual position of pointer pointing to? i mean, if count upwards copy string char char, need count down c "knows" pointer used point to? thanks frank a memory leak possible when using malloc() or similar functions , not calling free() when it's needed. free() should called pointer returned malloc() , yes if this: int* ptr = malloc(sizeof(int)); free(ptr + 1); causes undefined behaviour. memory leak, maybe segmentation fault, possible.

javascript - usage of jquery .live() to work with both present and future DOM -

i've jquery code as $('#tarea').click(function() { // stuffs }); this works fine button #tarea loaded along script. if button #tarea had been loaded using ajax in future, above code doesn't work. now changed code to $('#tarea').live('click', function() { // stuffs }); this time, button #tarea if loaded along script doesn't work. script works button if generated using ajax. how write script in both cases, works?? .live() works in both cases without doing additional have done. check other problems in code might preventing happening. important: 1 thing check make sure .live() event being bound , doesn't rely on other event happening. might post important parts of javascript file. declare .live() events globally. i this: // mean global because outside document.ready $("#test").live("click", function() { // stuff }); $(function() { // stuff when document ready }); if want pro

sql server 2008 - SQL XML Xquery data query using a variable in the node selection? -

i missing right in front of me, have sql 2008 xml query follows: select distinct cast(customfields_xml.query('data(/root/cf_item_type)') varchar) c1 designs .. trying achieve make "cf_item_type" variable, because want pass in node param proc.. so in reality, trying end like: (@cf passed param, declaring example use) declare @cf varchar set @cf='cf_item_type' select distinct cast(customfields_xml.query('data(/root/@cf)') varchar) cloth designs .. can see trying use @cf variable within xquery statement.. any pointers/help great!! this might want. declare @cf varchar(20) set @cf='cf_item_type' select distinct cast(customfields_xml.query( 'data(/root/*[local-name(.) = sql:variable("@cf")])') varchar(20)) cloth designs

c# - background image of a css loaded as an embedded resource -

i have control created in class library , should styled default css. i've created css file, added library , embedding resource, can used default styling. the css file contains classes set background-image property. images used added embedded resources in library well. expected, css run correctly, not display images since added relative css file, request ../images/my_image.png result in 404 since not exist my_image.png, downloaded .axd resource. any ideas on how overcome this? any , appreciated. kali. why not having done myself remember reading article getting javascript in embedded resource. accessing embedded resources through url using webresource.axd http://www.4guysfromrolla.com/articles/080906-1.aspx

sql - Check whether the schedule overlaps between days -

i need find whether new schedule overlaps existing schedules. this "intervals" table: id first last 1 1900-01-01 09:00 1900-01-01 10:00 2 1900-01-01 15:00 1900-01-01 18:00 3 1900-01-01 18:01 1900-01-01 08:00 i using scalar function dbo.timeonly extracting time part datetime fields. my selection criteria follows first case declare @start datetime declare @end datetime set @start = dbo.timeonly('2011-may-11 08:01:00'); set @end = dbo.timeonly('2011-may-11 15:30:00'); select * intervals ( not ( dbo.timeonly(last) < @start or @end < dbo.timeonly(first) ) ) this return 1st , 2nd records. got logic check whether schedule overlaps each other? second case set @start = dbo.timeonly('2011-may-11 07:01:00'); set @end = dbo.timeonly('2011-may-11 08:30:00'); how write query return 3rd record criteria in second case? update i give

ruby - Rails 3: use contents of an array as variables in a where method -

i have 3 models: isbn, sale , channel. aim: list in isbns show.html.erb view looks this: isbn: myisbn total sales myisbn: 100 myisbn sales channel 1: 50 myisbn sales channel 2: 25 myisbn sales channel 3: 25 here models. isbn.rb model has_many :sales has_many :channels, :through => :sales sale.rb model (has attributes sales_channel_id, isbn_id, quantity) has_many :channels belongs_to :isbn channel.rb model: belongs_to :sale i've been working in isbns controller, in show method, work. thought i'd refactor later - advice on whether of stuff should go in model welcome. so far i've got this: @channelisbn = sale.where("sales_channel_id =?',1).where("isbn_id=?",3) @channelsalesisbn = 0 @channelisbn.each {|y| @channelsalesisbn =+ y.quantity} this gets sales channel id 1 , isbn id 3. it's not use, ids hard coded. got channel ids array: @channellist = channel.all @channel = 0 @channelarray = @channellist.map {|z| @chann

delphi - Connect to Sun LDAP with ADO -

i want connect (and user's group) sun ldap server delphi program. think adsi works microsoft ldap. try ado, can't connect. can show code how this? i think this code fit bill. there more adsi ldap, , experience easier use ldap client connect activedirectory other way around - trying do, unfortunatly. to started, here fail safe way authenticate user. establish connection ldap server service account. if possible, use ldap protocol on ssl, ldaps search username (wich cn=jdoe part) full dn (distinguished name) if have duplicate result, stop here error bind ldap dn , password trying validate. make shure using same validation method on both side. if binds, password valid. close connection established depending on needs, either hold on connection made step 1 or tear down, too.

Contact Form Plugin in Wordpress? -

i'm using contact form 7 form's plugin, need form submitted "thank you" page on success, in order able track objectives in google analytics. contact form 7 uses ajax post form, i'm not able track "message sent" event... do know plugin capabilities? better if it's free... this contact form 7 blog post linked contact form 7 faq shows how track form submissions analytics target. basically hook cf7's on_sent_ok hook , call analytics' _trackpageview() method. lets fire off given analytics target whenever form sucessfully submitted without needing redirection "thank you" page.

jQuery hover() flickering/fading -

trying image "b" overlay on image "a" when mouse hovers on image "a". ideally want fade in. html: <div id="prod-image"> <img src="../imgs/products/mens/image-a.jpg" class="box-shadow" /> </div> <div id="prod-overlay"> <img src="../imgs/image-b.jpg" /> </div> jquery: $(function() { $("#prod-image").hover(function() { $(this).next().fadein().show(); }, function() { $(this).next().fadeout().hide(); }); }); problem every time mouse moves retriggers hover effect meaning blinks on , off retriggers every pixel mouse moves. how can make trigger second action when leave container div, not move within it? thanks help. [edit] css: #prod-overlay { display: none; position: absolute; z-index: 999; top: 0px; } basically sits div on top of other. don't

java - Windows Mobile Bluetooth access on either Microsoft or Widcomm Stack -

i have java application running on windows mobile device. need able turn bluetooth on , off executing native code this. problem trying out on new device (the htc hd2) , native code doesn't work. reason hd2 device using widcomm bluetooth stack, whereas other device using microsoft stack. i have found way of activating bluetooth on hd2 device using widcomm sdk. native code needs able run on device, somehow need able make decision @ runtime code run based on bluetooth stack present. question 1: how can determine programmatically stack present? question 2: if include header file required widcomm stack , try run on device doesn't use code fails. how can compile dll includes header file if widcomm dll exists? i'm guessing can have dynamically: declare prototypes necessary widcomm functions in own code. use loadlibrary load widcomm dll. if loadlibrary call fails know you're on microsoft stack , can run standard microsoft stack functions. if load

how to call this function in a delphi dll from C# -

i have function defined in delphi code: procedure testflashwnew( name: array of string; id: array of integer; var d1:double ); stdcall; how can define , call c#? this bit of messy p/invoke because can't (to best of admittedly limited knowledge) use of built-in easy marshalling techniques. instead need use marshal.structuretoptr this: c# [structlayout(layoutkind.sequential)] public struct myitem { [marshalas(unmanagedtype.lpwstr)] public string name; public int id; } [dllimport(@"mydll.dll")] private static extern void testflashwnewwrapper(intptr items, int count, ref double d1); static void main(string[] args) { myitem[] items = new myitem[3]; items[0].name = "jfk"; items[0].id = 35; items[1].name = "lbj"; items[1].id = 36; items[2].name = "tricky dicky"; items[2].id = 37; intptr itemsptr = marshal.allochglobal(marshal.sizeof(typeof(myitem))*items.length); t

c - Linux GCC Compiler Output in Mint: What to do with the file? -

i wrote simple c program. saved "c" suffix. went terminal (in linux mint), typed in gcc -o outputfile inputfile.c in directory containing inputfile.c file called outputfile appeared, expected. want run program, clicking on file nothing. what doing wrong? the program running, you're not seeing output because terminal isn't open. open terminal , run ./outputfile if program opened window, see clicking on file.

c# - Annoying exceptions in Silverlight 4 with async validation (RIA Services) -

i've set custom validation sivlerlight project. there's grid, , makes sure entry unique going off server , performing check in domainservice. the property given attribute tell use custom validator, , validator calls function in domainservice called 'isusernameunique'. now then, problem this: exception , program died. if detatch project, 3 error messages (they same - 'isusernameunique' failed validation. please inspect validationerrors on operation details). if click through them, see grid , validation message wanted! mean works... sort of. has these exceptions don't want end user see. any suggestions? are specifying custom validation attribute viewmodel property? verify binding created (validatesonexceptions, notifyonvalidationerror set accordingly). a code example helpful too.

java - Client-server application file transfer -

i trying design client-server application, this: user connects server , when authentication ok server send user files. problem files written in single file (with method). here code: the function transfers file public void processfile(int id, dataoutputstream ostream, socket socket, int tip){ string filename; if(tip==0){ filename="file"+integer.tostring(intrebari[id])+".txt"; }else{ filename="image"+integer.tostring(intrebari[id])+".jpg"; } byte[] buffer=null; int bytesread = 0; fileinputstream file=null; try { file = new fileinputstream(filename); buffer = new byte[socket.getsendbuffersize()]; while((bytesread = file.read(buffer))>0) { ostream.write(buffer,0,bytesread); } file.close(); } catch (ioexception ex) { system.out.println(ex

html - Create Firefox addon to fix broken webpage on the fly -

at job use "central login" facility on internal webpages. whenever internal webpage requires authentication, forwards central login, , after logging in, sends page trying view. the first line in html central login page starts this: <!-- encoding=iso-8859-1; but never ends comment, means html code in whole document commented out. works fine in ie6 (which company standard - eek!), , used work in firefox, when upgraded firefox 4, no longer works (as shouldn't - following standards). i have saved source , changed first line to: <!-- encoding=iso-8859-1; --> and page display, since loaded file:/// , can't submit credentials main server... i hate using ie6, internal pages stuck because firefox renders empty page every time sent central login. is possible create firefox addon (or greasemonkey script) modify html coming browser before gets rendered? see tons of examples of modifying html once loaded, can't find manipulate while loading it

What setting will prevent "vi" to show the editing window after exiting? -

i tried search answer, maybe i'm phrasing question wrong, couldn't find it. so, in own linux environment, when exit "vi", content of editing window stays in shell window. cannot scroll see previous commands typed before entering "vi". i've been in environment (as different user) once exit "vi", vi command shows 1 regular command line following earlier commands typed. tried setting behavior, liked, couldn't. can please me? it isn't vi setting per se; in terminfo entry use ( $term ). check on other user has set $term , , compare have set. then, either change term value, or modify terminal entry use. infocmp decompiles terminal entries; tic compiles them. can create own directory hold entry if can't modify system 1 (or while testing modifications): mkdir $home/terminfo export terminfo=$home/terminfo tic -o $terminfo new.terminfo.src etc.