Posts

Showing posts from February, 2013

c++ - OpenCV: Why does Haar classifier only detect one face and one eye? -

Image
i absolutely newcomer opencv , haar classifiers. have copied following code , works fine, returns 1 face , 1 eye. second eye , face? const char[] eyescascadefilename = "haarcascade_eye.xml"; const char[] facecascadefilename = "haarcascade_frontalface_alt2.xml"; const int haaroptions = cv_haar_do_rough_search; // prepare image fast processing mat grayimage; cvtcolor(colorimage, grayimage, cv_bgr2gray); equalizehist(grayimage, grayimage); // detect faces on image std::vector<cv::rect> faces; facecascade.detectmultiscale(grayimage, faces, 1.1, 2, haaroptions, cv::size(60, 60)); (int = 0; < faces.size(); i++) { // visualize faces cv::point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height); cv::point pt2(faces[i].x, faces[i].y); cv::rectangle(colorimage, pt1, pt2, cvscalar(0, 255, 0, 0), 1, 8 ,0); // detect eyes within facial roi cv::rect rect(faces[

ios - Iversion equivalent for titanium -

i need way check app store latest update of app. one way of doing make api call see latest version , force user download it. reliant on internet connection; better way sync app app store. there native module called iversion, know of titanium equivalent. https://github.com/nicklockwood/iversion inspired harpy project bencoding.ios.tools module allows query appstore , return latest version. check readme further details.

python - Read text data from a website -

my program recursively processes string reverse it. have pull data directly website instead of text file does, can't pull data website. import urllib.request def reverse(alist): #print(alist) if alist == []: return [] else: return reverse(alist[1:]) + [alist[0]] def main(): #file1 = urllib.request.urlopen('http://devel.cs.stolaf.edu/parallel/data/cathat.txt').read() file1 = open('cat.txt','r') line in file1: stulist = line.split() x = reverse(stulist) print(' '.join(x)) file1.close() main() the commented-out lines show have tried. you can use url file: import urllib ... f = urllib.urlopen(url) line in f: ... f.close() what did call read on opened url. read content file1 variable , file1 became string. for python 3: import urllib.request ... f = urllib.request.urlopen(url) line in f: ... f.close() also need convert each line correct encoding.

neural network - How to extract image features using caffe matlab wrapper? -

does use matlab wrapper caffe framework? there way how extract 4096 dimensional feature vector image? following https://github.com/bvlc/caffe/issues/432 and tried remove last lines in imagenet_deploy.prototxt remove layers suggested in forum on github. but still when run "matcaffe_demo(im, 1)" 1000 dim vector of scores (for image net classes). appreciated kind regards it seems might not calling correct prototxt file. if last layer defined in prototxt has top blob of 4096 dimension, there no way output 1000 dimension. to sure, try creating bug in prototxt file , see whether program crashes. if doesn't program indeed reading other prototxt file.

perl - Print 10 elements out of array -

this question has answer here: what's best way last n elements of perl array? 5 answers if have array i've used create 50 random numbers, sort them numerically. lets wanted print out 10 biggest number (elements 40 50) say: print($array[40]) print($array[41]) print($array[42]) etc etc. there neater way it? hope i'm making myself clear. cheers you loop on indexes. say $array[$_] 40..49; offsets end make more sense here. say $array[$_] -10..-1; you use array slice. say @array[-10..-1]; to print them on 1 line, can use join . say join ', ', @array[-10..-1];

html - How to create a form that flys out onto the screen using javascript/css -

i relatively new web programming (not programming, yes web). trying figure out how build form off screen when clicked, moves onto screen allow user fill in fields , submit form field data. found example of i'd on pcmag.com. have 'subscribe' link on right side of screen, when click form moves onto screen off screen filled in , submitted. i'd have posted images, first post here, looks i'm not allowed to. thanks pointers/direction. chris you thinking of modal. use bootstrap or foundation ui framework , ton easier you.

php - Sql Get results older than 10 minutes - wpdb Wordpress query -

hi guys have trouble query need postid's 1 column posts older 10 minutes. time datetime field 2015-03-20 17:15:45 , want work id's - (delete them). empty array. im doing wrong? need each loop? im not this. help $getexe = $wpdb->get_results("select postid rejekt time < date_sub( now(), interval 10 minutes"); echo '<pre>'; print_r($getexe); echo '</pre>'; if time_created unix timestamp (int), should able use this: select postid rejekt time < (unix_timestamp() - 600); (600 seconds = 10 minutes - obviously) otherwise (if time_created mysql timestamp), try this: select postid rejekt time < (now() - interval 10 minute) thanks ivar bonsaksen .

sql server - Combining MSSQL results with Oracle into CFSPREADSHEET -

i have report generates excel file daily data extracted ms-sql database. have add additional columns spreadsheet oracle database id matches id in ms-sql query results. my problem have 1200-1400+ unique ids generated on report first query. when plug them in list oracle query , try cfdump see if results come out should, receive cf error saying query cannot list more 1000 results oracle query. i set values first query valuelist id column , put in clause oracle query. cfdump on oracle receive error. i've tried wrapping cfloop query = "firstquery"> around oracle query , placing #firstquery.columnidname# not work either. so 2 questions have here .. how handle limit on oracle 1k limit , if have read access oracle database coldfusion? after #1 figured out, how combine results oracle query mssql query or in other words, add columns i'm pulling oracle query spreadsheet matching id. thanks. for quick, dirty, , sub-optimal approach, visit cflib.org ,

methods - Else without If error (Palindrome program) -

the program meant find if user input palindrome. in ispalindrome method keep getting stated error. , when fix 24 errors saying can't located multiple other variables. please help. here code: import java.util.scanner; public class project4 { public static void main (string [] args) { string line = getinputline(); while (!isemptyline (line)) { if (ispalindrome (line)) system.out.println ("\"" + line + "\" palindrome , " + getpaltype (line)); else system.out.println ("\"" + line + "\" not palindrome"); line = getinputline(); } system.out.println ("end of prgram"); } public static string getinputline () //ask user input , returns line { scanner scan = new scanner(system.in); system.out.print("enter possible palindro

python - How to add app image path to urls.py? -

when run app on localhost try show random banners configured using adzone , when load home page can't see images used banners, problem path images /media/adzone/bannerads/image.jpg , path automatically used app, , cant change it. how can tell app images there? my settings.py : """ django settings ciudad_tenis project. more information on file, see https://docs.djangoproject.com/en/1.7/topics/settings/ full list of settings , values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # build paths inside project this: os.path.join(base_dir, ...) # quick-start development settings - unsuitable production # see https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # security warning: keep secret key used in production secret! secret_key = '###############################################' # security warning: don't run debug turned on in production! debug = true template_debug = true allowed_hosts = [] # a

orm - Gorm Golang fetching a collection and its relationships -

i started using golang , decided give gorm try orm. works pretty on things, orms it's limited. luckily ties database/sql can custom queries easily. i'm wondering if there other way in gorm: have struct companies, companies have 1 many relationships w/ emails, addresses, , phones. use following code in gorm pull list of companies , corresponding info. use gorm's preload function. db.dbaccess. model(&companies). count(&dbinfo.count). order("companies.id asc"). offset(offset). limit(length). preload("addresses"). preload("phones"). preload("emails"). find(&companies) this works fine. feel there way accomplish without preload function. ideas? you can load related entities later (only when/if needed), using db.related shown in the documentation : // user has many emails db.model(&user).related(&emails) //// select * emails user_id = 111; // user_id foreign ke

java - Random Tour Generation Issues -

i trying generate random tour graph. using adjacency-list method. there problem vertices. when add vertex particular list, vertex gets added lists in graph. not understand why! here's code: public static void main(string[] args) { defaultdata(6); } public static void defaultdata(int n) { integer costs[] = { 26, 95, 38, 74, 80, 73, 73, 92, 22, 97, 13, 81, 41, 17, 4, 2, 47, 54, 21, 68, 78, 4, 77, 3, 66, 55, 99, 42, 62, 39, 8, 36, 53, 74, 26, 8, 42, 66, 30, 58, 69, 14, 49, 39, 85, 98, 72, 3, 18, 99, 96, 66, 64, 36, 17, 44, 70, 0, 8, 14, 62, 41, 84, 59, 94, 27, 5, 27, 96, 10, 15, 52, 43, 20, 2, 86, 45, 43, 32, 17, 49, 92, 9, 15, 6, 49, 72, 7, 51, 21, 2, 26, 63, 82, 98, 48, 21, 96, 16 }; arraylist<arraylist<integer>> costgraph = new arraylist<>(); arraylist<arraylist<integer>> completegraph = new arraylist<>(); random rand = new random(system.currenttimemillis()); int costindex = 0;

odata - Need to fetch Annotation (Notes) for each list in dynamics CRM 2011 -

i trying fetch annotation entity (note) associated every list entity based on list id. want top 1 record when sorted in descending order of created on date. have written below restfull call using odata query in button click event of javascript. function button1_onclick() { var filtercriteria = "$select=notetext&$top=1&$orderby=createdon&$expand=list_annotation&$filter=list_annotation/listid eq '" + document.getelementbyid("text1").value + "'"; sdk.jquery.retrievemultiplerecords( "annotation", filtercriteria, function (results) { if (results != null) { alert("success."); } else { alert("no notes available."); } }, errorhandler, function () { //oncomplete handler } );

elasticsearch - Elastic Search filter with aggregate like Max or Min -

i have simple documents scheduleid. count of documents recent scheduleid. assuming max scheduleid recent, how write query. have been searching , reading few hours , work. { "aggs": { "max_schedule": { "max": { "field": "scheduleid" } } } } that getting me max scheduleid , total count of documents out side of aggregate. i appreciate if me on how take aggregate value , apply filter (like sub query in sql!). this should it: { "aggs": { "max_scheduleid": { "terms": { "field": "scheduleid", "order" : { "_term" : "desc" }, "size": 1 } } } } the terms aggregation give document counts each term, , works integers. need order results term instead of count (the default). , since want highest scheduleid , "size":1 adequate.

javafx - Minimising & Maximising Java fx app programmatically -

i creating custom titlebar application, , implementing minimise && maximise && close buttons stage .. achieving using transparent stagestyle i maximise way stage.setheight(screen.getprimary().getvisualbounds().getheight()-margins); stage.setwidth(screen.getprimary().getvisualbounds().getwidth() -margins); stage.setx(1.0); stage.sety(0.0); // let others know i close way // stop custom stuffs stage.close(); && want minimise any way achieve that?? minimisation problem.. incase of have tried, have tried hide() , toback() -( which seems persuade if have piles of windows on screen ) , not work maximize , de-maximize javafx stage use stage.setmaximized(boolean value) . to maximize: stage.setmaximized(true); to restore pre-maximized size: stage.setmaximized(false); update further questions i want java way of hiding effect of app without closing , reopen on demand sounds question how reduce application icon or restore

java - Error: The constructor CellSignalStrengthGsm() is not visible -

when try code: cellsignalstrengthgsm abc = new cellsignalstrengthgsm(); i following error in eclipse: "the constructor cellsignalstrengthgsm() not visible". the full source code here in source file have noticed following: """"""""""""""""""""""""""""""""""""""""""" /** * empty constructor * * @hide */ public cellsignalstrengthgsm() { setdefaultvalues(); } /** * constructor * * @hide """""""""""""""""""""""""""""""""""""""""" now question above comment means , how object of cellsignals

html - prevent unknown css properties from being removed from the style attribute -

so have js adds style attribute css filters. have added both webkit-prefixed , unprefixed version of property, this: <img src="image.jpg" style="filter: blur(10px); -webkit-filter: blur(10px)"/> i need save html , display in different browser. however, filters aren't visible in different browsers, because unknown attributes removed. example, if filters added in webkit, non-prefixed property removed browser, preventing html later working in firefox. way override browser's removing unknown properties style attribute, unprefixed version visible in different browser. know can add js recalculates filters on pageload, prefer not this. there better solution? i have example here , can see (e.g. in chrome) style attribute not updated css attributes don't apply and $().html() will only. in problem may don't need prefixes. worth notice fact, taken jquery decumentation, that as of jquery 1.8, .css() setter automatically take

postgresql - return select from view, update one column postgres -

i have view. want function returns rows view; however, need change 1 value in each of rows return. i can using select , writing field names in select clause , listing values including 1 change, makes code obscure. seems want light weight temporary table. want write like: update { select * myview f(row,x,y) } set column = y where x , y arguments function, column column name myview, , f function. is there can write? thanks. some pointers: you can view in have list columns separately: create view myviewmodified select y column, ... myview; , after can use select * myviewmodified f(row,x,y); you write select y column1modified, * myview; in code , use column1modified. way can use asterisk-symbol. listing values might make code obscure if drive code through poor sql can make quite clean (it helps if accustomed reading sql queries). why select * considered harmful?

c# - How can I generate a tree with duplicate values -

i need generate tree in node can have particular children, number of node cannot repeat in same branch. 1:5 2:5 3:5 4:5 5:1,2,3,4 ':' means node n can have children x,y,z,... root 0, has possible children, not repeat in tree. 0 / / | \ \ 1 2 3 4 5 | | | | / / \ \ 5 5 5 5 1 2 3 4 / | \ / | \ / | \ / | \ 2 3 4 1 3 4 1 2 4 1 2 3 you need loop 1 5 , have if inside loop see if child same node on (the parent), if is, use continue skip it. if can't repeat in whole branch, have check grand-parent node too, in fact, ancestor nodes. while loop inside main loop. loop until ancestor node checking not 0. inside while loop, need set ancestor ances

Java - array stuck in for loop -

i'm trying fill array keyboard input, method gets stuck on b = in.nextint(); line, in second last value want input. i'm confused. public static void main(string[] args) { scanner in=new scanner(system.in); int a_size; int duplicate; system.out.println("enter test size"); a_size = in.nextint(); int [] a_array; a_array = new int[a_size]; int b; (int i= 0; <a_array.length; i++ ){ system.out.println("enter number"); b = in.nextint(); a_array[i] = b; } system.out.println("passed"); } edit: sorry kind folks. tested code , working fine. simple code , not see wrong it. apologize , agree bundle of sticks. please forgive me. in.nextint(); is waiting enter keyboard, why stuck

php - Routing Circular reference -

here app/config/routing.yml appbundle: resource: "@appbundle/controller/" type: annotation prefix: / rapportbundle: resource: "@rapportbundle/controller/" type: annotation prefix: /rapport fos_user: resource: "@fosuserbundle/resources/config/routing/all.xml" rapportbundle/controller/rapportcontroller.php <?php namespace rapportbundle\controller; use sensio\bundle\frameworkextrabundle\configuration\route; use symfony\bundle\frameworkbundle\controller\controller; use sensio\bundle\frameworkextrabundle\configuration\template; class rapportcontroller extends controller { /** * @template * @route("/", name="rapport_index") */ public function indexaction() { return []; } } and same file appbundle/controller/defaultcontroller.php when launch index defaultcontroller, got : circular reference detected in "/var/www/my-site/app/config/routi

javascript - Highcharts - custom navigator dragger issue with Safari/IE -

Image
i couldn't find posts on issue, figured i'd ask. i'm working custom scrollbar/navigator highcharts, , i'm having display issues in safari , versions of internet explorer. here's how custom scrollbar should displayed: here's how it's showing in safari/ie: as can see, in safari/ie, there appears default dragger displays behind custom dragger, , can't seem figure out how hide it. has had issue before? here code used create custom handles on scrollbar: (function (h) { var d = false; h.wrap(h.scroller.prototype, 'init', function (proceed) { proceed.apply(this, array.prototype.slice.call(arguments, 1)); }); h.wrap(h.scroller.prototype, 'addevents', function (proceed) { proceed.apply(this, array.prototype.slice.call(arguments, 1)); }); h.wrap(h.scroller.prototype, 'drawhandle', function (proceed) { proceed.apply(this, array.prototype.slice.call(arguments, 1)); h.each(this.handles, function

c - Why sciencific notation for "(double)123456" with "%.4g" conversion is "1.235e+05" instead of 1.234e+05 -

for me, seems normal 1.234e+05 when using conversion, because when revert '"%f\n", 1.235e+05' 123500.000000 instead of wished "123400.000000". actually question is: why skipped "4" digit ?! following example reinforces wanted say: #include <stdio.h> int main(int argc, char **argv) { char x[100]; sprintf(x, "%.4g", (double)123456); printf(">%s<\n", x); printf("%f\n", 1.235e+05); return 0; } thanks, valentin printf limited precision not truncate; rounds per current rounding mode. default mode round-to-nearest. since 123456 closer 123500 123400, former value printed.

How can I modify the class for a button in a django widget form? -

Image
i'm trying set class form widget. have: <form action="{% url "list" %}" method="post" enctype="multipart/form-data"> {% csrf_token %} <p>{{ form.non_field_errors }}</p> <p>{{ form.input.label_tag }} {{ form.input.help_text }}</p> <p> {{ form.input.errors }} {{ form.input }} </p> <p>{{ form.non_field_errors }}</p> <p>{{ form.itinerary.label_tag }} {{ form.itinerary.help_text }}</p> <p> {{ form.itinerary.errors }} {{ form.itinerary }} </p> <p><input class="button-primary" type="submit" value="upload" /></p> </form> and looks i attempted use django tweak tools when tried googling find solution problem. modified code see how change: <form action="{% url "list" %

javascript - variable scope in module asynchronous function -

this first week in node i'm sorry if no brainier. the code works , should. can't figure out how match name (url) starts http.get whit result gets website. i found witch problem, except premade function can't edit function , add callback. variable scope in asynchronous function if run code synchronous or make callback in http.get function good. don't have skills , don't know if can it. thanks - robin. http = require('http'); function download(name) { //name array whit csgo items names. (var = 0; < name.length; i++) { var markethashname = getgoodname(name[i]); var url = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=' + markethashname; http.get(url, function (res) { var data = ""; res.on('data', function (chunk) { data += chunk; }); res.on("end", function () { data = json.parse(data);

sql - Sqlite update with min if smaller than existing -

must misunderstand basic here, have couple tables: table1 (id, minvalue) table2 (table1id, value) if run query: update table1 set minvalue = (select min(value) table2 table1.id == table2.table1id); i expected values. if run query minvalues remain null: update table1 set minvalue = min(minvalue, (select min(value) table2 table1.id == table2.table1id)); i updating minvalue multiple tables want make sure stays smaller incoming values still gets updated when minvalue still null. if want ensure minvalue never gets updated higher current value need add condition apply update rows there exists lower incoming value: update table1 set minvalue = ( select min(value) table2 table1.id = table2.table1id ) exists ( select value table2 table1.id = table2.table1id , table2.value < table1.minvalue )

playframework 2.0 - Akka actor externalizing deployment configuration -

i instantiating actor in play 2.1.5 application using lazy val ref = akka.system.actorof(props[backgroundprocessoractor], name = "background-processor") i have properties file specifies following configuration application { akka { actor { default-dispatcher = { fork-join-executor { parallelism-factor = 1.0 } } background-dispatcher = { fork-join-executor { parallelism-factor = 1.0 } } deployment = { /background-processor = { dispatcher = background-dispatcher router = round-robin nr-of-instances = 128 } /solr_asset_updater = { dispatcher = default-dispatcher } /solr_asset_log_updater = { dispatcher = default-dispatcher } /change_queue_processor = { dispatcher = default-dispatcher } } } } } i spent time reading docs , source code play. depl

android - Re-apply layout_centerHorizontal programmatically -

i have custom relative layout view, have dynamically change background resource. problem is, after setting background, layout_centerhorizontal property of children removed , items no longer horizontally centered. trying figure out how re-apply it. here layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/marker_background" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:background="@drawable/ic_markerdefault" > <imageview android:id="@+id/marker_category" android:layout_width="20dp" android:layout_height="20dp" tools:src="@drawable/ic_bike" android:layout_centerhorizontal="true" /> <textview android:id="@+id/marker_price" andro

javascript - Make a page load at the bottom and move assets up on scroll down -

this class project. making 1 page site space kids. idea have page load @ bottom , scroll rocket blasts off etc. can't find solution getting load @ bottom without specifying anchor in url. you use javascript scroll bottom of page when window loads. window.addeventlistener('load',function() { window.scrollto(0,document.body.scrollheight); }, false); in html document: <!doctype html> <meta charset='utf-8'> <title>page title</title> <script type='text/javascript'> window.addeventlistener('load',function() { window.scrollto(0,document.body.scrollheight); }, false); </script> <!-- rest of document -->

How to choose ODE timespan for Matlab when solving for a set of linear differential equations? -

the set of differential equations in form x'=ax+b a,b, , x matrices. attempted solve problem using ode45 function in matlab. having difficulty choosing timespan ode45 arguments, since problem did not specify. note: have tried time=[0,10]; ended big matrix factor multiplied it. code written: %myode45function.m file function dx_dt = myode45function (t,x) b=[1 2 3 4 5 6 7]'; a=[2 3 4 5 6 0 7; 3 6 2 1 3 5 4; 4 2 2 4 2 7 5; 5 1 4 3 5 2 1; 6 3 2 5 4 1 2; 0 5 7 2 1 8 0; 7 4 5 1 2 0 9]; dx_dt= [(a*x)+b]; end %main code clear all; clc time=[0,4]; initial=[1,1,1,1,1,1,1]; [t,x]=ode45(@myode45function, time, initial);

c# - Bulk insert not working as expected -

i have 2 tables in 2 different server. called 1 local , 1 remote table. reasons, want bulk insert remote table , use local data source. in phpmyadmin, have checked both totalrows. table | rows ----------------------- local | 1111 remote | 0 i expect remote table have same rows local table. it's not working expected. after did bulk insert, returns : table | rows ----------------------- local | 1111 remote | 64 i don't know why happens. did same way tables 2 different server , works i'm expected. maybe have idea ? so used same code bulk insert in 2 different remote servers , works perfectly? are using load data infile? or running multiple insert queries? if you're using load data infile, wanna make sure path file correct.

javascript - Can't get cookies to send with request in Express 4 -

Image
here's initial config: var session = require('express-session'); var cookieparser = require('cookie-parser'); app.use(session({ saveuninitialized: true, resave: false, genid: function(req) { return services.misc.generateuuid() }, secret: secret.tostring() })); app.use(cookieparser(secret)); then in controller (it's routed through dead simple router controller, renders appropriate actions based on rails-like naming convention) i'll this: var testcontroller = { noaction: function(req, res) { var locals = { billy: 'the goat' } console.log('req session'.red, req.session); res.cookie('test_cookie', 'wu tang clan'); this.services.render.view(req, res, this, 200, locals); } module.exports = testcontroller; note this.services.render.view service don't have write res.render('./app/controllers' + controller + '/' + action) note res.cookie line i

python - Given a String, What is the Length of the One of the Longest WFF in Polish Notation? -

i'm trying to write version of popular count-a-wff section of wff 'n proof game (no copyright infringement intended) in python. alright, not popular. i think have , running desired case of 4 letter string. def maximum_string(s): if cs(s) == true: return len(s) elif len(s) == 2: l1 = [cs(s[0]), cs(s[1])] if true in l1: return len(s) - 1 else: return 0 elif len(s) == 3: first = s[0] + s[1] second = s[0] + s[2] third = s[1] + s[2] l1 = [cs(first), cs(second), cs(third)] if true in l1: return len(s) - 1 l2 = [cs(s[0]), cs(s[1]), cs(s[2])] if true in l2: return len(s) - 2 else: return 0 elif len(s) == 4: first = s[0]+s[1]+s[2] second = s[0]+s[1]+s[3] third = s[1]+s[2]+s[3] fourth = s[0]+s[2]+s[3] l1 = [cs(first), cs(second), cs(third), cs(fourth)] if true in l1: return 3 first = s[0] + s[1] second = s[0] + s[2] third = s[0] + s[3] fourth =

Slicing PHP Array Into Table -

not sure if "slice" right word.. have following array stored in variable. array ( [0] => design|1-cylinder 4-stroke engine, water-cooled [1] => displacement|373.2 cm³ [2] => bore|89 mm [3] => stroke|60 mm [4] => performance|32 kw (43 hp) [5] => starting aid|electric starter [6] => transmission|6 speed, claw shifted [7] => engine lubrication|wet sump ) 1 note "|"'s separating content. content should in table this. <table> <thead> <tr> <td>title</td> <td>details</td> </tr> </thead> <tbody> <tr> <td>engine displacement</td> <td>373.2 cm³</td> </tr> <tr> <td>transmission</td> <td>6 speed, claw shifted</td> </tr> </tbody> </table> how can write foreach sta

c - Scanf does not read user input as expected -

the program not taking inputs should. when input t = 1 , l = 4 inner loop takes 2 inputs instead of four. int main() { int l, b, g, count, t, i; char s[10000]; scanf("%d%d", &t, &l); while (t--) { (i = 0; < l; i++) { scanf("%c", s[i]); if (i > 0) if (s[i] == s[i-1]) count++; } printf("%d\n", count); } getch(); } the problem when enter character scanf , press enter key. input(if valid) consumed scanf , newline character(since pressed enter key) stays in standard input stream( stdin ). when scanf (with %c ) called next time, sees \n character in stdin , consumes it, , not wait further input. to fix it, change scanf("%c",s[i]); to scanf(" %c",&s[i]); the space before %c instructs scanf scan number of whitespace characters including none, until first non-whitespace character. quoting standard: 7.21.6.2 fscanf function [.

jquery - Remove an item from the server with JSON -

this question has answer here: adding/removing items json data jquery 6 answers i appreciate here. json knowledge limited, , can't solve it. i need delete item shopping cart quick view create via json. front end seems work, doesn't because doesn't remove item json object. the json object looks like. [ { "id": 216687, "productid": 9604505, "catalogid": 306758, "name": "xxxxxxxxx1", "description": "", "quantity": 1, "totalprice": "38,00", "smallimage": "/images/products/large/xxxxx.jpg", }, { "id": 216687, "productid": 9604503, "catalogid": 306756, "name": "xxxxxxxxx1",

android - Which is the best Cross-Platform Framework for mobile app development? -

hi wanna start develop cross platform application mobile app (mostly tablets/ipad). 1 best in below start : appcelerator phonegap xamarin mosync each framework has own con's & pro's. choosing framework purely based on selection criteria : availability across different platforms development speed ui performance

c# - About publish an application in Local IIS -

i'm going publish application in local iis .but have question before publish. question if host application can access application system in local area network? can run application out opening visual studio , run through visual studio? iis : internet information services yes if deploy application,for sure can access within network. yes, if deployed there no need open visual studio run application , deployed already

linux - what happen in this script? -

#!/bin/sh yes_or_no(){ echo "is name $* ?" while true echo -n "yes or no" read x case "$x" in y | yes ) return 1;; n | no ) return 0;; * ) echo "answer yes or no" esac done } if yes_or_no "$1" echo "hi $1,nice name i" else echo "never mind" fi exit 0 output--> ./fuction1.sh salman khan name salman ? yes or non hi salman,nice name why opposite output cam if press no output never mind because fuction return 0. totally confuse here can any-buddy me solve this? in shell things not in other languages. "0" code of success: $ true $ echo $? 0 $ if true ; echo "true"; fi true from above can see 0 means "0 errors", while other "0" indicate error code. shell logic geared towards rather c-like 0 == false , 1 == true

android - How to add press effect or selector indicator to astuetz/PagerSlidingTabStrip? -

Image
i used astuetz library , implemented pagerslidingtabstrip android application, it's working find. want change pressing effect, tried: android:background="@drawable/tab_selecor" code tab selector: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/darkgreen" android:state_focused="true" android:state_pressed="true" /> <item android:drawable="@color/darkgreen" android:state_focused="false" android:state_pressed="true" /> <item android:drawable="@color/green" /> </selector> the press colour suppose changed dark green see not change, still looks if use colour red, yellow, .... . make use of setindicatorcolor() setting color of indicator , setindicatorheight() setting height and make use of settabbackground() method

MySQL stored procedure behaving unpredictably -

writing stored procedure parse names in format 'last first mid' , 'last first mid suffix' table. create procedure parse_full_name(full_name text) begin set @last_name = substring_index(full_name, ' ', 1); set @middle_name = substring_index(full_name, ' ', -1); set @first_name = substr(full_name, locate(' ', full_name), length(full_name) - length(@middle_name) - length(@last_name)); set @query = concat('select ''', @last_name,''' last_name, ''', @first_name,''' first_name, ''', @middle_name,''' middle_name;'); prepare stmt @query; execute stmt; deallocate prepare stmt; end; call parse_full_name('last first middle'); >>> last_name | first_name | middle_name >>> -----------|------------|------------- >>> last | first | middle call parse_full_name('last first middle suffix

html - Div being pushed down by invisible force -

Image
i trying have thumbnail grid. each thumbnail can have either 1 of 2 different height, want whole row have same height as can seen, because last 2 thumbnails higher, rest get's pushed down. when inspect google devtools, no padding or margin has been added, they're being forced down somehow css: .video { display: inline-block; width: 220px; height: 250px; margin: 0 0 15px 15px; h4 { margin-top: 5px; } .thumbnail { padding: 0px; border: none; background: none; // box-shadow: 5px 5px 15px -6px; .caption { word-break: break-all; } } } html: <div class="row"> <div class="col-xs-12"> <div class="videolist"> <div class="video"> <div class="item"> <div class="thumbnail"> <img src="https://i.ytimg.com/s_vi/yxqdrjjiqjy/hqdefault.jpg?sqp=cnjotkgf&amp;rs=aon4cl

algorithm - Minimum number of characters to be inserted at the end of a string to make it a palindrome -

the question this-- we have find minimum number of characters inserted at end of string make palindrome. so, in efforts problem, figured equivalent finding largest palindromic substring suffix of string. i in o(n^2) looking o(n) solution possible using modified kmp. please me figure out. i have approach uses hashing posted answer here . you can indeed use kmp. can compute prefix function reversed string, , iterate initial string left right: kmp computes function prefix[i] = longest prefix of string suffix of string[1..i] however, want know the longest suffix of our string prefix of reversed string . why? if have: 15232 => reverse = 23251 then longest suffix of string prefix of reversed string 232 . palindrome, , lets find you're asking because suffix of string overlaps prefix of reversed string if 2 palindromes. you have cases: prefix[i] = length - => can palindrome of length 2*prefix[i] centered @ , i+1 prefix[i] = length - +

unix - Traceroute on Host with Path? -

when run traceroute against domain name hit cloudflare cache. avoid this, i'm trying run traceroute against path on domain know isn't cached, this: > traceroute domain.com/some/path traceroute: unknown host domain.com/some/path is there way traceroute against path work?

c++ - Painfully slow function calling -

i stumbled on interesting while working in visual studio c++. calling function made set pixels screen through nested loop, x , y screen coordinates. discovered if did operations in main() function program run @ 250 frames per second, yet if moved outside function , called frame rate dropped 30 frames per second. i did investigating test program, , replicated happened in program. below illustration of did.... if run following program.... void main() { (int = 0; < 1e9; i++) // loop billion times { 1+1; // } } it runs in 1.6 seconds. however, if run following code, same thing except calling outside function.... void oneplusone() { 1+1; } void main() { (int = 0; < 1e9; i++) // loop billion times { oneplusone(); // call function instead } } it takes 18 second execute. now, can avoid calling function , have code need in main(), makes messy , unreadable. please tell i'm doing wrong or i've got visual studio sett

sql - Setting an identity column based on a field changed value -

i have table used identity primary key (t_head_id), key became long way upsets client, changed normal column select max + 1 , added new identity column ( id ) , 1 computed ( id_per_year ) id_per_year=id+'-' year(opeartion_date) the prob want reset id not @ beginning of year when client starts inserting new values of operation_date , since new year can started client still inserting records of passed year how can reset identity based on changing value of operation_date? you define column of type int (or smallint, tinyint, bigint ) identity attribute: create table dbo.yourtable( id int identity(1,1) ...... with setup, sql server automatically generate consecutive id's table when rows being inserted table. with type int , starting @ 1, over 2 billion possible rows - should more sufficient vast majority of cases. bigint , 922 quadrillion (922 15 zeros - 9'220'000 billions) - enough you?? if use int identity starting @ 1, , insert row every

C# - Constantly adding 9 digits -

as title says, i'm developing in c#. i'd generate number has more 9 numbers, thought generating numbers, follow 9. instance, if want generate number has 10 digits - i'd generate first number has 9 numbers, , number has 1 digit. if generate number 20, i'd generate first 2 numbers 9 digits each, , number 2 digits. i've tried: for (int = 0, j = (int.parse(inputrandom.text) % 9 == 0 ? int.parse(inputrandom.text) % 9 : int.parse(inputrandom.text) % 9 + 1); < j; i++) if (i < (int.parse(inputrandom.text) % 9 == 0 ? j % 9 : j % 9 + 1) - 1) numtosend += (biginteger)r.next(int.parse(1 + zero((int.parse(inputrandom.text) % 9 + 8) * (inputrandom.text.length - 1)))); else numtosend += (biginteger)r.next(int.parse(1 + zero(int.parse(inputrandom.text) % 9 * 9))); the method 0 returns string 0, times number specified in. i.e zero(1) return: "0" need method because method next(int32) can return number, specified between brackets

c++ - How to call a function with a parameter typed high-dimensional array by passing a pointer? -

for example, have function (need c99) void fun(int nx, int ny, double a[nx][ny]) { // code here } and have pointer double *p = new double[nx * ny]; and use call function like fun(nx, ny, p); // error type not matched how it? type conversion allowed. what want not possible in c++ because c++ requires sizes of array types compile time constants. c99 not have limitation, function declaration void fun(int nx, int ny, double a[nx][ny]); is valid c99, not valid c++. btw, in c99, correct call of function this: int nx = ..., ny = ...; double (*matrix)[ny] = malloc(nx*sizeof(*matrix)); fun(nx, ny, matrix); now, have 2 possibilities: use c multidimensional array stuff. use c++ workaround this. the easiest c++ workaround vector<vector<double> > . avoid hassle of allocating memory yourself, however, rows in 2d matrix not consecutive. you can use 2 layer indirection this: double **matrix = new double*[nx]; for(int = 0; < ny; i++) ma

apache - Remove trailing .html rewriterule creates 404 error -

i have modified .htaccess remove trailing .html pages. htaccess looks this: rewriteengine on rewritebase / rewritecond %{http://www.mydomain.co.uk} !(\.[^./]+)$ rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule (.*) /$1.html [l] rewritecond %{the_request} ^[a-z]{3,9}\ /([^.]+)\.html\ http rewriterule ^([^.]+)\.html$ http://www.mydomain.co.uk/$1 [r=301,l] i added following @ top of .htaccess set custom 404 page , stop indexing: errordocument 404 /notfound.html options -indexes the rewrite rule works perfectly. anti-indexing. 404 page gives me error: internal server error server encountered internal error or misconfiguration , unable complete request. please contact server administrator, webmaster@mydomain.co.uk , inform them of time error occurred, , might have done may have caused error. more information error may available in server error log. additionally, 500 internal server error error encountered while trying use errordocu

ios - Use multiple contains functions in if statement (Swift) -

is there way use multiple "contains(array, value)" functions in if statement? have query stores in results in array. if results nil perform set of operations. if, however, array not nil i'd check see if objects appear in it: var user: pfuser? override func viewdidload() { super.viewdidload() //get 2 players if let user = user{ var userquery = pfquery(classname: "game") userquery.wherekey("user1", equalto: user) userquery.wherekey("isactive", equalto: true) var userquery2 = pfquery(classname: "game") userquery2.wherekey("user2", equalto: user) userquery2.wherekey("isactive", equalto: true) var currentuserquery = pfquery(classname: "game") currentuserquery.wherekey("user1", equalto: pfuser.currentuser()) currentuserquery.wherekey("isactive",

TDD Implementing Step Definitions derived from Behave (Python) -

where put behave's implementation code not fail behave's tests? further need import or put code in code write linked feature file. here excerpt feature file \steps\main.feature ... feature: main program program allows users create create , view development logs scenario: user requests development logs particular user given user has requested development logs given user development logs user show and here implementation suggestions (that come running behave): @given(u'user has requested development logs given user') def step_impl(context): raise notimplementederror(u'step: given user has requested development logs given user') @then(u'the development logs user show') def step_impl(context): raise notimplementederror(u'step: development logs user show') i realise basic information nothing in documentation covers , although there lots of tutorial on google none of them cover this. assume basic. the answ