Posts

php - Remove before echoing -

say have list this hello1 hello2 hello3 hello4 goodbye hello6 hello7 hello8 how can remove goodbye , print everything else besides goodbye? use unset , array_search this: $array = array('hello1','hello2','hello3','hello4','goodbye','hello6','hello7','hello8'); if(($key = array_search('goodbye', $array)) !== false) unset($array[$key]); this 2 things in 1 if statement: if assigned value of $key (the return value of array_search ) truthy, proceed , use index, otherwise, don't anything. necessary because if return value of array_search false , resulting $array[false] not intended behavior @ all.

sql server - python to mssql encoding problem -

Image
greetings by using pymssql library, want write data mssql database encounter encoding issues. here sample code write db: # -*- coding: utf-8 -*- import _mssql .... connection info data here .... def mssql_connect(): return _mssql.connect(server=host, user=username, password=pass, database=db, charset="utf-8") con = mssql_connect() insert_ex_sql = "insert mydatabsae (id, programname, programdetail) values (1, 'test characters ÜŞiçÇÖö', 'löşüiiğĞü');" con.execute_non_query(insert_ex_sql) con.close() sadly data written db corrupted: the collacation of mssql db is: turkish_ci_as how can solved? here possible solution : the key insert_ex_sq.encode('your language encoder') . try instead: con.execute_non_query(insert_ex_sq.encode('your language encoder'))

compression - File formats with included versioning -

i idea of using compressed folders containers file formats. used libreoffice or dia. if want define special purpose file format, can define folder , file structure , zip root folder , have single file data in single file. imported files live originals inside compressed file. defining binary file format 0 features lot of work. now question: there applications using compressed folders file formats , versioning inside folder? benefits great. commit state in project file , versioning decorated functions own application. diffs presented own way. libraries working compressed files , versioning available. used versioning system should distributed system, repository lives inside working folder , not seperate example subversion client-server model. what think? i'm sure there applications out there using approach, couldn't find one. or there major drawback in approach? sounds interesting idea. know many applications claim have "unlimited" undo , redo, that...

command line - HELP: UDP broadcast vlc stream weirdness! -

hi i'm trying using vlc broadcast udp stream within lan, making tv channel. i used command line launch vlc vlc ok run = cvlc --repeat filename.avi --sout '#standard{access=udp,mux=ts,dst=239.255.12.42:8001} problem works on network, , have problem receiving on network without router! question: magical address "239.255.x.x" ? network hardware require udp broadcast besides switches , cables? wireless can accept udp broadcast? thanks answers! the 239.255.x.x addresses part of multicast address space, ranging 224.0.0.0 239.255.255.255 (and there specific-use areas in there). you've correctly noted doesn't work without router. because basic ip stack still wants know how route addresses determine interface send them on. can either add static route multicast (that address or multicast addresses), or put in default gateway.

.net - Probably simple regex search -

what regex find text#2? pattern it's first occurance of "z=" after c. text want rest of line after z=. i'm using regex in .net a x b x z=text#1 x c x z=text#2 .*c.*z=([^\n]*).* you'll need turn on . matching newlines ( regexoptions.singleline below). here's c# code generated my regex tester : using system; using system.text.regularexpressions; namespace myapp { class class1 { static void main(string[] args) { string sourcestring = "source string match pattern"; regex re = new regex(@".*c.*z=([^\n]*).*",regexoptions.singleline); matchcollection mc = re.matches(sourcestring); int midx=0; foreach (match m in mc) { (int gidx = 0; gidx < m.groups.count; gidx++) { console.writeline("[{0}][{1}] = {2}", midx, re.getgroupnames()[gidx], m.groups[gidx].value); } ...

opengl - Given a 4x4 homogeneous matrix, how can i get 3D world coords? -

so have object getting rotated translated , rotated again. storing matrix of these translations object member. when come object picking need know 3d world coords of object. currently have been able position of object so coords[0] = finalmatrix[12]; coords[1] = finalmatrix[13]; coords[2] = finalmatrix[14]; this giving me correct positions of objects want take rotations account well. any great... the matrix 4x4 matrix, you've got single dimensional matrix appears elements arranged follows: [0] [4] [8] [12] [1] [5] [9] [13] [2] [6] [10] [14] [3] [7] [11] [15] the rotation part top left 3x3 matrix see here , in case elements [0]-[2] , [4]-[6] , [8]-[10]

cmd - Consoles and Tabs -

when start tomcat server console using startup.bat script, new command window opens filled java logging statements. i use console2 leverages tabs each open console window. possible let java system create new tab within console2 instead of opening new command window? this has nothing java, merely down way catalina.bat called startup.bat catalina.bat can called either "start" argument or "run" argument. run start catalina in current window start start catalina in separate window so open startup.bat, scroll bottom should see "%executable%" start %cmd_line_args% change "%executable%" run %cmd_line_args% exit i add exit after close calling window.

build - Building and installing Perl subsystem in a project that uses make (Makefile) -

what build system (make, extutils::makemaker , module::build , ...) use in perl subsystem (e.g. perl bindings, or auxillary command implemented in perl), , how connect build system of main project. project uses make build system. perl subsystem in separate subdirectory. we can assume if there perl installed, @ least version 5.8.3. for 5.8 eumm okay. connect main makefile straight-forward way, write perl-binding target contains usual incantation .

php mysql combine queries -

if have 2 mysql_query commands in single php file, way combine them? for example, have: $a=mysql_query(select * table1); $b=mysql_query(select id table3); but want combine them single mysql_query, more efficient? faster? multiple queries not supported in mysql_query descripted on php manual , can't combine both query in php mysql_query way here reference php manual notes : executed multiple queries @ once, mysql_query function return result first query. other queries executed well, won't have result them.

user interface - form close event in c# -

i trying cleaning when form closes. using following signature private void batchgui_closing(object sender, formclosingeventargs e) the issue is, if put breakpoint in there code never executes, how write method form close event? thanks in winforms event called formclosing: private void form1_formclosing(object sender, formclosingeventargs e) { } make sure attached event in designer. adding method not enough!

php - Why does everyone use latin1? -

someone said utf8 has variable length encoding 1 3 bytes. so why still use latin1? if same thing stored in utf8 1 byte, utf8 has advantage can adapt larger character set. is hidden reason uses latin1? what disadvantages of using utf8 vs. latin1? iso 8859-1 (at least de facto) default character encoding of multiple standards http (at least textual contents): when no explicit charset parameter provided sender, media subtypes of "text" type defined have default charset value of "iso-8859-1" when received via http. data in character sets other "iso-8859-1" or subsets must labeled appropriate charset value. the reason iso 8859-1 chosen it’s superset of us-ascii fundamental character set internet based technologies. , world wide web invented , developed @ cern in geneva, switzerland, might reason choose characters of western european languages 128 remaining characters. when unicode standard developed, character set of iso 8859-1 ...

objective c - How to increment a NSNumber -

how increment nsnumber? i.e. mynsnumber++ update: fyi, boltclock's , darkdusts's one-line answers better. they're more concise, , don't require additional variables. in order increment nsnumber , you're going have value, increment that, , store in new nsnumber . for instance, nsnumber holding integer: nsnumber *number = [nsnumber numberwithint:...]; int value = [number intvalue]; number = [nsnumber numberwithint:value + 1]; or nsnumber holding floating-point number: nsnumber *number = [nsnumber numberwithdouble:...]; double value = [number doublevalue]; number = [nsnumber numberwithdouble:value + 1.0];

linker - Problem in creating a shared library for Android platform -

i using android toolchain. i have make changes stack has lot of static libraries , make shared library. able compile changes .o file (using gcc). when trying create shared library linking existing static libraries, getting error saying 'linker input file unused because linking not done'. i compiling files using -fpic , , using -shared linking still getting error. let me know if there has faced similar problem or if can suggest solution. see if this link helps you. there's similar question on stackoverflow

ajax - xmlhttp not supporting in IE -

xmlhttp not supporting in ie ,actually had created 1 facebook app users can play game each other randomly,problem when want test it, login in facebook userid in firefox,and login brother facebook id in chrome connecting each other,do think beacuse of same ip address not connecting or not creating xmlhttprequest object ie , chrome.... function getxmlhttpobject() { var xmlhttp = null; try { // firefox, opera 8.0+, safari xmlhttp = new xmlhttprequest(); } catch (e) { //internet explorer try { xmlhttp = new activexobject("msxml2.xmlhttp"); } catch (e) { xmlhttp = new activexobject("microsoft.xmlhttp"); } } return xmlhttp; ...

vb.net - assign value without open excel file -

imports microsoft.office.core imports microsoft.office.interop imports microsoft.office.interop.excel i have code: dim oapp new excel.application() dim wb excel.workbook wb = oapp.workbooks.open("d:\noriamail\23120011\lpo summary per month_view 3 - allmonths.xlsx") can tell me how can assign value wb witout open file (i want function give wb value without open file) thank's help what type of value want "assign"? sort of metadata? in experience, code above correct way open file; there, can begin manipulating file.

observer pattern - Clone all 'observe' of a cloned element using Prototype -

i have sortable list (done using prototype , scriptaculous): can sort elements or drag them list. when drop element (let's call element_1) of list 1 'clone' of dropped element , insert (appendchild) new list. element1 had 'observe' (clicking on something, double-clicking on else) of course lost when cloning.. want cloned element have same 'observe' of element1. how can that? thanks in advance observe lists instead of items , allow event bubbling work you. $('list1','list2').invoke('on', 'click', 'li', function(event, element){ // "this" either list1 or list2 // "element" list item }

profiling - gprof messing up -

i trying 2 profile cpp code. compiled -pg flags , after profiled output got weird function names. make file using: # makefile parallel simulated annealer prefix=${parsecdir}/pkgs/kernels/canneal/inst/${parsecplat} target=canneal libs:=$(libs) -lm cxxflags+=-pg ifdef version ifeq "$(version)" "pthreads" cxxflags+=-denable_threads -pthread endif endif all: $(cxx) $(cxxflags) annealer_thread.cpp -c -o annealer_thread.o $(cxx) $(cxxflags) rng.cpp -c -o rng.o $(cxx) $(cxxflags) netlist.cpp -c -o netlist.o $(cxx) $(cxxflags) main.cpp -c -o main.o $(cxx) $(cxxflags) netlist_elem.cpp -c -o netlist_elem.o $(cxx) $(cxxflags) $(ldflags) *.o $(libs) -o $(target) clean: rm -f *.o $(target) install: mkdir -p $(prefix)/bin cp -f $(target) $(prefix)/bin/$(target) this sample of gprof output: flat profile: each sample counts 0.01 seconds. % cumulative self self total time seconds sec...

javascript - fitBounds and getZoom not playing nice -

i have following code running after map initialised function showaddress(address) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { map.fitbounds(results[0].geometry.bounds); if (map.getzoom() < 12) { map.setzoom(12); } } else { alert("geocode not successful following reason: " + status); } }); } the problem tha zoom check , set doesn't work. have checked , map initiated map.getzoom() function returns undefinted @ time. is there can force wait until fitbounds have been set , zoom level known can control zoom appropriately? // define bounds changed event handler "once-only" zoom level check google.maps.event.addlistener(map, 'bounds_changed', function() { initialzoomcheck() }); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google....

asp.net - mvc with ajax post -

i have form includes list of records. when user clicks edit image on table modal div show him. modal div ajax. after changing fields posting via ajax. watched firebug. sends parameter. when debug code in vs method calls no parameter has been send. have done before in other pages. can not. problem can here in code? c# code here [httppost] //[authorize(roles = "operator")] public actionresult editrow(string name, string secondname) { //code goes here return content("saved"); } jquery ajax code here $.ajax({ type: 'post', contenttype: 'application/json; charset=utf-8', url: 'editrow', data: { name: "php", secondname: "mvc" }, datatype: 'html', success: function (response) { //some code goes here } }); have tried simplify ajax call to: $.ajax({ type: 'post', url: 'editrow', data: { ...

Maven release setup with svn tags per module -

goal multimodule maven release tags per module situation assume following project structure maven-based java project: xx-parent xx-modulea xx-moduleb xx-modulec/submodule1 xx-modulec/submodule2 xx-modulec/submodule3 the project structure in subversion follows: xx-parent/trunk xx-modulea/trunk xx-moduleb/trunk xx-modulec/trunk/submodule1 xx-modulec/trunk/submodule2 xx-modulec/trunk/submodule3 my goal create tags per module when performing release: xx-parent/tags/xx-parent-1.0 xx-modulea/tags/xx-modulea-1.0 xx-moduleb/tags/xx-moduleb-1.0 xx-modulec/tags/xx-modulec-1.0 in past, each module built , released separately. project grew larger (30 modules), time build release increased. change project multi-module set perform reactor build , release. building doesn't seem problem, creating tags per module is. the maven-release-plugin seems insist on making single tag whole project/release. i'm looking way create multiple tags, e.g. tag per module. what have tri...