Posts

Showing posts from September, 2013

c# - Custom app.config section with a simple list of "add" elements -

how create custom app.config section simple list of add elements? i have found few examples (e.g. how create custom config section in app.config? ) custom sections this: <registercompanies> <companies> <company name="tata motors" code="tata"/> <company name="honda motors" code="honda"/> </companies> </registercompanies> but how avoid collection element ("companies") looks same appsettings , connectionstrings sections? in other words, i'd like: <registercompanies> <add name="tata motors" code="tata"/> <add name="honda motors" code="honda"/> </registercompanies> full example code based on op config file: <configuration> <configsections> <section name="registercompanies" type="my.myconfigsection, my.assembly" /> </config...

cmdlet - PowerShell Advanced Function get current ParameterSetName -

in c# can current parametersetname in processrecord override of powershell cmdlet code this: switch (parametersetname) { case fromuriparamsetname: loadfromuri(); break; case fromfileparamsetname: loadfromfile(); break; } i'm trying figure out how can value parametersetname in script cmdlet (advanced function). as way expand awesome answer: switch ($pscmdlet.parametersetname) { "fromfile_paramset" { } "fromuri_paramset" { } "__allparametersets" { } } the __allparametersets default option in ps

objective c - how do i access GData api's(get map) in my application in iphone? -

how access gdata api's(get map) in application ? hey tryed add gdata.framework in iphone application generate error , tell me in iphone how can use web service? you can use gdata-objective-client . it can compiled static library. once set in application have @ example applications - mapsample come library how access gdata map api.

Rails - How do I write this string condition as an array condition -

named_scope :correct, :include => :correction, :conditions => "checked_at not null , corrections.id null" on side note have googled loads , looked through books cant seem find list of various types of conditions can use , how differ when implenting them strings, arrays or hashes. is there list of syntax anywhere? the string posted correct. also, there's no way express same condition using arrays or hashes. array–syntax , hash-syntax useful when need interpolate values. instance, following condition named_scope :is_one, :conditions => "field = '1'" can written as named_scope :is_one, :conditions => ["field = ?", "1"] or named_scope :is_one, :conditions => { :field => "1" } the hash-syntax subset of array-syntax , supports limited set of operators. instance, can transform named_scope :is_one, :conditions => ["field1 = ? , field2 in (?)", "1", ["foo...

wcf - Service Contract Implements another Interface -

please tell me if possible. have client win form app , wcf app in c#. model. common project public interface iservicea { string doworka(); } i not using servicecontract or operationcontract attributes here in common project. now, clientproject references common project. serviceproject references common project. in serviceproject, using service contract shown below: [servicecontract] public interface igetdata : iservicea { // implements iservicea method [operationcontract] string doworka(); } public class myservice : igetdata { string doworka() { } } in client side public class myclass : iservicea { // implements iservicea method string doworka() { // inside call myservice using duplexchannel proxy } } [please assume callback contract implemented in model] why asked question that, in application, have lot of modules, each needs data service own method. planning use facade pattern. please tell me if correct ...

java - hibernate restrictions.in with and, how to use? -

i have table below id, employee_no, survey_no, name 1 test 1 test_name 2 test2 1 test_name2 3 test3 1 test_name3 4 test4 2 test_name4 how query restriction.in combining below , 1 in statement? in[ (if(survey_no==1) && employee_no== 'test') , (if(survey_no==1) && employee_no== 'test2') , ... ] i think criteria combination want use (btw. easier hibernate entity bean definition instead of table structure): string[] employeenames = { "test", "test2" }; list<survey> surveys = getsession().createcriteria(survey.class).add( restrictions.and ( restrictions.eq("surveynumber", 1), restrictions.in("employeename", employeenames) ) ).list();

build - Creating an on Demand Deployment from TFS using a label -

i have build scripts builds, test, version , packages projects artifacts staging area each of our environments ready versioned release given environment (and labels changeset). want stop doing automatically , deploy on demand. my problem using tfs , friction immense. want have easy way specific version source control build specific enviroment -done deploy it. -done the last 2 steps trival. "getting label" not fun tfs. any ideas/pointers other use stop using tfs? just ask on twitter next time :-) seriously though, have @ tfs deployer on codeplex. way works normal build versioning of output would, pull out deployment stuff it. next, setup tfs deployer - listens changes in build quality , fires off powershell script write deployment work. example, when change quality of build "deploy uat" can fire off powershell script whatever need to. deploy go build explorer, set quality whatever want , let powershell rest - you'll email of results kn...

java - How to use third party themes in swing application? -

i want use third party themes (like synthetica http://www.javasoft.de/synthetica/themes/ ) in swing appliaction. using eclipse ide , got jar file of theme , did following modification(according readme file theme) in code try { uimanager.setlookandfeel(new syntheticablackmoonlookandfeel()); } catch (exception e) { e.printstacktrace(); } but after modification showing following error type de.javasoft.plaf.synthetica.syntheticalookandfeel cannot resolved. indirectly referenced required .class files what mean? tried searching on net cant find useful answers contents of readme file: system requirements =================== java se 5 (jre 1.5.0) or above synthetica v2.2.0 or above integration =========== 1. ensure classpath contains synthetica libraries (including synthetica's core library 'synthetica.jar'). 2. enable synthetica , feel @ startup time in application: import de.javasoft.plaf.synthetica.syntheticablackmoonlookand...

Java error: cannot find symbol -

help don't know do, why i'm getting error. score.java:44: cannot find symbol symbol : class invalidtestscore location: class score catch (invalidtestscore e) ^ 1 error // george beazer import javax.swing.*; import javax.swing.joptionpane; public class score { public static void main(string[] args) { int numberoftests = 0; double[] grade = new double[numberoftests]; double startgrade = 0; int x = 1 ; string strinput; // how many tests used strinput = joptionpane.showinputdialog(null, "how many tests have? "); numberoftests = integer.parseint(strinput); grade = new double[(int) numberoftests]; { (int index = 0; index < grade.length; index++) { strinput = joptionpane.showinputdialog(null, "enter test score." + (index + 1)); grade[index] = double.pars...

c++ - Problem In Separating The Interface And The Implementation -

its first time trying separate class in separate header file getting error.please me out.thanks code: my main function: #include <iostream> #include <myclass> int myclass::data; int main() { cout<<"data="<<myclass::data; system("pause"); return 0; } myclass.h #ifndef myclass #define <myclass> class myclass { static int data_; }; #endif error: fatal error c1083: cannot open include file: 'myclass.h': no such file or directory you should use #include "myclass.h" angle brackets system headers. also it's data or data_ ? also better like #if !defined(myclass_h_included) #define myclass_h_included ... #endif #define -ing name identical class name going source of problems

asp.net - My pay pal button will not link to pay pal. It only refreshes page, why? -

i have following code in registration page go paypal button. when click on button refreshes page. is missing? should able include paypal button on aspx page right? <asp:content id="content1" contentplaceholderid="head" runat="server"> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <asp:panel runat="server" id="pnlregisterpage" cssclass="registerpage"> <table> <tr> <td><p>plain text</p></td> <td> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="z8tackrhqr722...

centos - Git repo planning questions -

at work, development uses perforce handle code sharing. won't "revision control", because aren't allowed check in changes until ready regression testing. in order personal change sets under revision control, i've been given go-ahead build own git , initialize client view of perforce depot git repo. there difficulties in doing this, however. the client view lives in subfolder of ~ , ( ~/p4 ), , want put ~ under revision control well, own separate history. can't figure out how keep history ~ separate ~/p4 without using submodule. problem submodule looks have go make repository become submodule , git submodule add <repo> <path> . there make submodule's repository except in ~ . there seems no safe place create initial client view of depot git p4 clone. (i'm working off of assumption initing or cloning repo subdirectory of git repo not supported. @ least, can find nothing authoritative on nested git repos.) edit: merely...

javascript - What's the difference between Require.js and simply creating a <script> element in the DOM? -

what's difference between using require.js amd creating <script> element in dom? my understanding of require.js offers ability load dependencies, can not done creating <script> element loads necessary external js file? for example, lets assume have function dostuff() , requires function needme() . dostuff() in external file do_stuff.js , while needme() in external file need_me.js . doing require.js way: define(['need_me'],function(){ function dostuff(){ //do stuff needme(); //do more stuff } }); doing creating script element: function dostuff(){ var scriptelement = document.createelement('script'); scriptelement.src = 'need_me.js'; scriptelement.type = 'text/javascript'; document.getelementsbytagname('head')[0].appendchild(scriptelement); //do stuff needme(); //do more stuff } both of these work. however, second version doesn't require me load ...

c# - Sanitizing incoming XML via WCF -

i consuming java webservice .net using wcf. i getting error on deserialization of response java service the byte 0x00 not valid @ location. line 1, position 725. i know research incorrectly encoded null, unlikely provider change it, sanitize null out before wcf deserializes return message. any ideas? i using c#, answers in clr language do. just thought. character encoding issue i.e. deserializer using incorrect encoding when trying deserialize message? may result in appear nulls, in fact part of underlying character encoding.

django, phpmyadmin and mysql? -

i start using django mysql, instead of sqlite time, experience using msql through xampp, manipulating databases through phpmyadmin. keep gui interaction mysql , not have through command line. can start , manage mysql database using xampp/phpmyadmin, , use django web development side using django'sn development server? or have start new databases through command line, , if how done, bearing in mind ever use mysql through xampp/phpmyadmin? i know how link , manage database through django, dont know how start mysql 1 through it, , dont want have loose mysql gui comes xampp/phpmyadmin. appreciated. you can manage mysql through xampp interface. try setting db_host in settings.py "localhost". if doesn't work, try "127.0.0.1". typically caused python-mysql module expecting mysql unix socket in place is. actually, i'm unsure if mysql server uses unix socket on windows. anyway, 1 of both should work :) can use credentials use login phpmyadmin d...

asp.net - WCF error over the internet only -

i have wcf problem. been stuck here days. i have wcf service , client working on intranet. i deployed same service/client on our iis server exposed on internet. service, able access workstatation, using internet site (the .com address) however, when accessing same .com site using computer not connected our network, it's giving me dreaded "the http request unauthorized client authentication scheme 'negotiate'. authentication header received server 'negotiate, ntlm'" when accessing service other info: client authenticates me. when client accessing wcf service, error. client web.config: <system.servicemodel> <bindings> <basichttpbinding> <binding name="basichttpendpoint" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00" allowcookies="true" bypassproxyonlocal="false" hostnamecomparisonmode=...

java - Problem uploading a file with ajax in appengine -

i need send content of file spring webservice ajax in google appengine application. i've used jquery ajaxfileupload plugin . <form id="load_form" action="" enctype="multipart/form-data"> <input name="file" type="file" id="upload_files" value="browse"/> <input type="button"" id="upload_file" value="load file"/> </form> the javascript looks this: $("#upload_file").click(function(){ $.ajaxfileupload ( { url: '/myproject/uploadfile.json', secureuri: false, fileelementid: 'upload_files', datatype: 'json', success: function (data, status) { alert("ok"); }, error: function (data, status, e) { alert("error")...

.net - Can I create thread safe objects with ContextBoundObject? -

i have object serves multiple requests (threads) ... think of sqlconnection object across multiple threads .... now, want create "thread" safe object aware of thread context in created . so if thread1 creates object foo , thread2 tries access .... object foo ignore , "act" if thread1 running ... will contextboundobject this? if yes, limitations? pseudo code public class foo { private int _threadid; public void dosomething() { (if thread.managedthreadid != _threadid) return; // thread safe stuff } } behavior want achieve can made using synchronizationattribute . however, using attribute serialize access members of class. on other hand if methods of class not require synchronization (like static method not share state) using synchronization attribute may result in degraded performance.

syntax - Acessing struct fields within an assembly X64 function -

is possible access directly struct fields within assembly function? , how can access via assembly global variable? in inline assembly on intel syntax can this: struct str { int a; int b; } int someglobalvar; __declspec(naked) void __fastcall func(str * r) { __asm { mov dword ptr [ecx].a, 2 mov dword ptr [ecx].b,someglobalvar } } how do in assembly x64 function (not inline), att syntax (gcc), if it's not possible how do in inline function? for many similar problems, easiest solution write example in c want, use gcc -m64 -s ... generate assembler source, , use source template own assembly code. consider following example: #include <stdio.h> typedef struct { int a; int b; } s; int foo(const s *s) { int c = s->a + s->b; return c; } int main(void) { s s = { 2, 2 }; printf("foo(%d, %d) = %d\n", s.a, s.b, foo(&s)); return 0; } if generate asm using gcc -wall -o1 ...

jsf 2 - JSF - List of objects in a Managed Bean and memory management question -

i creating first jsf application. question going simplify try , make question clear possible. the application creating simple contact storing application allow create new contact, store information such addresses, phone numbers, work, , upload files associated contact. when application loads user displayed list of contacts have been created. can click on contact's image open contact , view of information stored on them. question comes in. all of information stored in contactmanager.java managed bean. of data on contact displayed in datatables. there address datatable, phone datatable, uploads datatable. each datatable view resides within appropriate tab. using primefaces create tabs. when contact opened system has load maybe 10 lists of data dropwdown lists used select values. populate these datatables in tabs. @managedbean @viewscoped public class contactmanager implements serializable { private contact contactinfo; private list<phone> phones; pr...

javascript - Django Admin: Pre-populating values from POST or GET? -

in django 1.2.4 site, direct user admin page pre-filled out values, based on current data working with. example: {% person in people %} <tr> <td>{{person}}</td> <td><a href='admin/foo/bar/add?name={{person}}'>create foo {{person}}</td> </tr> {% endfor %} then, when user clicks on link, name field pre-populated value {{person}} . does django admin interface support doing this? django admin forms use post, i'm not sure how add post data request template. or, set variables, use custom javascript in form set values accordingly. according source code (and quick test), django support use of parameters initial values modelforms in admin. supports many-to-many relations. did try this? maybe it's missing slash @ end of url. admin/foo/bar/add?name=foobar probably gets redirected ... admin/foo/bar/add/ ... dropping querystring. try add slash there , see if works. admin/foo/bar/add/?...

c# - How can I make my Windows Forms application 'listen' for global key presses? -

i'm making little application taking notes. when type 'note' anywhere on computer, window pop , show me textbox me type in , save xml. i'm stumped on how program 'listen' keypresses. i'll have app running on system tray if that's help. :) take @ http://www.codeproject.com/kb/cs/globalhook.aspx besides question has been asked around in already. take @ here: global keyboard hooks (c#) global keyboard capture in c# application best way tackle global hotkey processing in c#?

asp.net mvc 3 - MVC3/Razor Client Validation Not firing -

i trying client validation working in mvc3 using data annotations. have looked @ similar posts including mvc3 client side validation not working answer. i'm using ef data model. created partial class validations. [metadatatype(typeof(post_validation))] public partial class post { } public class post_validation { [required(errormessage = "title required")] [stringlength(5, errormessage = "title may not longer 5 characters")] public string title { get; set; } [required(errormessage = "text required")] [datatype(datatype.multilinetext)] public string text { get; set; } [required(errormessage = "publish date required")] [datatype(datatype.datetime)] public datetime publishdate { get; set; } } my cshtml page includes following. <h2>create</h2> <script src="@url.content("~/scripts/jquery.validate.min.js")" type="text/javascript"></script> <...

Is there a way to concat C# anonymous types? -

for example var hello = new { hello = "hello" }; var world = new { world = "world" }; var helloworld = hello + world; console.writeline(helloworld.tostring()); //outputs {hello = hello, world = world} is there way make work? no. hello , world objects objects of different classes. the way merge these classes use dynamic type generation ( emit ). here example of such concatenation: http://www.developmentalmadness.com/archive/2008/02/12/extend-anonymous-types-using.aspx quote mentioned article: the process works this: first use system.componentmodel.getproperties propertydescriptorcollection anonymous type. fire reflection.emit create new dynamic assembly , use typebuilder create new type composite of properties involved. cache new type reuse don't have take hit of building new type every time need it.

javascript - handling redirect while loading JS through Script Tag in Head of HTML document -

there 2 cases: 1) loading js file facebook site using script tag.if site blocked network access manager (websense) getting 302 response , autmatically redirected page. how handle condition ? 2) if point #1 passes internally creates iframe , try access facebook site if blocked same thing happen time text appear on page along other page content visible user. how handle ? please me out here. regards, pv the easiest way handle first case check variable or namespace loaded javascript facebook. // lets assume facebook js file contains "fb" namespace if(fb || window.fb){ // action since have facebook loaded var fbframe = document.getelementsbytagname('iframe')[0]; fbframe.onerror = function(){ // facebook failed load :( redirect window.location.href = "someotherpage.html"; }; }else{ // facebook failed load :( redirect window.location.href = "someotherpage.html"; } for second part, can add onerror event listener...

entity framework - What is the meaning of the "Pluralize or singularize generated object names" setting? -

when setting new entity data model, there option to [x] pluralize or singularize generated object names i have noticed option in linq well. also, studying ado.net entity framework, noticed has 'default' 'pluralize or singularize generated object names' what result of not checking/allowing option when setting 'entity data model'. what advantages/disadvantages/issues face making selection 1 way or other? no problem @ all, except you'll want manually. usually, want entity names singular , entity set names plural.

c++ - converting a byte array into a in_addr or in6_addr and endianness -

i'm concerned endianness when comes problem. maybe overthinking have worry about. the input code packet looks like: i've received network packet contains bytes. if know index in byte array (and have valid data) of in_addr is, safe like: uint8_t* addrptr = packet[ip_idx]; struct in_addr addr; memcpy((void*) addr, addrptr, sizeof(in_addr)); is safe regardless of endianness? what in6_addr 16 bytes? thanks. struct in_addr supposed in network byte order, iirc. assuming packet delivered in network byte order, you're go.

c# - TabPage Validating event firing when clicked on the currently selected tab -

i'm doing things said in how prevent user changing selected tab page in tabcontrol? things working fine. validating event of tabpage1 occurs if i've tabpage1 selected , user clicks on tabpage1 itself. , later when user clicks on tabpage2 validating event tabpage1 doesn't fire. what happens if e.cancel in validating event of tabpage1, in above case, when user clicks on tabpage1 mistake having tabpage1 selected, prompt user "do want stay on current tab save data or move current tab?". , if user clicks stay doesn't changes. , when correctly clicks tabpage2, validating event of tabpage1 not firing. i've uploaded sample application here . can run , see behavior understand problem use tabcontrol.selecting event instead. use this: tabcontrol1.selecting += tabcontrol1_selecting; private void tabcontrol1_selecting(object sender, tabcontrolcanceleventargs e) { e.cancel = !(can switch tab); }

java - synchronizing global variables in a servlet -

i have couple of global variables in servlet. individual servlet sessions read , wrote these variables. used coordinate values posted database important sessions remain in synch. question can use synchronize key words servlets keep different servlet sessions colliding each other @ these global variables? thank you, i'd recommend not doing stuff in servlet class itself. have servlet's doget() etc. call object real work. if delegated class singleton have full control on initialization, state etc. if rely on how app server loads servlet class things can brittle. best let server classload/share servlet whenever feels , not depend on specific behavior.

console.log is not working in Android 2.1 emulator -

i'm running 1 web application... in android emulator browser. in 1 javascript file i'm trying output string as: console.log("android"); but didn't got log using adb logcat. i tried start adb logcat firstly , tun app, didn't log message used in console.log is there way can log message? there info on nitobi/phonegap blog: http://blogs.nitobi.com/joe/2010/02/26/console-log-on-android-webview/

php - codeigniter find by library? -

is there codeigniter plugin allows me create find functions without writing code on every field in db table? i find myself writing lot of functions tables such findbyid findbyfirstname findbyemail , on, libraries written speedup dev time? tried googling havent come across any. if mean have write multiple methods in model find rows in table specific field, pass associative array containing fields , values want search generic function - like: function search_mytable($search=array()) { $this->db->select('mytable.*'); $this->db->from('mytable'); if(!empty($search) $this->db->where($search); } there's more information can pass ci active record method here http://codeigniter.com/user_guide/database/active_record.html#select

Add javascript using XSLT -

i'm looking simple insert of javascript in xslt. e.g. <xsl:variable name="comboname" select="@name" /> <script type="text/javascript"> var z{$comboname} = {$comboname}; </script> however, when run transform gives: <script type="text/javascript"> var z{$comboname} = {$comboname}; </script> i've debugged , $comboname has correct value...but how javascript? many thanks! var z<xsl:value-of select="{$comboname}"/>=<xsl:value-of select="{$comboname}"/>;

javascript - XML Outputting - PHP vs JS vs Anything Else? -

i working on developing travel website uses xml api's data. however relatively new xml , outputting it. have been experimenting using php output test xml file, furthest iv got output few records. as questions states need know technology best project. below iv included points take consideration. the website going large sized, heavy traffic site (expedia/lastminute size) my skillset php (intermediate/high skilled) & javascript (intermediate/high skilled) below example of xml api outputting: <?xml version="1.0"?> <response method="###" success="y"> <errors> </errors> <request> <auth password="test" username="test" /> <method action="###" sitename="###" /> </request> <results> <line id="6" logourl="###" name="line 1" smalllogourl="###"> <sh...

algorithm - How can I better understand the one-comparison-per-iteration binary search? -

what point of one-comparison-per-iteration binary search? , can explain how works? there 2 reasons binary search 1 comparison per iteration. less important performance. detecting exact match using 2 comparisons per iteration saves average 1 iteration of loop, whereas (assuming comparisons involve significant work) binary searching 1 comparison per iteration halves work done per iteration. binary searching array of integers, makes little difference either way. expensive comparison, asymptotically performance same, , half-rather-than-minus-one isn't worth pursuing in cases. besides, expensive comparisons coded functions return negative, 0 or positive < , == or > , can both comparisons pretty price of 1 anyway. the important reason binary searches 1 comparison per iteration because can more useful results some-equal-match. main searches can are... first key > goal first key >= goal first key == goal last key < goal last key <= goal last key ...

PHP Undefined Constant PHP_ROUND_HALF_DOWN -

i have php code in project i'm working on uses php's round function. on localhost, don't include quotes around mode argument, stating php_round_half_down. however, when pushing server error message: use of undefined constant php_round_half_down - assumed 'php_round_half_down' warning (2): wrong parameter count round() [app/views/helpers/time_left.php, line 14] now, when add single quotes mode argument, first error goes away, "wrong parameter count" remains. i'm calling function follows: $days = round(($difference/$day), 0, php_round_half_down); thanks , help! the rounding mode added in php 5.3. make sure you're running @ least version. you can see version you're running placing following in php file: var_dump(phpversion());

jsp - Getting current date in JSTL EL and doing arithmetic on it -

without using scriptlets, what's correct way doing date arithmetic in jsp? here examples i'm trying do: get current year (yyyy) subtract current year 1 previous year (yyyy) thanks! use <jsp:usebean> construct new date . use jstl <fmt:formatdate> year out of it. use el substract it. <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <jsp:usebean id="now" class="java.util.date" /> <fmt:formatdate var="year" value="${now}" pattern="yyyy" /> <p>current year: ${year}</p> <p>previous year: ${year - 1}</p> result: current year: 2011 previous year: 2010 note pattern full year yyyy , not yyyy .

Creating a JQuery Slideshow of a Background-Image -

i have element serves banner on website. banner has html content on it, uses high-resolution picture background-image. because of this, i'm loading background-image last , fading in when has been downloaded. code looks this: <table id="bannertable" border="0" cellpadding="0" cellspacing="0" style="width:640px; height:480px;"> <tr><td style="padding-top:20px; padding-left:300px;"> <div>[some text]</div> </td></tr> <tr><td style="vertical-align:bottom; padding-bottom:20px;"> <div>[site menu goes here]</div> </td></tr> </table> <script type="text/javascript"> $(document).ready(function () { $("#bannertable").loadbgimage("/picture1.png"); }); $.fn.loadbgimage = function (url) { var t = this; $('<img />') .attr('src...

java - How to add local jar files to a Maven project? -

how add local jar files (not yet part of maven repository) directly in project's library sources? install jar local maven repository follows: mvn install:install-file -dfile=<path-to-file> -dgroupid=<group-id> -dartifactid=<artifact-id> -dversion=<version> -dpackaging=<packaging> -dgeneratepom=true where: <path-to-file> path file load <group-id> group file should registered under <artifact-id> artifact name file <version> version of file <packaging> packaging of file e.g. jar reference

javascript - jQuery selector loads images from server -

here code: <script type="text/javascript"> var ajax_data = '<ul id="b-cmu-rgt-list-videos"><li><a href="{video.url}" '+ 'title="{video.title.strip}"><img src="{video.image}" '+ 'alt="{video.title.strip}" /><span>{video.title}</span></a></li></ul>'; var my_img = $(ajax_data).find('img'); </script>` ajax_data data js template engine need part of it. problem jquery on the img src={video.image}: /test/%7bvideo.image%7d http/1.1 (on firefox live http headers). generates 404 server. any clues on how solve this? lot :) when create jquery object html, it's evaluated (because document fragment created), this: $("<img src='bob.jpg' />") immediately causes fetch of image. way see had 3 quick options (and others, hard without more context question): ...

objective c - Check if a method exists -

is there way can test if method exists in objective-c? i'm trying add guard see if object has method before calling it. if ([obj respondstoselector:@selector(methodname:withetc:)]) { [obj methodname:123 withetc:456]; }

excel - How to avoid OLEDB converting "."s into "#"s in column names? -

i'm using ace oledb driver read excel 2007 spreadsheet, , i'm finding '.' character in column names converted '#' character. example, if have following in spreadsheet: name amt. due due date andrew 12.50 4/1/2010 brian 20.00 4/12/2010 charlie 1000.00 6/30/2010 the name of second column reported "amt# due" when read following code: oledbconnection connection = new oledbconnection( "provider=microsoft.ace.oledb.12.0; data source=myfile.xlsx; " + "extended properties=\"excel 12.0 xml;hdr=yes;fmt=delimited;imex=1\""); olddbcommand command = new oledbcommand("select * mytable", connection); oledbreader datareader = command.executereader(); system.console.writeline(datareader.getname(1)); i've read through documentation can find , haven't found mentions happen. has run before? there way fix behavior? see oledbadapter excel ...

Parsing Email header fields using C/C++ -

i've c code fetch headers mails in inbox via imap issuing uid fetch 1:* (flags body[header]) command. due special authentication requirements cannot use standard imap library vmime or libetpan. need parse mail header values in accordance rfc 822. have library/function in c/c++ job ? mimetic works great ! takes care of non-standard mail headers.

python - FTP filename encoding -

hi use twisted library connect ftp server have problem filename encoding. receive 'illusion-n\xf3z.txt' not unicode. there ftp command force specific encoding? in advance! mk there 2 possibilities: ftp not unicode aware. looks server you're talking in example sending latin-1 encoded bytes. need decode bytes using encoding when receive them. there an rfc updates ftp utf-8-aware. check results of feat command see if utf8 there (but isn't, since example bytes not valid utf-8). if is, decode bytes using utf-8. twisted's ftp client won't unicode-related it, since implements basic ftp rfc.

javascript - How to get Firebug to tell me what error jquery's .load() is returning? -

i'm trying find out data/error jquery's .load() method returning in following code (the #content element blank assume there kind of error). where find in firebug content or error .load() returning? how can use console.log find out @ least content being returned? alt text http://www.deviantsart.com/upload/ksqe5b.png <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("jquery", "1.3.2"); google.setonloadcallback(function() { $('#loadbutton').click(loaddatafromexernalwebsite); }); function loaddatafromexernalwebsite() { ...

objective-c determine if parameter is an object -

in objective-c have function prototype: -(nsstring*)formatsql:(nsstring*) sql, ... may pass function type of parameters: nsstring, nsnumber, integer, float how can determine in function if parameter object (nsstring..) or primitive (integer...)? brochpirate if you're going have parameter accepts multiple types, can safely using obj-c objects, means using id type. can't safely inter-mingle id float , integer etc. if wrapped float s , int s in nsnumber s, have method so: - (nsstring *)formatsql:(id)obj { if ([obj iskindofclass:[nsstring class]]) { // format string } else if ([obj iskindofclass:[nsnumber class]]) { // further processing required differentiate between ints , floats } } there few caveats using iskindofclass: , should serve starting point.

mysql - Request to select the last 10 send/received messages to/by different users -

i want select 10 last messages received or sent different users. for example results must shown that: 1. john1 - last message received 04/17/10 3:12 2. thomy - last message sent 04/16/10 1:26 3. pamela - last message received 04/12/10 3:51 4. freddy - last message received 03/28/10 9:00 5. jack - last message sent 03/20/10 4:53 6. tom - last message received 02/01/10 7:41 ..... table looks like: create table `messages` ( `id` int(11) not null auto_increment, `time` timestamp not null default current_timestamp, `sender` int(11) default null, `receiver` int(11) default null, `content` text ) i think facebook (and iphone) uses solution. when go mail box, have last messages received/sent grouped users (friends). so take example. if have theses messages (they ordered yet): **mike** **tom** **pam** mike mike **john** john pam **steve** **bobby** steve steve bobby only message **** should returned because last messages sent/received user. in fact want last ...

sql - Custom Result Order using UNION - TSQL -

i have simple task in need select rows particular field value of 1 first, value of 2 , other rows value of 0. i using join items member of category. thought performing 3 selects , using union combine results in correct order, wrong :) my sql follows: select * tblcompanycategory inner join tblcompany on tblcompany.idcompany = tblcompanycategory.idcompany tblcompanycategory.idcategory = @category , tblcompany.intpremium = 1 union select * tblcompanycategory inner join tblcompany on tblcompany.idcompany = tblcompanycategory.idcompany tblcompanycategory.idcategory = @category , tblcompany.intpremium = 2 union select * tblcompanycategory inner join tblcompany on tblcompany.idcompany = tblcompanycategory.idcompany tblcompanycategory.idcategory = @category , tblcompany.intpremium = 0 my results not come out ordered 1, 2 , 0.. doing wrong here?? * solution * guys. below final sql using. select * tblcompanycategory inner join tblcompany on tblcompany.idcompany = ...

javascript - Exposing server-side state through client-side controls in ASP.net -

hopefully isn't redundant question--i'm not sure how word it. let's have list of items on asp.net page. list selectable in whenever user clicks on one, page postback , server code stores index or unique identifier of picture in viewstate property indicating selected. i minimize load on server , therefore store index or unique identifier representing image in way on client side. best way can think store said information in hidden field ), had 2 questions before go crazy: is security risk in way, shape or form (i.e., exposing implementation details of page)? is there better/best way more industry-standard? asp.net provide framework cleaner idea? seems common requirement me... i have been working in asp.net 2 years now. please, kind :-) best, patrick kozub the security risk if list items must remain non-selectable. sounds not case in situation. user knows information, because or selected item. note: if server ever information , pulls user, must valid...

c - Mac gcc trying to link against old, nonexistent library -

i'm writing simple c program uses taglib library. had installed library in /usr/local , compiled , linked program against it. i've since removed library , attempting link against compiled version of library in location. problem when compile program now, compiles cleanly, when attempting run it, program looking library used exist in /usr/local/lib instead of new location. example, code , new taglib library in /users/mdi/code/tag. i'm compiling program this: cc main.c -wall -i./taglib/bindings/c -o tag -l./taglib/bindings/c/.libs -ltag_c like said, compile completes no errors or warnings. when attempting run binary, error: dyld: library not loaded: /usr/local/lib/libtag_c.0.dylib referenced from: /users/mdi/code/tag/./tag reason: image not found trace/bpt trap running 'otool -l' on binary shows this: tag: /usr/local/lib/libtag_c.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current...

php - symfony Warning: array_merge(): Argument #2 is not an array in /home/ -

i getting started symfony , trying build database following error: ./symfony doctrine:build --model warning: array_merge(): argument #2 not array in /home/nicky/symfony/symfony-1.4.8/lib/plugins/sfdoctrineplugin/lib/task/sfdoctrinebasetask.class.php on line 182 i have following in schema.yml # config/doctrine/schema.yml jobeetcategory: actas: { timestampable: ~ } columns: name: { type: string(255), notnull: true, unique: true } jobeetjob: actas: { timestampable: ~ } columns: category_id: { type: integer, notnull: true } type: { type: string(255) } company: { type: string(255), notnull: true } logo: { type: string(255) } url: { type: string(255) } position: { type: string(255), notnull: true } location: { type: string(255), notnull: true } description: { type: string(4000), notnull: true } how_to_apply: { type: string(4000), notnull: true } token: { type: string(255), notnull: true, unique: true } is_public: { type:...

Best practices for deploying a high performance Berkeley DB system -

i looking use berkeley db create simple key-value storage system. keys sha-1 hashes, in 160-bit address space. have simple server working, easy enough written documentation berkeley db website. however, have questions how best set such system, performance , flexibility. hopefully, has had more experience berkeley db , can me. the simplest setup single process, single thread, handling single db; inserts , gets performed on 1 db, using transactions. alternative 1: single process, multiple threads, single db; inserts , gets performed on db, threads in process. does using multiple threads provide performance improvements? there 1 single db, , therefore it's on 1 disk, , therefore guessing won't boost. if berkeley db caches lot of stuff in memory, perhaps 1 thread able run , answer cache while has blocked waiting disk? using gnu pth, user level cooperative threading. not familiar details of pth, not sure if pth can have userlevel thread run while userlevel thread has bloc...

javascript - Enclosure Memory Copies -

function myclass() { //lots , lots of vars , code here. this.bar = function() { //do numerous enclosed myclass vars } this.foo = function() { alert('hello'); //don't enclosed variables. } } each instance of myclass gets own copy of bar , foo, why prototyped methods use less memory. however, know more memory use of inner methods. it seems obvious me (1) below must true. agree? not distinct myclass instances have own distinct copies of bar, must have own distinct copies of myclass enclosure. (or else how bar method keep myclass variables straight on per instance basis?) now (2) question i'm after. since inner foo method doesn't use in myclass enclosure natural qustion is: javascript smart enough not keep myclass enclosure in memory use of foo? this depend entirely on implementation not language. naive implementations keep far more around others. answer true e.g. v8 (chrome's js engine) may not true spider...

c++ malloc segmentation fault -

i have problem malloc(). weird. code in following. use random generator generate elements array. array opened malloc(). if array size smaller 8192, ok. if size larger 8192, shows segment fault. void random_generator(int num, int * array) { srand((unsigned)time(0)); int random_integer; for(int index=0; index< num; index++){ random_integer = (rand()%10000)+1; *(array+index) = random_integer; cout << index << endl; } } int main() { int array_size = 10000; int *input_array; input_array = (int*) malloc((array_size)); random_generator(8192, input_array); // if number larger 8192, segment fault free(input_array); } malloc() takes size in bytes, not number of elements. size of int typcially 4 bytes, allocating enough memory 2500 integers. allocating array_size bytes, while should allocating array_size * sizeof(int) bytes. so, error fixed input_array = (int*) malloc(array_size * sizeof(int)); p.s. never assume k...

asp.net mvc - How pass different repository object with same interface to my service layer using Ninject? -

so i've run confusion in past, , got around not using ninject. i'm redoing site i'm @ point ninject seems handy again, i've got myself confused. again . i have mvc3 project using repository pattern. currently, home controller creates few objects orderrepository.cs, customerrepository.cs , sends them service called orderservice.cs , customerservice.cs. have test project can use send in fakeorderrepository.cs , fakecustomerrepository.cs. handy unit testing go through project. however, realise declaring repositories in controller , unit tests, i'm setting dependency on objects. have no repositories passed, , have service layer use ninject "oh look, iorderrepository in constructor, better go orderrepository". the issue ran last time while can bind orderrepository instance or iorderrepository in contructor , bind 2 in global.ascx, seems leave unit tests high , dry. unless go in , switch every bind in global.ascx object want passed in (in case, fakeord...