Posts

Showing posts from September, 2012

terminate - My C code doesn't output anything, or end running -

i'm trying answer question: the prime factors of 13195 5, 7, 13 , 29. what largest prime factor of number 600851475143 ? here code: #include <stdio.h> int isprime(long long num) { (long long k = 1; k < num; k++) { if (num%k == 0) return 0; } return 1; } long long num = 600851475143; int main(void) { long long prime_factor = 0; (long long j = 2; j < num; j++) { if (num % j == 0 && isprime(j) == 1) prime_factor = j; } printf("%lli\n", prime_factor); } but reason doesn't print anything, or end. causing this? that's terribly inefficient way of finding prime factors of number. to find prime factors, should: create static list of primes less or equal (number / 2). iterate on each element in list of primes , see if each 1 can evenly divide number. divide original number prime, , check last number again...

assembly - Segment registers and paragraph boundaries 8086 -

does segment registers hold physical address used base address or because segments can start on paragraph boundary, segment register hold ordinal number of paragraph boundary , when multiplied 10h final physical base address formed , offset added. right? segment registers work describe on actual 8086 processor. physical address of memory operand determined multiplying value in relevant segment register 16 , adding effective address of operand. on modern intel processors segmentation works way while in real mode , virtual 8086 mode. (strictly speaking works as-if how virtual/physical addresses calculated. in reality loading segment register in real mode loads hidden selector cache entry segment base, , value in cache used when calculating virtual/physical address. selector cache exists speed segmentation in protected mode segment registers used indexes tables in memory.)

ruby on rails - Carrierwave or Paperclip: Keep image/file when updating other form fields -

when using either carrierwave or paperclip works expected exception of edit/update. when image or file exists record it's set nil on save if don't explicitly upload file. what i've been looking for, haven't found, solution allows other form fields updated keeps existing file. unless, of course, file updated well. my setup using nested models both carrierwave , paperclip i've tried following no success. https://github.com/carrierwaveuploader/carrierwave/wiki/how-to%3a-keep-%28not-replace%29-files-on-nested-edits apparently i'm missing can't life of me figure out what. any appreciated. i use paperclip nested_form , it's straight forward, no surprises. did make sure check if nested record new record or existing? want display file_field if it's new record, otherwise display image (or file_field). that's link explained. additionally post params sent on submit - check logs that.

c# - Reading response data from a web service -

i'm using this hook client application web service. in addition, i'm looking @ msdn reading getresponse per first link. here's code i've got far: public actionresult index() { webrequest request = webrequest.create("http://localhost:49474/api/store/get"); request.method = "get"; webresponse response = request.getresponse(); stream stores = response.getresponsestream(); encoding encode = system.text.encoding.getencoding("utf-8"); streamreader sr = new streamreader(stores, encode); char[] read = new char[1024]; int count = sr.read(read, 0, 1024); list<store> storeslist = new list<store>(); while (count > 0) { // need read contents of response strem above instantiated list of stores. } } my api delivers data this: public httpresponsemessage get() { list<store> stores = d...

sql server 2008 - Selecting rows as columns with case on SQL -

Image
what want achieve add names current select , highlighted cells on same row right getting result with select case sc.tipo when 1 sc.saldoini else 0 end, case sc.tipo when 2 sc.importes1 else 0 end, case sc.tipo when 3 sc.importes1 else 0 end, case sc.tipo when 1 sc.importes1 else 0 end saldoscuentas sc inner join cuentas c on c.id = sc.idcuenta sc.ejercicio = 13 , sc.idcuenta = 131 how go putting highlighted text on 1 row you can put case statements inside sum function query return 1 row. sum(case sc.tipo when 1 sc.saldoini else 0 end) saldoini

java - How do I open my own inventory via a Event? -

i trying open inventory whenever pick item. in bukkit. here event far, arguments player.openinventory empty. @eventhandler public void blank(playerdropitemevent e){ player player = e.getplayer(); player.openinventory(); } try using player.getinventory() retrieve inventory using player.openinventory(inventory) open it. @eventhandler public void blank(playerdropitemevent e) { player player = e.getplayer(); inventory inventory = player.getinventory(); player.openinventory(inventory); }

Creating image table in python -

here problem: have n images. have same width , height, png. want make image(png) contains table out of them have 5x(n/5) images in putting them next each other. i never tried creating images in python, me package , functions use? it seems trivial knows how vote down no 1 knows answer, right? ok, package image, create canvas need image.new(colour_mode, size=(x,y), colour) put image image need image.paste(image, (left, up, right, down)) thanks lot nothing.

javascript - how do you do querySelector for no attributes -

given elements: <link arbitrary="arbitrary">1st link</link> ... <link>the link want</link> ... what queryselector() selector selecting "the link want"? there may number of links arbitrary attributes before or following "the link want", element without attributes. don't want loop through queryselectall() list. [update] queryselector doesn't require html elements, plain old nodes. working on xml dom loaded atom feed: var parser = new domparser(); var xmldoc = parser.parsefromstring(xmlsrc, "text/xml"); var xmlelem = xmldoc.documentelement; // fragment: <feed> <entry> <link rel='replies' type='application/atom+xml' href='..' title='...'/> <link rel='replies' type='text/html' href='...' title='...'/> <link>the link want</link> <link rel='self' type='application/atom+xml' h...

shellcode - What Does Assembly Instruction Shift Do? -

i came across pretty interesting article demonstrated how remove nullbyte characters shellcode. among techniques used, assembly instructions shl , shr seemed occupy rather important role in code. i realize assembly instructions mov $0x3b, %rax , mov $59, %rax each generate machine code instructions 48 c7 c0 3b 00 00 00 . cope this, author instead uses mov $0x1111113b, %rax fill register system call number, generates instead machine code 48 c7 c0 3b 11 11 11 , removes nullbytes. unfortunately, code still doesn't execute because syscall treats 3b 11 11 11 illegal instruction, or causes code seg fault. author did shift %rax , forth 56 bytes commands shl $0x38, %rax shr $0x38, %rax after shift, code executes perfectly. want know how shift instructions fixes 48 c7 c0 3b 11 11 11 issue, , somehow makes %rax proper , syscall'able. know shl/shr shifts bits left , right, meaning shifting left moves bits higher bits, , shifting right makes them lower again...

html - Javascript: Hang-Man Function Not Working -

i making simple hang-man game using browser. when user clicks on button, calls function pickword() : <button onclick="pickword()" id="restart">pick word</button> the function picks random word dictionary, assigns variable, , creates spaces ( _ _ _ _) word put in html table. function pickword() { var word = dictionary[math.floor(math.random()*dictionary.length)]; wordspaces = "_" * word.length; document.getelementbyid('spaces').innerhtml = wordspaces; } this not working: spaces not displayed on table. i made jsfiddle solve problem. you can't apply multiplication string , number, need use loop build wordspaces string. there comma missing after first line in dictionary array. in jsfiddle, javascript code wrapped inside onload function, didn't have pickword in global scope. updated: https://jsfiddle.net/24eqxlpn/1/

java - How to pass system properties to a jar file -

i have main class expects properties pass using -d option. can access in ide sending them vm options. i package application jar file using maven , when try following: java -jar myjar.jar -denviroment=dev or java -jar myjar.jar "-denvironment=dev" the enviroment system property not getting picked up. any pointers on going on? pass arguments before -jar . if pass them after jar file interpreted command line parameters , passed string[] args in main . like, java -denviroment=dev -jar myjar.jar

php - Javascript document.GetElementById('iframe_id').src = 'link' working only once -

Image
so here's simple question i'm having difficulties on solving see have iframe , want change it's src depending on link clicked here's javascript code function showoverlay(id) { var str1 = 'abstract.php?id='; var link = str1.concat(id); document.getelementbyid(id).style['display'] = "block"; document.getelementbyid(id).style['opacity'] = "1"; document.getelementbyid('abstract_frame').src = link; } function hideoverlay(el, evt) { if (el && evt) { el.style.display = evt.target == el ? 'none' : ''; } document.getelementbyid('abstract_frame').src = ''; } so used document.getelementbyid('abstract_frame').src = link; set src on hideoverlay function used document.getelementbyid('abstract_frame').src = ''; set src blank link. so problem when c...

android - RelativeLayout won't wrap right-aligned TextView -

in messaging app's xml right-aligned messages (outgoing), can't relativelayout wrap it's content (a textview that's aligned right). post picture, i'm new here, , need more reputation before that's possible. the relativelayout containing text (message) has text bubble sort of background, , want nicely wrap around text. got working in other xml-file, left-aligned messages (incoming). to specify, problem innermost relativelayout. here's code: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp"> <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginstart="10dp"> ...

c# - System.InvalidOperationException: -

protected void btnlogin_click(object sender, eventargs e) { string id = request.form["txtid"]; string password = request.form["txtpassword"]; string strconstring = configurationmanager.connectionstrings["soconnectionstring"].connectionstring; oledbconnection conn = new oledbconnection(strconstring); oledbcommand cmd = new oledbcommand("select * usermaster userid =" + id + ""); try { // clientscript.registerstartupscript(this.gettype(), "yourmessage", "alert('" + id + " " + password + "');", true); conn.open(); oledbdatareader dr; dr = cmd.executereader(); txtid.text = "test1"; //txtpassword.text = dr["userpwd"].tostring(); //oledbdatareader dr; //while (dr.read()){ // clientscript.registersta...

internet explorer - IE11 CSS :hover missing some mouseout events? -

Image
this weird 1 difficult reproduce... we have following css/dom constructs: <style> .mycheckboxclass { border-radius: 4px; /* plus -mox/-webkit/-khtml versions */ margin: 0 20px 0 0; padding: 2px 5px 2px 5px; } .mycheckboxclass:hover { background-color: #fe9e19; } </style> <div class="mycheckboxclass"> <label> <input type="checkbox" value="true" name="cb1" /> checkbox label goes here </label> </div> ie11 stuck background-color: #fe9e19; on multiple elements, seemingly not registering mouseout !? tends happen when mouse being moved rapidly between elements (hopefully img showing, i'm locked out of imgur form work) oddly, it's top right 1 can stick often, , margin setting between , it's left neighbor it's not ie should getting confused due elements abutting each other. ...bueller?

python - parsing rss different tags extract image -

hi trying extract images multiple sites rss. first rss <enclosure type="image/jpeg" length="321742" url="http://www.sitio.com.uy//uploads/2014/10/19/54441d68e01af.jpg"/> second rss <g:image_link>http://img.sitio2.com/imagenes/314165_20150422201743_635653477836873822w.jpg</g:image_link> need extract url of image. my code beatifulsoup in python response = requests.get(url) soup = bs4.beautifulsoup(response.text) items = soup.find_all('item') item in items: title = item.find('title').get_text().encode('utf-8') description = item.find('description').get_text().encode('utf-8') category = item.find('category').get_text().encode('utf-8') image = item.find('enclosure') print(image) you can search multiple tags using tag list. item.find(['enclosure', 'g:image_link']) this return f...

Wordpress Home page and Index page -

how make index.php page home page. please trying make slide show on home page , don't think working because of index.php not set home page. create new page - put html code on page(only in source) , set frontpage in appearance -> customize -> static font page -> front page displays.that work . :)

html - Changing meta name for theme via Tumblr API -

i wondering if possible change meta name variable in tumblr theme's html through tumblr's api in way? basically, have following variable, use set color of links in tumblr theme. <meta name="color:mycolor" content="#000000"/> i have list of random colors parsed website , put text file python. is there way can select line of text file or somehow use python replace content variable? it doesn't need read text file.

Android copy database directory issue? -

i have application need access assets folder database data when application start, doing copy data assets action, in last release, user cannot open application, user can. may know, if need copy database assets folder user device, database directory path should use store copied database? or missing important thing in code? as now, doing on device: createdirectory: public boolean createdirectory() { if(environment.getexternalstoragestate().contains(environment.media_mounted)) { string rootpath = environment.getexternalstoragedirectory().getabsolutepath()+globalconfig.config_data_dir; if( isneeddl( rootpath )) { file mydir = new file(rootpath); return mydir.mkdirs(); } } return false; } and database directory, globalconfig.config_data_dir = "/data/" path = environment.getexternalstoragedirectory().getabsolutepath()+globalconfig.config_data_dir; and in sqliteopenhelper class: check if database e...

python - Creating a function that assigns a random index location a specific number -

so i'm working on card game project in python, , i've been given starter code work with. have function called assigncard , supposed assign index location in array of 52 "cards" deck, player, or computer. here code: """ cardgame.py basic card game framework keeps track of card locations many hands needed """ numcards = 52 deck = 0 player = 1 comp = 2 cardloc = [0] * numcards suitname = ("hearts", "diamonds", "spades", "clubs") rankname = ("ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king") playername = ("deck", "player", "computer") def main(): cleardeck() in range(5): assigncard(player) assigncard(comp) showdeck() showhand(player) showha...

ios - After using self sizing cells reloadData doesn't work anymore -

i have uitableview custom cell. there button, 1 label , 1 hidden label in cell. want hidden label visible after clicking button. when using self sizing cells can't reload tableview after setting hidden label visible. the self sizing cells working fine these 2 lines of code in viewdidload() function. self.tableview.estimatedrowheight = 68.0 self.tableview.rowheight = uitableviewautomaticdimension this viewcontroller class: class viewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet weak var tableview: uitableview! override func viewdidload() { super.viewdidload() //self sizing cells self.tableview.estimatedrowheight = 68.0 self.tableview.rowheight = uitableviewautomaticdimension } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return 1 } func tableview...

javascript - d3: how to interpolate a string (with numbers in it) so that the numbers don't get interpolated -

i'm newbie in javascript few weeks delved d3.js trying create spatio-temporal visualisation. what want achieve ( https://jsfiddle.net/dmatekenya/mz5fxd44/ ) based on code shown below: var w1 = ["dunstan","mercy","lara","khama"]; var w2 =["august 1,2013","august 2,2013","august 3,2013"] var text = d3.select("body") .attr("fill","red") .text("dunstan") .attr("font-size", "50px"); var j = 0; var transition = function() { return text.transition().duration(500).tween("text", function() { var = d3.interpolatestring(w1[j], w1[j + 1]); return function(t) { this.textcontent = i(t); }; }).each('end', function() { j += 1; if (!(j > w1.length)) return transition(); }); }; transition(); however, instead want use date string ( w2 in code snippet above). when d3 interpolates numbers e...

sys - Read argument with spaces from windows cmd Python -

i'm trying read arguments spaces in windows cmd. so here code. from avl_tree import * import sys,os if __name__ == '__main__': avl = avltreemap() infile = sys.argv[1] + '.txt' avl._preprocessing(infile) avl._interface(infile) i've written sys.argv[1] since i'm gonna type in cmd following: python filename.py textfilename but if text file has spaces in name won't work that. suggestions? thanks in advance. this hacky fix, , wouldn't suggest because mess other arguments might need add later this: infile = " ".join(sys.argv[1:]) + '.txt' so if run program this: python filename.py file name infile equal "my file name.txt"

javascript - Iterate over String of JSON Format -

i passing mongodb query result in string format jsp page using ajax. retrieving data don't know how iterate on data. note : json structure of dynamic schema given below query result in string format [ { "_id":"...", "user":"john doe", "hobbies":["1","2","3"], "address":{ "city":"...", "state":"...", "country":"..." }, "cell":97265xxxxx }, { "_id":"...", "user":"john doe", "hobbies":["1","2","3"], "cell":97265xxxxx } ... ] first converting json string javascript object using jquery parsejson() & trying loop on data showing me undefined. here code <button>click me</button><br/> <p id="p0"></p> <p id="p1"></p>...

Learning to implement a C++ BubbleSort using function pointers -

my compare function simple return true or false. bubblesort works going through vector once, sorting once, not going continue sort. if numbers 1, 5, 2, 4, 3, 6, 5, 1, 4, 2, 6, 3. instead of 1, 2, 3, 4, 5, 6. if use bool swapped, there error. here code: void bsort(vector<int> &vector1, bool (*compare) (int a, int b)) { bool swapped = true; //using swapped in following code causes crash while(swapped) { swapped = false; (int = 0; < vector1.size(); ++i) { (int j = 1; j < vector1.size(); ++j) { if ((*compare)(vector1[i], vector1[j]) == true) { swap(vector1[i], vector1[j]); swapped = true; } } } } } i have seen function before, , trying implement because want learn. please help. edit: here fixed , working function! :) void bsort(vector<int> ...

r - Result out of SQL to list -

i have data set out of sql in csv format , table/data structure. order id items o1 beer o1 wine o2 beer o2 wine o3 beer o4 chips i need convert in r following format o1 beer,wine o3 beer,chips any appreciated. i tried following : # mock data o1 <- c("beer","wine") o2 <- c("beer","wine") o3 <- c("beer","chips") o4 <-c("curd","chips") o5 <-c("beer") o6<-c("wine") o7 <-c("fruits") o8<- c("wine","cheese") order <- list(o1,o2,o3,o4,o5,o6,o7,o8) library(arules) dt <- (order,"transactions") output: str(order) list of 8 $ : chr [1:2] "beer" "wine" $ : chr [1:2] "beer" "wine" $ : chr [1:2] "beer" "chips" $ : chr [1:2] "curd" "chips" $ : chr "beer...

how to handle arbitrary dimensional vector in c++? -

i want create function can handle arbitrary dimensional vector, function in psudocode: template<class t> void printvector(vector<t> t){ if(t==vector){ printf("["); for(auto it=t.begin(),it!=t.end();++it){ printvector(*it); } printf("]"); }else{ printf("%d ",t); } } for example: vector<int> a; a.push_back(12); a.push_back(34); printvector(a); the output should [12 34], vector<vector<int> > b; vector<int> b1; b1.push_back(1); b1.push_back(2); b.push_back(b1); vector<int> b2; b2.push_back(3); b2.push_back(4); b.push_back(b2); printvector(b); the output should [[1 2][3 4]] the c++ template system supports recursion. had right idea, need overload function: void printvector(int t) { printf("%d ", t); } template<class t> void printvector(std::vector<t> t) { printf("["); for(auto v : t)...

User input to specify array name [bash] -

i started learning bash/shell fun, , i'm trying create simple script should take user input, should name of pre-built array, , say each item in array pause in between. here's have far: #!/bin/sh array=("foo" "bar" "baz") read -p "which array should read you? " answer item in ${answer[@]} "$item [[slnc 1000]]" done please let me know if can point me in right direction! you can access array using variable array name this: #!/bin/bash array=("foo" "bar" "baz") read -p "which array should read you? " answer tmp="$answer"[@]; item in "${!tmp}"; echo "$item [[slnc 1000]]" done then use above script as: bash arr.sh array should read you? array foo [[slnc 1000]] bar [[slnc 1000]] baz [[slnc 1000]]

c# - Excel interop MissingMethodException on some systems -

in c# program, using microsoft.office.interop.excel. reading & writing data excel file. on 1 machine, though has office 2007, there seeing below exception, raises @ getcomponentpath() method call. unhandled exception: system.missingmethodexception: method not found: 'system.type system.runtime.interopservices.marshal.gettypefromclsid(system.guid)'. here code: public static string getcomponentpath(officecomponent _component) { string toreturn = string.empty; string _key = string.empty; try { microsoft.office.interop.excel.application _excelapp = null; _excelapp = new microsoft.office.interop.excel.application(); if (_excelapp != null) { console.writeline("excel installed"); } else { console.writeline("excel not found."); } } catch (exception ex) { console.writeline("error \n" + ex.tostring()); }...

python - ARMA modelling ARIMAResults.predict -

when tried implementing code suggested in correct wat use armaresults.predict() function . follows import numpy np import scipy stats import pandas pd pandas import series,dataframe import statsmodels.api sm dates=pd.date_range('2011-1-30','2011-04-30') dataseries=series([22,624,634,774,726,752,38,534,722,678,750,690,686,26,708,606,632,632,632,584,28,576,474 ,536,512,464,436,24,448,408,528,602,638,640,26,658,548,620,534,422,482,26,616,612,622,598,614,614,24,644,506,522,622,526,26,22,738 ,582,592,408,466,568,44,680,652,598,642,714,562,38,778,796,742,460,610,42,38,732,650,670,618,574,42,22,610,456,22,630,408,390,24 ],index=dates) df=pd.dataframe({'consumption':dataseries}) df input_data_point = len(df) p = 1 q = 0 result = sm.tsa.arma(df[:input_data_point], (p, q)) start_pos = max(result.k_ar, result.k_ma) fit = [] t in range(start_pos, len(df)): value = 0 in range(1, result.k_ar + 1): value += result.arparams[i - 1] * df[t - i] in ...

ruby - Enable/disable the custom field when another custom field is selected -

i need disable 1 custom field when other custom field selected. example, have custom field dropdown format. when click on 2nd option of particular custom field,the other custom field should disabled , 1 more custom field should enabled. how do in redmine ? as understood wanted change option of 2nd dropdown box on bases of 1st dropdown's option selection: this sample code perform same using jquery. can modify per requirement. html <select class="product" id="select_1" name="product"> <option selected="selected" value=""> choose category </option> <option value="mens suits"> mens suits </option> <option value="womens suit"> womens suits </option> <option value="children suit"> children suits </option> </select> <select class="size" id="select_3" name="size"> <option selected=...

command line - Windows Batch echo variable with old value -

here's sample: d:\>set var=123 d:\>set var=456 & echo %var% 123 d:\>set var=789 & echo %var% 456 a new value set in var variable, echo still displays old value. anyone have clue happened? , how correct value? when execution of command or block of commands (commands concatenated or enclosed in parenthesis) requested, parser replaces read operations on variables content in variable before starting execute commands/block in case, value in variable changed @ execution time, value echo console determined before change made. can tested with set "var=abc" set "var=123" & set var & echo %var% set var show correct value in variable (in command there no variable read operation replaced parser) echo show old value (replaced parser before command execution). inside batch files, usual way handle use delayed expansion ( setlocal enabledelayedexpansion command), allow change, needed, syntax access variables %var% !v...

java - JPA-ECLIPSELINK FUNCTION throwing error -

i executing below query:- select function(lower,d.comp) peopledbvo d d.person = :persons; but getting error unexpected token [function] internal exception, tried func getting same error. here using function execute database function lower. you can directly use lower function because it's part of jpa spec: http://www.objectdb.com/java/jpa/query/jpql/string select lower(d.comp) peopledbvo d d.person = :persons;

Python file to exe not working in all locations in my computer only works in dist folder in python installation -

Image
i have created exe file python file add.py in case, followed tutorial tutorial my setup.txt file follows: from distutils.core import setup import py2exe setup(console=['add.py']) setup(options = { "py2exe": {"includes": ["encodings"]}}) the following exe creation step: i got output exe file add.exe in location c:\python34\dist . double clicked , working. when move add.exe location suppose c:\python34 or other location in system not working. giving following error instead of executing: i not have idea why misbehave way. need exe file work locations. how can solve this? appreciated!! setup( console=['add.py'], options = { "py2exe": { "includes": ["encodings"], "bundle_files": 1, "ascii": false } }, zipfile = none )

jquery - Click event not fired on button with svg element in Safari -

in safari click event not fired on button svg element. when click on buttons edge click event fires, if click on svg element not. $(document).on('click', 'button', function(e) { console.log(e); }); it works if attach click event this: $('button').on('click', function(e) { console.log(e); }); because of buttons added dynamically can't this; example in codepen.io http://codepen.io/neilhem/pen/bdgypq jquery version 2.1.3 i don't know best way solve problem, adding pointer-events: none; svg element solved problem. svg.icon { pointer-events: none; }

codeigniter - According to google my desktop site is not mobile friendly -

i have desktop view(test.com) , mobile view(m.test.com) site. redirecting mobile view through codeigniter constructor . public function __construct(){ parent::__construct(); $this->load->library('user_agent'); if ($this->agent->is_browser()) { if($this->agent->mobile()){ $url = $_server['request_uri']; header('location: http://m.test.com'.$url); } } } and working fine. included annotations in site main layout file. in desktop link rel="alternate" media="only screen , (max-width: 640px)" href="http://m.test.com/" in mobile link rel="canonical" href="http://www.test.com/" but google still showing site not mobile friendly. please me out. from looking @ site is, not mobile friendly. seems miss several of following criteria: page eligible “mobile-friendly” label if meets following criteria detected googlebot: a...

c# - Cannot convert varchar value to int in stored procedure in SQL Server -

i have stored procedure create procedure [dbo].[createnewticket] (@practice_id varchar(40), ) /* insert rows ticket table */ begin declare @prctid int select @prctid = 'select id practice_detail practice_name_description = ' + @practice_id + ';' end go but whenever passing value c# stored procedure throwing error. conversion failed when converting varchar value 'select id practice_detail practice_name_description = bankson pt- daniel (dba);' data type int. can explain doing wrong? try this create procedure [dbo].[createnewticket] ( @practice_id varchar(40), ) /* insert rows ticket table */ begin declare @prctid int select @prctid = id practice_detail practice_name_description = @practice_id; end go

sql server - How to use tags in Simatic WinCC Flexible VB script -

i trying insert wincc tags value sql server. firstly defined sql connection , i've tested inserting rough values simple sql tag like: strsql = "insert test (t1,t2) values (3,4)" i saw can use variables in sql cmd const d = 5 strsql = "insert test (t1,t2) values (" & d & ",4)" how should use wincc tags instead of variable? i can share code used wincc flexible 2008 insert database simple record afeter recipe finished plant. '------------------------------------------------------------ dim sserver,sdatabasename ,sconn,oconn,ors, fetchdata dim susername,spassword dim adopenkeyset, adlockoptimistic, adcmdtable dim mrecordstr, tablename dim field dim loc_pressure dim loc_enddatetime dim loc_receipe dim loc_begindatetime dim loc_user dim loc_temperature loc_user = smarttags("databasesql\var_user") loc_begindatetime = cdate(smarttags("databasesql\var_begindatetime")) loc_enddatetime = cdate(smarttags(...

imageview - Android loading local image with space in path and with universal image loader -

i developing android application in want display local image of universal image loader. when try display image has space in it's local image path not able display image. tried in following manner: uri.fromfile(new file(newimagepath)).tostring(); i getting following error: java.io.filenotfoundexception: /storage/emulated/0/whatsapp/media/whatsapp%20images/img-20150421-wa0002.jpg: open failed: enoent (no such file or directory) @ libcore.io.iobridge.open(iobridge.java:456) if tried load image has no space in local path works fine image space in path cause issue. need help. thank you. actually problem universal image loader. https://github.com/nostra13/android-universal-image-loader/issues/371 so have decode image path remove space. as per discussion in above link got solution : final string uri = uri.fromfile(file).tostring(); final string decoded = uri.decode(uri); imageloader.getinstance().displayimage(decoded, imageview);

ruby on rails - Command not found mina -

im trying start deploying rails app mina cant seem initialized as can see here im not doing out of ordinary, have added mina gem list, installs fine, executable isn't found. ➜ trackitall git:(master) ✗ bin/bundle install 40 other gems using mina 0.3.4 bundle complete! 41 gemfile dependencies, 143 gems installed. use `bundle show [gemname]` see bundled gem installed. ➜ trackitall git:(master) ✗ mina init zsh: command not found: mina ➜ trackitall git:(master) ✗ i using rbenv ruby 2.1.5 project. ( osx 10.10.3 ) there no mina shim in ~/.rbenv/shims folder. far understand rbenv here should executables specific ruby env. i using rbenv , had same problem mina not being found. had was: rbenv rehash and then mina init

ios - How to convert Text into Emoji? -

Image
i have plan convert text emoji. but, don't know how start. here screen shots looking for. i have idea in mind achieve above result should save dictionary each character question how dictionary save emoji according character structure. i suggest using simple bitmap technique. in first step build black , white bitmap written text in same dimensions have final image. in second step "divide" image raster e.g. 20% smaller final emoji character create overlapping effect. in each raster rectangle calculate black pixels. there percentage between 0-100% black pixels. if percentage e.g on 40%, random emoji placed @ center of rectangle. you can improve effect adding small amount of random displacement. final thoughts i implemented , worked great. improve image further small optimization: for each rectangle >40% black, divide rectangle 4 zones (top left, top right, bottom left, bottom right). if 1 of zones has black pixel in it, count zone 1 o...

search contacts by phone number, filter using a 3 digit prefix -

i want phone numbers in contacts start specific 3 digits, eg "012" when hit button. i've been working on using following code: private void buttoncontacts_click(object sender, routedeventargs e) { contacts cons = new contacts(); //identify method runs after asynchronous search completes. cons.searchcompleted += new eventhandler<contactssearcheventargs>(contacts_searchcompleted); //start asynchronous search. cons.searchasync("0109", filterkind.phonenumber, "state string 5"); } void contacts_searchcompleted(object sender, contactssearcheventargs e) { try { //bind results user interface. contactresultsdata.datacontext = e.results; } catch (system.exception) { //no results } if (contactresultsdata.items.any()) { contactresultslabel.text = "results"; } else { contactresultslabel.text = "no results"; } } but filter...

How do i mention user in my Comment while replying from FACEBOOK GRAPH API? -

i using facebook graph api , want know how can mention person in comment while replying post? when trying format @[id:name] e.g (@[12345:abc]) gives me error like { "error": { "message": "(#1705) there error posting wall", "type": "oauthexception", "code": 1705 } } as per post of stack overflow tagging/mentioning pages or users in posts via graph api i come know cannot tag user via api. you can't tag people on feed using graph api, have use open graph concepts- mention tagging/ action tagging (based on requirement) source : tagging/mentioning pages or users in posts via graph api you can use open graph api - https://developers.facebook.com/blog/post/2012/08/21/bringing-mention-tagging-to-open-graph/

html - Breadcrumbs on current page -

i have implemented breadcrumbs this: <div itemscope itemtype="http://data-vocabulary.org/breadcrumb"> <a href="home url" itemprop="url"> <span itemprop="title">home title</span> </a> > </div> <div itemscope itemtype="http://data-vocabulary.org/breadcrumb"> <a href="1st level url" itemprop="url"> <span itemprop="title">1st level title</span> </a> > </div> <div itemscope itemtype="http://data-vocabulary.org/breadcrumb"> <span itemprop="title">current title</span> </div> as can see, haven't specified url current page, redundant. when try google testing tool , error saying url missing current page breadcrumb. given that, have 3 options can think of. i specify url current page: <div itemscope itemtype="http://data-vocabulary.org...

android - Error showing at onCreate() while using AppCompactActivity -

i updated sdk 22(android 5.1.1). used appcompactactivity instead of activity. here logcat output. 04-23 13:51:40.524: e/androidruntime(3150): java.lang.noclassdeffounderror: android.support.v7.app.appcompatdelegateimplv11 04-23 13:51:40.524: e/androidruntime(3150): @ android.support.v7.app.appcompatdelegate.create(appcompatdelegate.java:77) 04-23 13:51:40.524: e/androidruntime(3150): @ android.support.v7.app.appcompatactivity.getdelegate(appcompatactivity.java:414) 04-23 13:51:40.524: e/androidruntime(3150): @ android.support.v7.app.appcompatactivity.oncreate(appcompatactivity.java:57) 04-23 13:51:40.524: e/androidruntime(3150): @ com.emapps.easystudy.startactivity.oncreate(startactivity.java:61) 04-23 13:51:40.524: e/androidruntime(3150): @ android.app.activity.performcreate(activity.java:5451) 04-23 13:51:40.524: e/androidruntime(3150): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1093) 04-23 13:51:40.524: e/androidruntime(3150...

java - Why can't we add BigDecimal to TreeSet ? -

this question has answer here: why bigdecimal natural ordering inconsistent equals? 4 answers i read somewhere can't add bigdecimal treeset because incorrectly implements compareto method , e.g. 9.0 , 9.00 , return 0 , although using equals method return false. seems reason. can explain in bit more detail ? equals() in case return false because precision different. compareto() return 0 because "value" same.

How to export mysql database in .sql extension using php code or in codeigniter -

how can download .sql file using php code or codeigniter code! $this->dbutil->backup() permits backup full database or individual tables. backup data can compressed in either zip or gzip format. note: features available mysql databases. note: due limited execution time , memory available php, backing large databases may not possible. if database large might need backup directly sql server via command line, or have server admin if not have root privileges. usage example // load db utility class $this->load->dbutil(); // backup entire database , assign variable $backup =& $this->dbutil->backup(); // load file helper , write file server $this->load->helper('file'); write_file('/path/to/mybackup.sql', $backup); // load download helper , send file desktop $this->load->helper('download'); force_download('mybackup.sql', $backup); follw link

php - Can MYSQLI prepare statements independently of execution? -

i running site makes heavy use of search function. exploring ways speed , smooth search. my question is, can declare mysqli query , establish connection/prepare independently of executing query , binding results , parameters? this way can declare query , connection once, assumably saving processing time. mess parameters , results of query independently. the below code select x & y table. these 2 variable ones being selected, , connection same. changing element of below code parameter binded onto ? . $query = "select x, y z x = ? "; $stmt = $conn->prepare($query); loop through array , run query each element. foreach($array $key) { $stmt->bind_param('s',$key); $stmt->execute(); $stmt->bind_result($x, $y); while ($stmt->fetch()) { //lalalalalal } $stmt->free_result(); } are there inherent issues method? worth trouble way? beneficial? thanks in advance.

Put whole gitlab installation to read-only mode -

i wish deny push changes repository user. technically, need switch whole gitlab read-only mode. there simple way this? if don't want mess user privileges ( as done in pr ), 1 approach change gitlab-shell pre-receive hook . if pre-receive hook " exit 1 ", should disable push repo.

bash - keep some lines of a file according to some conditions -

i have file of kind : k1 bla started k1 bla finished k2 blu finished k3 bli started k3 bli died_skipped_permanently k4 blo started k5 ble started k5 ble died_skipped_permanently k6 blou started k6 blou started from this, want obtain file where, when each name in column 1 there finished or died_skipped_permanently , line containing information present , not other ones (with started or other things). moreover, if 2 lines identical (like 1 of k6), want print one. with example, output be: k1 bla finished k2 blu finished k3 bli died_skipped_permanently k4 blo started k5 ble died_skipped_permanently k6 blou started i can't delete grep -v started because names, k4 in example, line present , want know started (or not) need keep info. i have file names column 1 obtained with: awk '{print $1}' file | sort | uniq > names # 7,752 lines i thinking loop of kind: for each names present in file ...

Need Image Effect Library for Android IOS both -

i developing photo sharing app in android , ios, in want add image effects instagram app, need image effect library available in android , ios both. please me. thanks!!! you can use aviary sdk: https://developers.aviary.com/docs/android thanks.

cypher - Neo4j apply order to collect function -

i have data follows node - student node - exam relationship (student)-[:given]->(exam) here 1 student has given multiple exams. need fetch last 3 exams of users i have done somthing - match (s:student)-[:given]->(e:exam) return id(s) student_id, s.name student_name, collect({exam_id:id(e), mark:e.marks, exam_date:e.examp_date}) it fetch data me but, need exam ordered exam_date , there should limit can last 3 exams i expecting done in single query please comment here if more explanation needed. thanks try this match (s:student)-[r:given]->(e:exam) s,r,e order e.exam_date desc return id(s) student_id, s.name student_name, collect({exam_id:id(e), mark:e.marks, exam_date:e.examp_date})[0..3]

java - What causes err ' A SPI class of type lucene.codecs.Codec name 'Lucene42' -

Image
can't figure out causing ' spi class of type org.apache.lucene.codecs.codec name 'lucene42' not exist. need add corresponding jar file supporting spi classpath' any appreciated java.lang.illegalargumentexception: spi class of type org.apache.lucene.codecs.codec name 'lucene42' not exist. need add corresponding jar file supporting spi classpath.the current classpath supports following names: [] org.apache.lucene.util.namedspiloader.lookup(namedspiloader.java:104) org.apache.lucene.codecs.codec.forname(codec.java:95) org.apache.lucene.codecs.codec.<clinit>(codec.java:122) org.apache.lucene.index.liveindexwriterconfig.<init>(liveindexwriterconfig.java:118) org.apache.lucene.index.indexwriterconfig.<init>(indexwriterconfig.java:145) com.damn.fr.rr.rent.getresukt(man.java:404) com.damn.fr.rr.handler.pg.setresult(pg.java:103) com.damn.fr.rr.cmd.del.execute(del.java:19) com.damn.fr.rr.servlet.publiccontroller.dopost(controller.java:199) ja...