Posts

Showing posts from March, 2014

sql - Adding two fields in php -

$result = mysql_query("select * productlist1 order pdesc asc"); while($row = mysql_fetch_array($result)) $sold=$row['psold']; $left=$row['pleft']; $all=$left + $sold; { echo '<tr>'; echo '<td>'.$row['pcode'].'</td>'; echo '<td>'.$row['pdesc'].'</td>'; echo '<td>'.$row['date'].'</td>'; echo '<td>'.$row['time'].'</td>'; echo '<td><div align="center">'.$row['psold'].'</div></td>'; echo '<td><div align="center">'.$row['pleft'].'</div></td>'; echo '<td><div align="center">'.$row['pprice'].'</div></td>'; echo '<td><div align="center">'.$all.'<...

aptana - Why there is additional unwanted line in my php file when it has uploaded to cpanel? -

Image
i've been searching in google this, did not find answer. or maybe not know keyword this. find files have unwanted new line every time uploaded cpanel. before upload: after upload: it started when uploaded myfile.php 208 lines today via filezilla, , next day re-download file , edited using aptana. got file has unwanted new line become 382 lines . have been experiencing this? please me solve problem. thank you. sorry bad english the issue conversion of file between different operating systems. the server unix system, changes line termination character. such when files downloaded server, need use utility unix2dos convert file.

python - CSS select with beautifulsoup4 doesn't work -

i tried bs4, select method doesn't work. what's wrong code? import requests import bs4 def main(): r = requests.get("http://nodejs.org/download/") soup = bs4.beautifulsoup(r.text) selector = "div.interior:nth-child(2) > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3) > a:nth-child(1)" print(soup.select(selector)[0].text) if __name__ == "__main__": main() the answer on page differs viewing in browser parsing bs. have @ r.text , parse there. the response <div class="interior row"> <div id="installers"> <ul> <li> <a href="http://nodejs.org/dist/v0.10.26/node-v0.10.26-x86.msi"> <img alt="" height="50" src="http://nodejs.org/images/platform-icon-win.png" width="45"> windows installer <small>node-v0.10.26-x86.msi</small> <...

iphone - Get Directions for multiple locations in GMAP iOS. -

i have array contains multiple locations (latitude , longitude). i plot locations using lat , long in map, need join locations road (get directions in google map). i used google map api in application. thanks in advance. it sounds you're looking google directions api functionality. allows directions between multiple points (using waypoints) in order create 1 long route. service requires api key , has courtesy limit of 2,500 calls per day. google directions api

preg replace - How to remove text with preg_replace function of php -

i have code this: $data='<p>text begin</p> <script type="text/javascript"> $(".idr").hide(); $("[rel=tooltip]").tooltip({ placement: "top"}); </script> <p>text finish</p>'; i'm trying remove below text: <script type="text/javascript"> $(".idr").hide(); $("[rel=tooltip]").tooltip({ placement: "top"}); </script> with preg_replace() echo preg_replace("/<script(.+?)script>/i", '', $data); but it's doesn't work. suggestions? if tring remove script try this: preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $data);

jquery - slide (animation) not working -

i have page small buttons (more 2) profiles. working more or less fine, except hide , show (slidetoggle) - div (profilepannel) appears without nice slow expand, suddently. only css element (margin-bottom) working fine. see it, may click profile one, see on second button, final effect. jquery var menu; $(document).ready(function(){ $('.img').click(function () { menu = $("#" + $(this).data("menu")); $(".profilepannel:not(#" + menu.attr("id") + ")").slideup("slow"); menu.slidetoggle("slow"); }); }) try it! can nice , tell me why, , how can change it? and btw, have trouble positioning profilepanel - wish show under each profile button, without moving rest of buttons. have tried position: relative, absolute, z-index have missed , dont have output wish. it seems min-height causing issues. if remove/change that, effect going for: .profilepannel { width:...

c - Logic behind finding Heap space available -

hi i'm new memory management, thought of finding logic find free heap space. feel finding difference between " program break " , " stack pointer " can correct? if not please justify , let me know right logic. memory layout under linux complex beast , opinion should not care available heap: 1 of purpose of virtual memory. every process sees flat large memory space. regarding propose solution, don't think correct because described here: http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/ hep grows starting @ end of bss segment. you can heap size process (22088 in example) terminal with: cat /proc/22088/maps | grep heap 7f5082180000-7f5082ac7000 rw-p 00000000 00:00 0 [heap] from c user space code, can read @ file heap size of current process.

sql server - ColumnStore Index vs Columnar DB -

there option called "columnstore index" available in sql server 2012. comparable columnar databases such cassandra, hbase? few advantages of going sql server 2012 can be: it updateable it relational what other factors can considered choose between sql server 2012 , other columnar databases in case faster query performance requirement. i'm not sure mean "it updatable", in sql server 2012 tables have columnstore index cannot updated. must first drop columnstore index or must partition around columnstore index in order support changes underlying data. also, columnstore indexes useful in dw systems large amounts of data have aggregated , accessed quickly. in sql server 2012 have alternative of indexed (materialized) views .

python - PySerial: how to understand that the timeout occured while reading from serial port? -

i'm using pyserial read serial port in code below. checkreaduntil() read output of command send serial port until sequence of symbols readuntil in serial output. ... self.ser = serial.serial(comdev, 115200, timeout=10) ... #function continue read serial port until 'readuntil' #sequence of symbols appears def checkreaduntil(self, readuntil): outputcharacters = [] while 1: ch = self.ser.read() outputcharacters += ch if outputcharacters[-len(readuntil):]==readuntil: break outputlines = ''.join(outputcharacters) return outputlines however, if there no sequence readuntil (for reason), i'm stuck in function checkreaduntil() forever. setting timeout=10 sets timeout i'm stuck in loop iterates every 10 seconds , nothing, waiting. how possible understand there timeout event may exit infinite loop? output length may different. update (previous answer not correct, working code @konstantin)...

c# - "cannot be assigned to -- it is read only" error on ConditionExpression -

i have create "between date" condition. when write this: conditionexpression modifiedoncondition = new conditionexpression(); modifiedoncondition.attributename = "modifiedon"; modifiedoncondition.operator = conditionoperator.between; modifiedoncondition.values = new object[] { startdate, enddate }; startdate , enddate datetime . got error on modifiedoncondition.values . says: property or indexer 'microsoft.xrm.sdk.query.conditionexpression.values' cannot assigned -- read only how can fix it? you can't change values property after object has been created, pass parameter in conditionexpression constructor: var modifiedoncondition = new conditionexpression( "modifiedon", conditionoperator.between, new object[] { startdate, enddate });

Shopify If multiple tags are present - do something -

i'm trying show div if set of tags present. have working 1 tag using... {% if collection.all_tags contains 'tag1' %} {% endif %} ...but want check if multiple tags present like... {% if collection.all_tags contains 'tag1 or tag2 or tag3' %} {% endif %} i can't find solution seems simple, ideas? thanks. try this: {% if collection.all_tags contains 'tag1' or collection.all_tags contains 'tag2' %} {% endif %} see list of liquid operators here .

excel - Perform MID or LEFT on ARRAY -

match requires array second parameter. eg. =match(sheet1!a1 ; sheet2!a1:a4 ; 0) is there way match substrings of array values in lookup using left/mid? eg. =match(sheet1!a1 ; left(sheet2!a1:a4;5) ; 0) the above example gives #value! error, understand why not working, want know if there way acheive desired result? matching using substring each value in array? you can array enter formula make work. that, mean need press ctrl + shift + enter after typing in formula instead of hitting enter .

f# - Delegate/Func conversion and misleading compiler error message -

i thought conversions between f# functions , system.func had done manually, there appears case compiler (sometimes) you. , when goes wrong error message isn't accurate: module foo = let dict = new system.collections.generic.dictionary<string, system.func<obj,obj>>() let f (x:obj) = x // question 1: why compile without explicit type conversion? dict.["foo"] <- fun (x:obj) -> x // question 2: given above line compiles, why fail? dict.["bar"] <- f the last line fails compile, , error is: this expression expected have type system.func<obj,obj> here has type 'a -> obj clearly function f doesn't have signature of 'a > obj . if f# 3.1 compiler happy first dictionary assignment, why not second? the part of spec should explain 8.13.7 type directed conversions @ member invocations . in short, when invoking member, automatic conversion f# function...

Appengine Java MapReduce : Save all results in one google cloud file -

i wan't database export jobs in csv, think use mapreduce job, read datastore entity datastoreinput, in mapper, juste emit csv string current entity, , use valueprojectionreducer pass through values. cloudsqlfileoutput write 1 file each shards jobs. how export csv lines in 1 file mapreduce library ? thanks. set number of reducers 1. (in versions 0.5 done 1 output class.)

c# - DisconectedContext was detected -

i need getting rid of error: "transition com context 0x465608 runtimecallablewrapper failed following error: system call failed. (exception hresult: 0x80010100 (rpc_e_sys_call_failed)). typically because com context 0x465608 runtimecallablewrapper created has been disconnected or busy doing else. releasing interfaces current com context (com context 0x465498). may cause corruption or data loss. avoid problem, please ensure com contexts/apartments/threads stay alive , available context transition, until application done runtimecallablewrappers represents com components live inside them." which occurs during execution of code: int = 2; while(i <= lastrowpopt) { refdocno = poptsheet.cells[i, 1].text; refitem = poptsheet.cells[i, 2].text; plnt = poptsheet.cells[i, 3].text; concat = refdocno + refitem + plnt; poptsheet.cells[i, 8] = concat; poptsheet.range["e" + i, "g" + i].copy(type.missing);...

MySQL - Full text search -

i'm using mysql db full-text index of 2 fields (name , aliases). it videogames database codice: select name,match (name,aliases) against ('infamous: second son') relevance games_search order relevance desc; with query following results codice: infamous 2 9.150630950927734 infamous: second son 9.150630950927734 infamous 8.947185516357422 infamous: festival of blood 8.947185516357422 why first 2 results have same relevance? full text search in mysql ignores 2 types of words: stop words , words shorted threshhold. you can read list of stop words here . of particular interest in case word 'second' . by default, words 4 characters or longer kept search purposes. hence, 'son' ignored. so, query equivalent to: select name, match (name,aliases) against ('infamous:') relevance games_search order relevance desc; i not sure why these higher last two. speculate releva...

javascript - TWBS Ratchet - How to close modal maually? -

i'm building mobile web app ratchet. have opening modal, fill form, press button save , close modal. now, i'm able close modal it's documentated button, , i'm able save form field...but how things together? in rachet's documentation it's not explained how close modal manually via js. i'm using ratchet angularjs, button calls agular function, in should close modal. thanks ok, solved way. in modal i've added button <button class="btn" ng-click="add();" href="#mymodal">save</button> by pressing button wanted close modal after logic. so, logic: $scope.add = function() { // logic here jquery('#mymodal').removeclass('active'); }; i hope can else...

c++ - Does std::map::find performance depend on the key size? -

say have the following map definition: std::map<string,storage> where key string representation of storage class instance. question is, though stated map::find complexity logarithmic in size , string size has influence on performance? the reason have map enable fast access storage class instance. however, if string representation of storage classes long? there max string size if exceeded makes use of map redundant? notes my intuition tells me if the string representation of storage classes long comparing classes using operator== expensive well. no matter how long string is, i'm better of using map yes, map has perform less-than comparison of keys. lexicographical comparison , linear wrt string size. this not affect time complexity of find method, refers number of comparisons required. affects constant factor. whether matters or not in application should determined empirically.

xml parsing - Tool for xml (.locale) file automatic translation - TAOBAO CHAT TRANSLATION IN ENGLISH -

Image
edit: chat program name alichat, aliwangwang (taobao chat software) i have chat program installed on microsoft environment uses .locale file language customization. structured xml file. file: http://www.tr3ma.com/apps/translatortest/chs.locale_original this how structured: <?xml version="1.0" encoding="utf-8"?> <localedetails> <strings> <string id="common.yes">是</string> <string id="common.no">否</string> <string id="common.remind">提示</string> <string id="common.ok">确定</string> <string id="common.edit">编辑</string> <string id="common.save">保存</string> <string id="common.cancel">取消</string> ..... do know if file standard file microsoft development environment strings resource file android apps? found android apps there tool translate resources in ...

c# 4.0 - How I can get the request XML using WebAPI C# -

when can sent restfull request web api , how receive body/payload , headers of request in controller post method. public httpresponsemessage post(httprequestmessage request) { var requestbody = httpcontext.current.request.inputstream; var headers = system.web.httpcontext.current.request.headers; here able headers values unable body request. 1 suggest me how can body? one way create action method in controller looks this, public async task<httpresponsemessge> post(httprequestmessage request) { var bodystream = await request.content.readasstreamasync(); }

javascript - AngularJS - more of the same directives on one page with its own state -

in ralation question call method in directive controller other controller . how can put more 1 independent directives of same type on page? because of common api (singleton) state shared. if place 2 same directives there both reflect 1 instance of api , same state. i think you're talking isolating scope of directive, relevant documentation is here . may simple scope: true , makes isolated scope directive inherits. can read here .

phpmyadmin - How to import MySQL 4 .dump file into MySQL 5? -

i have mysql 4 dump file named booster.dump 30mb in size. want import file mysql 5 server. try using phpmyadmin. doesn't upload. shows error: size large then have zip file named booster.zip , try upload again in phpmyadmin show error: no data received import. either no file name submitted, or file size exceeded maximum size permitted php configuration then open booster.dump file in notepad++ , copy text , make new file named booster.sql try upload booster.sql in phpmyadmin. shows error: 1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near 'type=myisam' @ line 8 i have change type=myisam engine=myisam , works fine. if go way need change every query painful. my question is: there way import file mysql 5? mysql 4 5 1. export database on system mysql 4: mysqldump -p --opt dbname >dbname.sql 2. copy database other sytem, example, scp dbname.sql me@domain.com:/home/me 3. i...

ruby - rails no such file to load -- ap (LoadError) -

when try of rails , rake command in staging server got no such file load -- ap (loaderror) , for rails s : /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in`require': no such file load -- ap (loaderror) xxxx /config/application.rb:7 for rake -t : rake aborted! no such file load -- ap my application.rb file: require file.expand_path('../boot', __file__) require 'rails/all' # if have gemfile, require gems listed there, including gems # you've limited :test, :development, or :production. bundler.require(:default, rails.env) if defined?(bundler) my rails , ruby version: rails version in local , staging: 3.0.11 ruby version in staging: ruby 1.8.7 (2012-02-08 patchlevel 358) ruby version in local:ruby 1.8.7 (2011-06-30 patchlevel 352) but can run rails s , rails c , rake log:clear in local machine. gemfile file in staging same gemfile in local. what missing here? how can resolve this? ...

javascript - Angularjs undefined object when attribute two-way binding -

i running problem i'm trying in angularjs. thing goes this: i have controller , have directive defined this: helpers.directive('someevent', function() { ... scope: { api: '=' } ... controller: ['$scope', function($scope) { $scope.hassomeeventoccured = function(){ return booleanvariable }; $scope.api = { hassomeeventoccured: $scope.hassomeeventoccured } }] }); then, in other controller want access function hassomeeventoccured ... controller defined follows: modulename.controller('modulesomethingcontroller', ['$scope', '$state', 'modulerepository', function ($scope, $state, modulerepository) { $scope.theeventoccured = $scope.someeventapi.hassomeeventoccured(); }]); and in cshtml file have: <some-event api="someeventapi" ></some-event> <div ng-if="theeventoccured"></div> t...

java - Which encryption algorithm/method is being used in setEncryption method of PdfStamper class? -

i referring following method here. ( link more details) public void setencryption(boolean strength, string userpassword, string ownerpassword, int permissions) throws documentexception which encryption algorithm/method/standard being used internally itext encrypt pdf? is aes? the javadocs closely related interface, pdfencryptionsettings , provides clues: encryption settings described in section 3.5 (more section 3.5.2) of pdf reference 1.7. explained in section 3.3.3 of book 'itext in action'. looking @ section of the reference can see either rc4 or aes used. with in mind, i'd specific method linked either 40-bit rc4 or 128-bit rc4. overloaded alternative method allows specify 40-bit rc4, 128-bit rc4 or 128-bit aes.

Python script to read http paramters from a file -

i new python , trying extract information twitter http responses. have collated list of infosec professionals on twitter, want extract description through automated way - preferrably python script. the http request https://twitter.com/bpiatt so request in code : urllib2.urlopen(" https://twitter.com/ $variable").read() where variable name in file has list of names. the issues have how store names in variable , make http request. i can extract description field once have done this. thanks in advance. try this: urllib2.urlopen("https://twitter.com/%s" % variable).read()

visual studio - Web service that shows message box -

i need create simple web service application. need show message box on pc runs service. possible ask web service create message box? no, thats not possible. can create client application, consumes service. check condition , display message box.

Direct2d access violation in C++ XAML game -

i have created windows phone game in c++ (native only) using directxtoolkit , wanted recreate app using xaml , c++. i followed steps this tutorial got stuck on following problem. in void renderer::createdeviceresources() function calling m_spritebatch = unique_ptr<spritebatch>(new directx::spritebatch(m_d3dcontext.get())); this is, however, causing problem in mainpage.xaml.cs inside drawingsurfacebackground_loaded function @ line drawingsurfacebackground.setbackgroundcontentprovider(m_d3dbackground.createcontentprovider()); i getting an unhandled exception of type 'system.accessviolationexception' occurred in unknown module. attempted read or write protected memory. indication other memory corrupt. when removing m_spritebatch... line starting fine can't render sprites in game. any idea how fix this? new c++ don't know look. this guess, perhaps cannot instantiate using "new" doing: (new directx::spritebatch(m_d3dcontext.ge...

java - How to handle exceptions thrown by default interceptors in struts2? -

for example: org.apache.commons.fileupload.fileuploadbase$sizelimitexceededexception: request rejected because size (337867) exceeds configured maximum (200) you can use exception mapping feature of struts2 map exception specific result . in struts.xlm file put <exception-mapping> definition inside <global-exception-mappings> , create result , defined name, global or in specific action(s). <global-exception-mappings> <exception-mapping exception="java.lang.nullpointerexception" result="npe"/> </global-exception-mappings> note interceptor stack must include exception interceptor. recommended exception interceptor first interceptor on stack, ensuring has full access catch exception, caused other interceptors.

php - Get all possible matches in regex -

for example have following string: (hello(world)) program i'd extract following parts string: (hello(world)) (world) i have been trying expression (\((.*)\)) (hello(world)) . how can achieve using regular expression a regular expression might not best tool task. might want use tokenizer instead. can done using regex, using recursion : $str = "(hello(world)) program"; preg_match_all('/(\(([^()]|(?r))*\))/', $str, $matches); print_r($matches); explanation: ( # beginning of capture group 1 \( # match literal ( ( # beginning of capture group 2 [^()] # character not ( or ) | # or (?r) # recurse entire pattern again )* # end of capture group 2 - repeat 0 or more times \) # match literal ) ) # end of group 1 demo

java - RCaller get matrix of unknown size -

i'm using rcaller in java in order execute external r program. the problem is, don't know exact size of matrix .getasdoublematrix() method wants have size. double[][] matrix = caller.getparser().getasdoublematrix("result", dont_know, dont_know); is there way keep size dynamic? by revision e263b5393d43 , routputparser class has getdimensions() method getting unknown dimensions of matrix. here passed test file: int n = 21; int m = 23; double[][] data = new double[n][m]; (int i=0;i<data.lengthi++){ (int j=0;j<data[0].length;j++){ data[i][j] = math.random(); } } rcaller caller = new rcaller(); globals.detect_current_rscript(); caller.setrscriptexecutable(globals.rscript_current); rcode code = new rcode(); code.adddoublematrix("x", data); caller.setrcode(code); caller.runandreturnresult("x"); int[] mydim = caller.getparser().getdimensions("x"); assert.assertequals(n, mydim[0]); assert.ass...

How can i get all of the purchased products in magento? -

i'm newbie in magento. code : <?php $_orders = $this->getorders(); foreach ($_orders $_order){ var_dump($_order->getstatus()); } ?> this return me smth : string(7) "pending" string(10) "processing" string(7) "pending" string(7) "pending" string(7) "pending" string(10) "processing" string(10) "processing" string(7) "pending" string(7) "pending" string(8) "complete" but want of "complete" items . how can ? try $order->getstate() $_orders = mage::getmodel('sales/order')->getcollection(); // completed order //$_orders->addfieldtofilter('state', mage_sales_model_order::state_complete); foreach ($_orders $_order){ var_dump($order->getstate()); var_dump($_order->getdata()); // return field in sale_flat_order table //$_order->getstatus() = $_order->getdata('...

ios - Fullscreen state with Youtube Iframe API on iPhone -

i'm trying find way of knowing when youtube video on iphone enters/exists fullscreen inside html page. using safari mobile, not uiwebview, videos automatically go fullscreen start playing. being not on youtube.com domain cannot bind webkitbeginfullscreen , webkitbendfullscreen on <video> element within iframe. is there technique, hacks, allowing me query video fullscreen state? i think you'd have detect iphone or ipod user agent , if time changed on video (via youtube javascript api) have assume playing. although, gets equivalent beginfullscreen event reliably.

regex - What does the following regular expression do? -

foreach(@first) { $first[$r] =~s/<.*>(.*)<.*>/$1/; $first[$r]=$1; $r++; } what regular expression on line number 3? the subtitution s/<.*>(.*)<.*>/$1/ looks idiotic attempt remove surrounding html tags string. example, given input "<p>foo bar <em>baz</em> qux</p>" we output " qux" : <.*> matches less-than sign, many characters possible, , greater-than sign. (.*) matches many characters possible , remembers match $1 . <.*> matches less-than sign, many characters possible, , greater-than sign. then, whole match replaced contents of capture group 1. however, code looks written isn't experienced programmer, , doesn't know perl anyway. assuming $r = 0 before loop, equivalent to: for (@first) { /<.*>(.*)<.*>/; $_ = $1; } or @first = map { /<.*>(.*)<.*>/; $1 } @first;

Mayavi- Scale a surface without translating it -

im wondering if possible scale surface-object in mayavi without moving/translating it. so far use surface.actor.actor.scale property , assign 3d-vector it. however, surface not keep original position scaling carried out respect origin (0,0,0) - that's why seems surface moves... any ideas? when asked origin attribute on vtk actors, genuinely inquiring had been tried. have played little bit don't know details of how vtk actors decide position themselves, complicated , mathy , find easier hack , math manually (at least when math simple). here simpler solution. note, not best solution. there may cleaner solution have not found. the basic idea of solution simple: scrape x,y,z coordinates of surface vertices, apply correct linear translation these points, , feed them source. surf = mlab.surf(*args) # somehow generate surface xc,yc,zc = centroid() #somehow determine x,y,z coordinates stabilize towards scale_factor = 2.8 tx,ty,tz = surf.mlab_source.x, surf.mlab...

Multithreading use of python scripts in c++ -

i'm using code python multithreading scripts (got web): class pymainguard { public: pymainguard() { py_initialize(); pyeval_initthreads(); mgilstate = pygilstate_ensure(); mthreadstate = pyeval_savethread(); } ~pymainguard() { pyeval_restorethread( mthreadstate ); pygilstate_release( mgilstate ); py_finalize(); } private: pygilstate_state mgilstate; pythreadstate* mthreadstate; }; class pythrguard { public: pythrguard() { mmaingilstate = pygilstate_ensure(); moldthreadstate = pythreadstate_get(); mnewthreadstate = py_newinterpreter(); pythreadstate_swap( mnewthreadstate ); msubthreadstate = pyeval_savethread(); msubgilstate = pygilstate_ensure(); } ~pythrguard() { pygilstate_release( msubgilstate ); pyeval_restorethread( msubthreadstate ); py_endinterpreter( mnewthreadstate ); pythreadstate_swap( moldthreadstate ); pygilstate_release( mmaingilstate ); } private: pygilstate_state mmaingilstate; pythre...

Is it possible to change the IP of docker container when it is running? -

i need change ip , port of running docker container. possible? if how?? not far know. should solve on host setting routing. not area of expertise, can use http://www.computerhope.com/unix/route.htm ?

asp.net mvc - Is it possible use the like command in queryover nHibernate? How can I do this? -

i want search through parts of record, not in accurate records. in exemple search accurate records: var v = nhsession.queryover<dados.models.personmodel>() .where(w=>w.name == "mary")) .list(); i can queryover or criteria? the answer in the: whererestrictionon . this var v = nhsession .queryover<dados.models.personmodel>() //.where(w => w.name == "mary")) .whererestrictionon(w => w.name) .islike("mary", matchmode.start); .list(); the matchmode enum decide put '%' generated sql statement

git - How to reset to the top of a branch -

suppose i'm working on master , i've commit 5 changesets: v1 -- v2 -- v3 -- v4 -- v5 now 'git reset --hard v3' go particular point. @ stage, 'git log' show 1st 3 commits , hash v4 , v5 not displayed. how can v5 easily? (i did find way poking .git directory it's tedious , i'd avoid dealing .git directory directly). the git reflog should contain entry former head . can git checkout state ( head@{n} ) , work it.

ms access - Iterate through tabs in TabControl to hide tabs based on names -

i working on microsoft access database (office 2010) , have tab control on bottom of form displays equipment information based on type of equipment select. trying make dynamically display , hide tabs determined name of tabs. to accomplish have used following naming convention tabs. tab_static_description tab_static_comments tab_static_maintenance tab_config_computer1 tab_config_computer2 tab_config_printer1 tab_config_scanner1 tab_config_telephone1 tab_config_display1 my tabcontrol called "tabs" i have set form execute function below(the function need with) on form load , onchange of equipment drop down menu. to call function use following code. displaytab here code far. have been googling bit , have yet find doing similar me , have found myself little lost on one. appreciated. function displaytab(equipmenttype string) dim ctl control each ctl in me.tabs if ctl.name.contains("tab_static_") me.tabs.pages.item(ctl).visib...

java - send String[] b httprequest and get in php b $_GET -

i want send string[] http request , values in php $_get method. total number of values in string[] variable. have tried far: list<namevaluepair> params = new arraylist<namevaluepair>(); string[] dropdowns = {"1st item","2nd item","3rd item","4th item"}; (int = 0; < dropdowns.length; i++) { params.add(new basicnamevaluepair("pid", dropdowns[i])); } in php want values , query based on them. $pid = $_get['pid']; and use them like: $result = mysql_query("select *from apps pid[0] = $pid" , pid[1] = $pid" , ...); but know way wrong. how can that? this $result = mysql_query("select *from apps pid[0] = $pid" , pid[1] = $pid" , ...); is wrong , unsafe. (columns wrong syntax, sql injection, wrong quotation, wrong sql syntax,...) must like $result = mysql_query(" select * apps pid in(" . implode(',', mysq...

objective c - Foundation memory management for properties -

for project not using arc, assuming have property on class: @property (assign) cgpathref pathref; and have method updating path reference @ point, example: uibezierpath *bezierpath = [uibezierpath bezierpathwithovalinrect:rect]; self.pathref = cgpathcreatecopy(bezierpath.cgpath); in dealloc, doing follows: - (void)dealloc { cgpathrelease(self.pathref); self.pathref = nil; [super dealloc]; } when running static analyser i'm getting memory advice line using cgpathrelease : incorrect decrement of reference count of object not owned @ point caller. i thought onto here https://developer.apple.com/library/mac/qa/qa1565/_index.html seems explaining how hand off foundation objects core animation apis. can advise on this, how can manage foundation object without static analyser warning? you don't own return value of property accessor. use instance variable instead. cgpathrelease(_pathref); alternatively (and preferably), can impleme...

jquery - Place RadDropDownTree inside bootstrap modal dialog -

i trying place raddropdowntree telerik web ui control on bootstrap modal dialog. problem have filtering textbox of drop down tree, once placed on dialog, cannot receive user input. please see code excerpt follows: <telerik:radscriptmanager runat="server"></telerik:radscriptmanager> <!-- button trigger modal --> <a class="btn btn-primary btn-lg" data-toggle="modal" data-target="#mymodal"> launch demo modal </a> <!-- modal --> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button...

php - Read data from smart card reader -

i'm still new in programming , situation is: want webpage connect mysql using php how read data card reader in way? using php also? , how format or read data card? , necessary me card reader has sdk can read data card? a php web application's code typically executed on server side, if want interact smartcard reader on client side , need use else besides php code access client-side hardware. there different possibilities on how perform such access: you develop/use java applet embedded web page -- web applications @ moment. if smartcard reader pc/sc-compliant, use java smartcardio api within applet access reader , forware information php application on server. another option client-side application ( you need create , provide application) acts web server , processes json (or whatever) get/post requests. client-side application access smartcard reader , web application's (java) script code send json (or whatever) requests retrieve card data. instead of cli...

jquery - Access-control-allow-origin error when debugging -

i following error when debugging web app in visual studio 2013 express web. app mvc angularjs, jquery, bootstrap. have other web apps work fine , not have error, , i'm not sure resolve this. i've compared web.configs, global.asax, etc projects working. i can reproduce behavior creating new web project, , select mvc. when debug new project same error. xmlhttprequest cannot load http://ssl.socialprivacy.org/native/pagehandler.php. 'access-control-allow-origin' header has value 'http://localhost' not equal supplied origin. origin 'http://localhost:54400' therefore not allowed access. i've seen other question here not solve problem. access-control-allow-origin error because trying cross domain ajax call. browser block because of same origin policy. if trying make cross domain ajax, should cors in ajax. server should enabled it. method cross domain ajax using jsonp.

c# - Create Path programatically doesn't works as Desired -

Image
i have custom control <grid name="panelinferior" grid.row="5" grid.columnspan="5"> <grid.columndefinitions> <columndefinition x:name="nombrepiezaholder" width="2*"/> <columndefinition x:name="simbol1" width="1*"/> <columndefinition x:name="simbol2" width="1*"/> <columndefinition x:name="simbol3" width="1*"/> <columndefinition x:name="simbol4" width="1*"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="1*"/> </grid.rowdefinitions> <textblock x:name="nombrepieza" text="{binding elementname=esta_pieza,path=pieza.id}" margin="0" height="auto...

javascript - Open "Save As" Dialog Box To Download Image -

i've been checking on place answer 1 no luck. i want button or link open "save as" dialog box. simple? i know can open image in new window/tab (as i'm doing now) , use right-click, save as method people using not sharpest knives in box, want make download simple possible. the code @ moment is: <button class="downloadbutton" type="submit" onclick="window.open('<%=(rscontent.fields.item("contentimage").value)%>')">download image</button> but loads image new window/new tab. just record, users using windows xp internet explorer 8 can't use download html5 event. i don't mind if javascript, jquery or classic asp. thanks in advance help. pb update using mdn code lankymart posted, tried as-is , worked (for open/download of excel document), however, tried changing parts download images , didn't work. here classic asp code: <% dim rsimage__imageid rsimage__imageid =...

xcode5 - CoreText framework in iOS 5 using Base SDK 7.1 -

when building ipad app, using base sdk of latest ios (ios 7.1) , deployment target of 5.0. when trying run app on ipad 1 running ios 5.1, crashes on launch following error: dyld: symbol not found: _kctfontdescriptormatchingerror referenced from: /var/mobile/applications/c5593f35-b25c-415f-95a1-45cd617804ed/myapp.app/myapp expected in: /system/library/frameworks/coretext.framework/coretext in /var/mobile/applications/c5593f35-b25c-415f-95a1-45cd617804ed/myapp.app/myapp i tried removing , adding coretext.framework again, , made sure location set relative sdk. is there setting needs updated in xcode 5.1 able run on ios 5? the kctfontdescriptormatchingerror constant available ios 6 onwards.

database - Check MySQL CPU Usage (internally) -

from outside mysql, know can many things know cpu usage of process is, ie. top . but, internal standpoint, know if possible run query mysql know system cpu or cpu consumption of current thread is. i'm running massive queries nightly through event scheduler , db server gets stuck @ 100% cpu few minutes blocking or slowing down users around globe. i've tried research way limit cpu usage thread or user, doesn't seem possible yet. so, i'm trying along lines of following in event: if (select cpu_usage() > 0.8) repeat sleep(0.01); until (select cpu_usage() < 0.25) end repeat; end if; obviously cpu_usage() doesn't exist, if there similar can accomplish similar effect, i'm ears. thanks. p.s. i'm on amazon rds i afraid there no such option select option natively in mysql. if inside mysql client command line, can call "top" command inside mysql client using command : \! top , don't think need. the...

python - Python3 & PyCharm - Debug logging levels in run/debug -

i'm starting pycharm, there way show debug & info warnings? import logging logger = logging.getlogger('tipper') logger.setlevel(logging.debug) logger.debug('debug message') logger.info('info message') logger.warn('warn message') logger.error('error message') logger.critical('critical message') warn, error, critical show: /home/username/someproject/.someprojectenv/bin/python3/home/username/someproject/go.py warn message error message critical message process finished exit code 0 however debug, info not show. the problem has nothing pycharm, how logging configuration works. if try write code have shown in normal python interactive session same output: >>> import logging >>> logger = logging.getlogger('tipper') >>> logger.setlevel(logging.debug) >>> logger.debug('debug message') >>> logger.info('info message') >>> logger.warn('wa...

excel - Dynamic sum in dax picking distinct values -

below sample data week practice type capacity gen 1 bi c 80 0 1 bi c 80 1 1 bi sc 160 1 1 bi pc 240 0 1 bi pc 240 3 1 bi mc 1160 1 1 bi mc 1160 4 1 bi mc 1160 2 1 bi ac 440 1 1 bi d 40 0 1 bi d 40 3 i have pivot chart, has 3 slicers namely practice, type, , gen. when don't select slicer, should distinct sum(capacity) ie.,2120. when click on type slicer mc sum(capacity) should 1160 , click on gen 3 , clear other filters sum(capacity) = 280 . there can many practices , many weeks. need dax query meet requirement. you need define 2 dax measures: support:=max(table1[capacity]) and distinctsumofcapacity:=sumx(distinct(table1[type]),[support]) now can add distinctsumofcapacity value section of pivot , you'll distinct sum.

clojure - Transform Incanter matrix to nested vector -

consider function outputs incanter matrix. here example matrix containing output function: a 6x4 matrix -4.77e-01 8.45e-01 1.39e-01 -9.83e-18 8.55e-01 2.49e-01 1.33e-01 2.57e-17 -2.94e-03 6.60e-03 -9.63e-01 1.16e-16 ... 6.64e-09 2.55e-08 1.16e-07 -1.11e-16 -1.44e-01 -3.33e-01 1.32e-01 -7.07e-01 -1.44e-01 -3.33e-01 1.32e-01 7.07e-01 i'd continue analyzing rows of matrix, represent points. function want feed incanter matrix takes nested vectors inputs. so function need above data in form [[-4.77e-01 8.45e-01 1.39e-01 -9.83e-18] [8.55e-01 2.49e-01 1.33e-01 2.57e-17] [-2.94e-03 6.60e-03 -9.63e-01 1.16e-16] [6.64e-09 2.55e-08 1.16e-07 -1.11e-16] [-1.44e-01 -3.33e-01 1.32e-01 -7.07e-01] [-1.44e-01 -3.33e-01 1.32e-01 7.07e-01]] it transformation incanter matrix representation nested vector structure unsure how perform. there simple way convert data's representation? you can build-in to-vect function : (to-vect m) or build-in to-li...

javascript - Keep entire word on specific column width -

Image
i've tried differents approaches it, came same results: using word-wrap:break-word; how can insert dynamically tag , adjust column width, without "breaking" word? jsfiddle #game_tag_cloud span { display: inline-block }

string - Check for a substring in C++ -

this added functionality need build existing library. trying to check if string contains substring. have pointers start , one-past-the-end of main string,(which substring of larger string) , word search string datatype. char * start; char * end; string wordtosearchfor i read find in c++, having trouble figuring out how work pointer inputs. there inbuilt function works inputs in form? or efficient read start end new string can used find? thanks! first of can indeed use member function find of class std::string. example char * start; char * end; std::string wordtosearch; // setting values variables std::string::size_type n = wordtosearch.find( start, 0, end - start ); also there standard algorithm std::search declared in header <algorithm> example char * start; char * end; std::string wordtosearch; // setting values variables std::string::iterator = std::search( wordtosearch.begin(), wordtosearch.end(), start, ...

openshift email sends from terminal but not from php -

i'm using openshift , have problem sending email. it works fine when logged in via ssh, eg: echo “test postfix” | mail -s “test1″ me@yahoo.com however if want send email php code this: if (mail ('me@yahoo.com', "test postfix", "test mail postfix", "from: somebody@example.com")) echo "mail sent succesfully"; else echo "couldn't send mail"; it writes "mail sent succesfully", no email arrives :( tried without header too, it's same. checked settings smtp , sendmail_path , sendmail_from , smtp_port , both php -i , phpinfo() . same: smtp_port=25 sendmail_path= (the path sendmail) smtp=localhost (also tried ini_set("smtp", "smtp.mysmtp.com")). error.log contains no error. can't find email.logs. can suggest solution? as far know, need real sender account in order make it. that's why other answers suggest plugins/libraries. need provide not valid ...

django 403 forbidden - redirect to login -

how can redirect user login page when confronted 403 forbidden? consider following code: urls.py router = routers.defaultrouter() router.register(r'users', views.userviewset) urlpatterns = patterns('', url(r'^', include(router.urls)), ) views.py class userviewset(viewsets.modelviewset): queryset = user.objects.all() serializer_class = userserializer renderer_classes = (renderers.jsonrenderer, renderers.templatehtmlrenderer) template_name='rest_framework/users.html' def list(self, request, *args, **kwargs): response = super(viewset, self).list(request, *args, **kwargs) if request.accepted_renderer.format == 'html': return response({'request':request, 'queryset': response.data['results']}) return response if visit /domain/users while not logged in, i'll 403 forbidden error. instead, redirect login page. i...

Avoiding using global objects when building an R package with multiple separate functions -

i have built r package runs complex bayesian model (dirichlet process mixture model on spatial data) including mcmc, thinning , validation , interface googlemaps. i'm happy performance , runs without problems. issue on cran , rejected because extensively use global variables. the package built around use of 8 core functions (which user interacts with): 1) loaddata: loads in data, extracts key information , sets series of global matrices other small list objects. 2) modelparameters: sets model parameters, option plot prior on parameter sigma on googlemap. calculates hyper-prior @ point , saves large matrix global environment 3) graphicparameters: sets graphic parameters of maps , plots (see code below) 4) createmaps: creates prior surface on source location tau , plots data on google map. keeps number of global objects saved repeated plotting of map. 5) runmcmc: runs bulk of analysis using mcmc (a time intensive step), creates many global objects. 6) thinandanalsye...

android - The app screen is smaller on my phone -

Image
i have made snake app, uses canvas: the xml layout: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="bottom" android:orientation="vertical" > <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > <linearlayout android:id="@+id/surface" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_weight="1" > </linearlayout> <linearlayout android:id="@+id...