Posts

Showing posts from February, 2012

video streaming - How to capture and broadcast MJPEG stream from an IP webcam -

i've purchased foscam fi8910w ip webcam outputs live video stream in mjpeg format, , i'm trying embed live stream in webpage. i've accomplished goal using camera feed's url source html img tag. problem each browser session accessing page connects camera, limited bandwidth camera has used up, no more 2 or 3 users can view page @ same time. what set sort of streaming server access camera's feed directly, , reproduce/process in way when users browse site pulling server rather camera. ideally done without need browser plugins, , work across browser. i'm pretty experienced in several programming languages, writing handle not totally out of question, don't have slightest idea how started. i recommend 2 options (both work me): 1) c/c++ code + libjpeg library(use version above 8 since older ones exchange result through file system). this nice article used understand mjpeg , create c/c++ application works. pros: have full control on features

android - How to tell Gradle to use a different AndroidManifest from the command line? -

i have multi-module project. root of project (which contains multiple modules), want able call 'gradle build' , have use different androidmanifest in 1 of modules depending on parameter pass in. what's best way accomplish this? should use gradle.properties file or can specify different build.gradle somehow in settings.gradle file? appreciated! settings.gradle: include 'actionbarsherlock' include '<main_app>' build.gradle: buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4.2' } } apply plugin: 'android' dependencies { compile project(':actionbarsherlock') } android { buildtoolsversion "17.0" compilesdkversion 17 sourcesets { main { manifest.srcfile 'androidmanifest.xml' java.srcdirs = ['src'] resources.srcdirs = ['src'] a

java - My ArrayList only contains the last item on my array -

this question has answer here: why arraylist contain n copies of last item added list? 3 answers public static void main(string args[]){ new converter(); //the converter() method reads csv file pass array of string // called stringlist; in stringlist static variable; arraylist<student> list = new arraylist<student>(5); string p[] = null; student stud = null; for(int z = 0; z < stringlist.length; z++){ p = stringlist[z].split(","); id = integer.parseint(p[0]); yr = integer.parseint(p[5]); fname = p[1]; gname = p[2]; mname = p[3].charat(0); course = p[4]; stud = new student(id,yr,fname,gname,mname,course); studs = stud; i tried display current values of variables above , compare them student object system.out.println(id +&qu

php - update if not inserted in yii -

i want update values in table, if values not inserted. here code- function save_data($date, $game, $score) { $criteria = new cdbcriteria; $criteria->addcondition("date = '{$date}'"); $data = array("date" => $date, "game" => $game, "score" => $score); $game_report = new gamereport(); $game_report->attributes = $data; $game_report->save(); } but keeps on inserting duplicate values though have provided date condition. why? how update , not insert duplicate values? in order make update, need on loaded database model. in case, can done as: function save_data($date, $game, $score) { $criteria = new cdbcriteria; $criteria->addcondition("date = '{$date}'"); $data = array( "date" => $date, "game" => $game, "score" => $score ); $game_report = gamereport::model()->f

forms - IE 9, 8 and 7 jquery custom light box does not appear -

i created custom light box appear 2 buttons, user must click 1 , submit form. here code function lightboxrefferal(){ //$('body').append('<div class="lightbox" id="lightboxbg"></div>'); $('#lightboxbg').height($('body').height()); $('.lightbox').show(); $('#lightboxcontent').show(); $('#lightboxcontent').css("position", "absolute"); $('#lightboxcontent').css("top", math.max(0, (($(window).height() - $('#lightboxcontent').outerheight()) / 2) + $(window).scrolltop()) + "px"); $('#lightboxcontent').css("left", math.max(0, (($(window).width() - $('#lightboxcontent').outerwidth()) / 4) + $(window).scrollleft()) + "px"); $('#referral_dropdown').change(function(){

if statement - batch file to check existance of directory if not exists then use alternate directory for file copy -

i trying write batch file copies exe file network location local location. works depending on windows version (xp or win7) user has select correct .bat file due different local paths needed copy. (they going startup folder ran every time user starts machine). first time i've ever worked writing batch files , lost when looking @ syntax if statements. if figuring out great. here have works xp: rem @echo off echo starting movefiles set exitrc=0 set exitmsg=exitrc initialized echo %exitrc% -- %exitms copy "\\networkdrive\install\individual\program\movefiles.exe" "c:\documents , settings\all users\start menu\programs\startup\" echo copied files pc set exitrc=%errorlevel% if not %exitrc% == 0 goto :exit set exitmsg=processing complete :exit echo step: %exitmsg% rc: %exitrc% echo finishing movefiles pause exit %exitrc% here have windows 7: @echo off echo starting movefiles

c++ - Why do auto and template type deduction differ for braced initializers? -

i understand that, given braced initializer, auto deduce type of std::initializer_list , while template type deduction fail: auto var = { 1, 2, 3 }; // type deduced std::initializer_list<int> template<class t> void f(t parameter); f({ 1, 2, 3 }); // doesn't compile; type deduction fails i know specified in c++11 standard: 14.8.2.5/5 bullet 5: [it's non-deduced context if program has] function parameter associated argument initializer list (8.5.4) parameter not have std::initializer_list or reference possibly cv-qualified std::initializer_list type. [ example: template void g(t); g({1,2,3}); // error: no argument deduced t — end example ] what don't know or understand why difference in type deduction behavior exists. specification in c++14 cd same in c++11, presumably standardization committee doesn't view c++11 behavior defect. does know why auto deduces type braced initializer, templates not permitted

postgresql - Specifying psqlODBC parameters in VB.NET -

just began using postgresql vb application (using visual studio 2005 pro) , connect via odbc (there's reason using odbc connection , not native postgresql connector) . i'm used using @something , cmd.parameters.add("@something", data) format mssql. have 9 values want form , use them in insert statement can't seem figure syntax postgresql out. ideas? i've searched 2 days trying find answer btw. edit: sorry, deleted code trying, kept getting "the column not exist" error on column "name" first paramater. i know it's not connection error or naming convention issue or because following code work. here's how i'm doing testing: strsql = "insert tableb (name, extension, length,creationtime,lastaccesstime,lastwritetime,directoryname) values ('name','extension','length','creationtime','lastaccesstime','lastwritetime','directoryname')" objconn.connectio

php - How do I write on a file without clean it? -

how write on file without clean file using fwrite function? write skiping line using fwrite in text file. $fp = fopen('somefile.txt', 'w'); fwrite($fp, "some text"); fwrite($fp,"more texto in line"); fclose($fp); set open mode "append" instead of "write" (see documentation fopen ): $fp = fopen('somefile.txt', 'a'); if on windows, may want consider using t flag denote file opening text file, proper line-ending character being used ( \r\n instead of \n windows): $fp = fopen('somefile.txt', 'at'); now, add text onto new lines, make sure use php_eol newline character character ensure right newline characters being written right oss: fwrite($fp, php_eol . 'some text'); fwrite($fp, php_eol . 'more text on line');

CSS SubMenu Does Not Appear: Probably z-index issue -

trying figure out how display submenu when mouse on over parent page. http://bit.ly/11duqt5 if check website ie7 compatibility mode see submenus when hover on pages on main navigation menu. not available on ff, ie10 , google chrome @ all. could please check z-index values , me fix issue? add css ul.webstun-hmenu li:hover ul {visibility: visible;}

ruby - Mechanize script keeps stopping with `fetch': 503 => Net::HTTPServiceUnavailable -

i trying run local ruby script using mechanize logs me onto website , goes through 1500 of webpages , parses information each of them. parsing works, length of time; script runs 45 seconds or so, , stops , reports: /users/myname/.rvm/gems/ruby-1.9.3-p374/gems/mechanize-2.7.1/lib/mechanize/http/agent.rb:306:in `fetch': 503 => net::httpserviceunavailable http://example.com/page;53 -- unhandled response (mechanize::responsecodeerror) i can't tell sure, feel due connection timeout. tried resolving in script long timeout (this script take 15 minutes run), still doesn't change anything. let me know if have ideas. this script: require 'mechanize' require 'open-uri' require 'rubygems' agent = mechanize.new agent.open_timeout = 1000 agent.read_timeout = 1000 agent.max_history = 1 page = agent.get('examplesite.com') myform = page.form_with(:action => '/maint') myuserid_field = myform.field_with(:id => "usernam

Rails migration error - Name can't be blank -

i using rails 2.x version. using mysql 5.0 database end process. faced migration error when did following steps. get application code github. run schema:create, load , seed process after add data in application. again pull code same branch. after run db:migrate throws following error -> rake db:migrate --trace deprecation warning: rake tasks in vendor/plugins/acts_as_audited/tasks, vendor/plugins/annotate_models/tasks, vendor/plugins/app_version/tasks, vendor/plugins/bullet/tasks, vendor/plugins/importer/tasks, vendor/plugins/mimetype-fu/tasks, vendor/plugins/railsdav/tasks, vendor/plugins/rav/tasks, vendor/plugins/simple_captcha/tasks, vendor/plugins/smart_table/tasks, vendor/plugins/test_data_generator/tasks, vendor/plugins/visualize_models/tasks, , vendor/plugins/xss_terminate/tasks deprecated. use lib/tasks instead. (called /usr/lib/ruby/gems/1.8/gems/rails-2.3.12/lib/tasks/rails.rb:10) ** invoke db:migrate (first_time) ** invoke environm

c# - TabStop and Focus on a GroupBox -

Image
i have created custom control extends groupbox. control supports collapsing , expanding , use groupboxrenderer , buttonrenderer make typical groupbox has button in corner. have handled appropriate mouse events make "button" behave , regular button. have hit problem groupbox not receive focus using tabstop. there anyway can collapsable groupbox receive focus tabstop? i hoping use trick how set focus control after validation in .net set focus in enter event haven't come way of determining when should focus. devise way of finding siblings next highest , lowest tabindex (or childindex if same tabindex) , determine if lost focus seems bit hacky , high chance of breaking if don't right. note: did create user control not wanted various reasons including: it not control contains button , groupbox (it happens sort of way), groupbox flexibility coupling between backend code , ui dynamic layout shared across many projects require toolbox support , customising ui

actionbarsherlock - Android action bar tabs: screen rotation -

hi i'm having problems action bar , tabs using abs. have 2 tabs, first one, "favourites", extends fragment , not show anything. second one, "lines", extends sherlocklistfragment , implements loadermanager.loadercallbacks (loads user list database). the app works ok (or @ least, think so), problem appears when rotate screen. if in portrait mode linestab selected (the list displayed) , change landscape, content of favouritestab (initially empty) filled content of linestab. this important part of code. main.java (create both tabs) public class main extends sherlockfragmentactivity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); actionbar actionbar = getsupportactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); actionbar.setdisplayshowtitleenabled(true); tab tab = actionbar .newtab() .settext("favourites") .settab

javascript - ReferenceError: variable is not defined -

i met issue still don't know causes it. i have script in page: $(function(){ var value = "10"; }); but browser says "referenceerror: value not defined". if go browser console , input either 10 or var value = "10"; either of them can return 10. problem script? edit:just rid of "var" can solve problem. it's declared inside closure, means can accessed there. if want variable accessible globally, can remove var : $(function(){ value = "10"; }); value; // "10" this equivalent writing window.value = "10"; .

jquery - jScrollPane won't reinitialise -

i've somehow struggled jscrollpane everytime i've used in past, managed make work in end. time i'm stumped , hoping can enlighten me. i have animated items on page, after executing load external data div (#content). believe i've initialised , re-initialise correctly after animation completes nothing. else fires correctly except jscrollpane. here's css: #content { margin-top: 30px; position: absolute; left: 120px; right: 20px; max-width: 900px !important; height:300px; overflow: auto; z-index: 99; } and here's js: g_index = -1; $(function() { //jscrollpane settings var settings = { // showarrows: true }; var pane = $('#content') pane.jscrollpane(settings); var api = pane.data('jsp'); $('#nav > .circle').mouseenter( function () { var index = $(".circle").index(this); var $this = $(this); if(index != g_index) { g_index = index; $('.circle a').removeclass('engtext');

c# - callback url is not working in twitter for localhost -

i using twitter login asp.net.callback url not worked local host.i have tried every solution found on google.but still same problem. is possible use callback url localhost? if want use localhost u need use 127.0.0.1 instead of localhost. for example http://127.0.0.1:youportnumber

android - Closing alert dialog using menu -

i have alert dialog items. need close dialog when user clicks menu button without giving options close. how can that? here code charsequence[] cs = ques_cat.toarray(new charsequence[ques_cat.size()]); finalcharsequence[]css=ques_catidtoarray(newcharsequence[ques_catid.size()]); alertdialog.builder builder = new alertdialog.builder(gropinion_questions.this); builder.settitle("choose category"); builder.setitems(cs, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int item) { string ss = css[item].tostring(); getsubcat(ss); } }); alertdialog alert = builder.create(); alert.show(); public boolean oncreateoptionsmenu(menu menu) { menuinflater menuinflater=getmenuinflater(); menuinflater.inflate(r.menu.activity_main, menu); if(alert !=null && alert.isshowing()) alert.dismiss(); return true; } on host activity's, want check if user has gone menu , dismiss dialog there:

How to get the month names in kendo chart by using function -

how create function month jan,feb.. displayed in kendo chart x axis. var internetusers = [ { "month": "1", "year": "2010", "value": 1 }, { "month": "2", "year": "2010", "value": 2 }, { "month": "3", "year": "2010", "value": 3 }, { "month": "4", "year": "2010", "value": 4 }, { "month": "5",

java - Calculate the subtotal while every time adding a new row in JTable -

Image
how calculate subtotal while every time adding new row in jtable ? defaulttablemodel model = (defaulttablemodel) jtable1.getmodel(); int = 0; double total123 = 0.0; int row = model.getrowcount(); payment pm = new payment(); double sub_total123; //calculate sub_total;;; sub_total123 = double.parsedouble(unit_price.gettext()) * integer.parseint(order_quantity.gettext()); pm.setsub_total(sub_total123); sub_total.settext(double.tostring(pm.getsub_total())); if (row < 10) { model.addrow(new object[]{product_id.gettext(), product_name.gettext(), integer.parseint(order_quantity.gettext()), double.parsedouble(unit_price.gettext()), double.parsedouble(sub_total.gettext())}); } (i = 0; < row; i++) { total123 += ((double) jtable1.getvalueat(i, 4)).doublevalue(); total.settext(double.tostring(total123)); } i new jtable . while adding 1st row, wont sub total value , display in text field. when adding second row sub total value , insert text field , w

java - How to Access JDialog information from parent JFrame? -

** have updated question per , comments received. question is: after calling following code: searchbox searchbox = new searchbox(); // searchbox extends jdialog int state = searchbox.showsearchdialog(); // sets visible true , returns state i want let user enter input in searchbox (jdialog). "halt" jframe class when searchbox.showsearchdialog() called (shouldn't already?? not after setvisible(true) called). , once user presses ok in jdialog (searchbox class) "resume" jframe class , call string query = searchbox.getquery(); . i thought sine setvisible(true) called searchbox.showsearchdialog() method should halt not. code runs through from: seachbox = new searchbox(); int state = seachbox.showseachdialog(); string query = searchbox.getquery(); without stopping. query string coming wrong because user never had chance input before code calls method. jframe class: import java.awt.cursor; @suppresswarnings("serial") public class datap

android - position of two textview and a imageview in linearlayout -

Image
i preparing custom listview . want achieve this i quite confused, how put imageview along textview in linearlayout . so, question how put imageview along textview in linearlayout , in image. tried this, still couldn't able implement 2 textview imageview. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#003f84" android:textcolor="#ffffff" android:text="textview" /> <view android:layout_width="fill_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/> &l

ios - how to add the UITableView detailDisclosurebutton custom in ipad app -

i have tableview detaildisclosure button works fine want give title detail disclosure button think need add custom uibutton detaildisclosure possible want without using custom cell. if want give image works fine how may give title button comment. cell.accessoryview = [[ uiimageview alloc ] initwithimage:[uiimage imagenamed:@"loginn.png" ]]; try this.. uibutton *btn = [[[uibutton alloc]init]autoerelease]; btn .frame = cgrectmake(210.0, 0.0, 90, 25); btn = [uibutton buttonwithtype:uibuttontypecustom]; [btn setimage:[uiimage imagenamed:@"loginn.png"] forstate:uicontrolstatenormal]; [btn addtarget:self action:@selector(btnclickhandler:) forcontrolevents:uicontroleventtouchupinside]; [cell.contentview addsubview: btn]; and in btnclickhandler indexpath - (void)btnclickhandler :(uibutton *)button { uitableviewcell *cell = (uitableviewcell *)button.superview.superview; nsindexpath *indexpath = [tableview indexpathforce

nine patch - How to set image as background for all Android devices so that stretching does not distort it? -

Image
reference image attached. how set such image background? using 9-patch makes possible? yes, please use 9-patch image , please check this on how draw 9-patch image , video tutorial

c++ - Using boost::stream for more complex/structuered types then chars? -

is possible use boost::iostreams more complex / structured types? what want stream images should have annotations width, height, color depth,... first idea use struct instead of char or wchar namespace io = boost::iostreams; struct singleimagestream{ unsigned int width; unsigned int height; unsigned char colordepth; unsigned char* frame; }; class singleimagesource { public: typedef struct singleimagestream char_type; typedef io::source_tag category; std::streamsize read(struct singleimagestream* s, std::streamsize n) { char* frame = new char[640*480]; std::fill( frame, frame + sizeof( frame ), 0 ); s->width = 640; s->height = 480; std::copy(frame, frame + sizeof(frame), s->frame); return -1; } }; class singleimagesink { public: typedef struct singleimagestream char_type; typedef io::sink_tag category; std::streamsize write(con

html - Change in button css very slow in iOS/Android devices for Phonegap app -

i have designed custom button using jquery mobile , css phonegap mobile app. on clicking button toggles on/off states , css class changed. toggle/change slow on iphone/ipad/android devices. there delay in button rendering toggled css. pretty fast on desktop browsers. all doing in code : $("input[id='someid']").closest('div').removeclass("buttonup ").addclass("buttondown"); $("input[id='someid']").closest('div').removeclass("buttondown").addclass("buttonup"); css: .buttondown { border:1px solid #000;font-weight:bold; cursor:pointer; text-shadow:0 1px 1px #000; text-decoration:none; background:#8fffdd;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#8fffdd), color-stop(100%,#72ccb1));background-image:-moz-linear-gradient(top, #72ccb1 0%, #8fffdd 100%);background-image:-webkit-linear-gradient(top, #8fffdd 0%,#72ccb1 100%);backgr