Posts

Showing posts from June, 2010

unable to import function in django/python -

i writing django project follwing files: ttam_container -utils.py -ttam -views.py codes within utils.py module: def random_string(): ... def remove_blanks(): ... ...other functions... codes within views.py : from utils import * def get_sequences(request): ... string = random_string() ... sequences = remove_blanks(sequences_with_blanks) ... the error global name remove_blanks' not defined reported. thought didn't import utils.py correcty in first place, random_string works... any idea what's happening? the import should be: from utils import remove_blanks without .py

asp.net - VS 2012 Publish: Can't find the valid AspnetMergePath -

i installed update 2 visual studio 2012, introduces new publish dialog. i'm trying make used (precompile website before publishing), , i'm running error "can't find valid aspnetmergepath" which thrown file microsoft.web.publishing.aspnetcompilemerge.targets. i've confirmed file aspnet_merge.exe exists in multiple places on computer, but $(getaspnetmergepath) is evaluating empty string reason. must missing configuration setting, i've never messed before, i'm confused why start suddenly. can offer advice on how resolve this? i've done standard google searching on error , nothing has led me right solution. i hit same problem. searched through microsoft related sites, found lot of complaints , no intention microsoft fix it. here how worked around @ system. edit microsoft.web.publishing.aspnetconfigurationmerge.targets file , add following line. please make sure microsoft sdk path same on pc, if not change it: <targetfram

jQuery datatable column width on edit mode -

i using jquery datatable inline editing functionalities. able define custom widths table, however, enter edit mode, column width expands , table keeps jumping , forth. seems view 'swidth' works fine, , desired column width, user presses double click enter edit mode, column size expands , squeezes other columns. lingering issue within actual js code or doing wrong? here script: $(document).ready(function(){ otable = $("#datatables").datatable({ "aocolumns" : [ { "sname" : "fullname", "swidth" : "15%" }, { "sname" : "location", "sclass": "aligncenter" },

php - How to check if file exist in zip archive -

i have zip archive , after extract him need check if moduleconfig.xml exist inside zip archive. how can that. i try this $zip = new ziparchive(); if($zip->open('test.zip') === true ) { if(file_exists($zip->getfromname('moduleconfig.xml'))) { echo "config exists"; // somthing } } else { echo 'failed code:'. $res; } it should this: $zip = new ziparchive(); if($zip->open('test.zip') === true ) { if ($zip->locatename('moduleconfig.xml') !== false) { echo "config exists"; } } else { echo 'failed code:'. $res; }

java - Is it possible to keep a Dialog open after clicking the Neutral Button? -

this question has answer here: how prevent dialog closing when button clicked 16 answers i have dialog 3 edittexts use ftp address, username, , password. used .setneutralbutton create button "test connection". got working connect ftp , show toast result don't want test button close dialog. how can keep dialog open during connection test? livepreviewchk.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { linearlayout lila1 = new linearlayout(newsite.this); lila1.setorientation(1); // 1 vertical orientation final edittext servername = new edittext(newsite.this); servername.sethint("server name"); final edittext serveraddress = new edittext(newsite.this); serveraddress.sethint("server address"); final edittext username = new edittext(news

javascript - making ajax request in meteor helpers -

how can wait until ajax request finishes when returning data meteor helpers method. for example, template.item.helpers({ itemname:function () { var user = meteor.user(); $.when(reallylongajaxrequest()).done(function (a1) { //tried using jquery when return "item name should have because waited"; }); return " doesnt wait @ all"; } }); i have reallylongajaxrequest() running , finish before continuing on itemname helper. log statement console shows undefined that's because ajax request hasn't finished. tried using jquery when no luck. ideas edit: i should mention inside helper function reason. need item 'id' being rendered can run ajax request paramater. using reactive sessions perfect don't know of way rendering items outside of helpers method definition? an unnamed collection 1 null passed name. in-memory data structure, n

asp.net mvc - change default behavior of unobtrusive jquery validation to validate on onkeyup? -

i'm using micrososofts unobtrusive jquery validation mvc4 / razor , default behavior appears to first validate on click of submit, , after validate onkeyup. i'd change starts validating onblur, , after first submit continues validate on keyup normal. is there way can change start validating on blur forms? this default behaviour when using jquery validate directly or via microsoft unobtrusive validation. if enter non valid entry field, field validated on blur before field submitted. if focus , blur field without entering field validated on submitting form. from documentation page section "a few things when playing around demo" before field marked invalid, validation lazy [but] if user enters in non-marked field, , tabs/clicks away (blur field), validated i have forked fiddle in comment demonstrate using unobtrusive plugin , rendered html. http://jsfiddle.net/8wks2/ "links jsfiddle.net must accompanied code." here rendered m

delphi - GetLocaleFormatSettings for LOCALE_INVARIANT returns the users settings under Windows XP German -

all numbers write files exchange purpose use following code: getlocaleformatsettings(locale_invariant, fsinvariant); floattostrf(value, fsinvariant); when read in number use this getlocaleformatsettings(locale_invariant, fsinvariant); if trystrtofloat(value, floatval, fsinvariant) result := floatval that works under windows 7, incl. german version, fails in german version of windows xp. the problem seems in getlocaleformatsettings procedure since gives me same values under locale_invariant , locale_default_user. here code shows issue: unit umain; interface uses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, grids, valedit; type tform1 = class(tform) vleditor: tvaluelisteditor; procedure formshow(sender: tobject); private { private declarations } public { public declarations } end; var form1: tform1; implementation {$r *.dfm} procedure tform1.formshow(sender: tobject); var fsinvariant : tform

capybara - Poltergeist Rspec If-None-Match If-Modified-Since headers -

i have feature spec makes 2 visit requests same url. expected behavior second request should return 304. not happening however. have set phantomjs_options: ['--disk-cache=true'] not seem have desired effect. there other setting needs configured use if-none-match , if-modified-since headers? an example below: visit "/p/:id" page.driver.status_code.should eq 200 visit "/p/:id" page.driver.status_code.should eq 304 thanks, i not sure this. i'd suggest testing using phantomjs see if can replicate issue there - if file bug against phantomjs.

python - Unable to provide user input in PyDev console on Eclipse with Jython -

i trying debug jython program long time running in eclipse using pydev plugin, worked once ran terminal instead. suspected might user input wasn't working on eclipse console, tried running basic input program jython think of name = raw_input("what name? ") print "hello %s" % (name) when runs outputs what name? and when type in console, normal green text appears, upon hitting enter, nothing happens. how can console feed input process? edit: input fed program upon pressing terminate, outputs hello name also, happening when using pydev, input works fine when running java code in java perspective this strange (and works me). so, identify what's happening, need more info: what's jython version you're using? do have in error log? what's eclipse version? how doing run? (hint: pressing f9 should enough)

mysql - Using Distinct in a subquery -

how display fields of row based on 1 field distinct (i.e there should no duplicates field) suppose there's table called office_roles fields , data below name department designation john marketing executive john sales executive john pr executive so want end result display fields in row 1 john (distinct) output - john marketing(or sales) (or pr) executive i thinking of like select * office_roles name =(select distinct name office_roles); how correctly ? want order , limit number of results per page on end result... you can't have variable number of columns query. 1 thing can concatenate values together: select name, group_concat(department) departments, group_concat(designation) designations office_roles o group name

sql server - Run existing .sql file from Excel -

i have .sql file contains select statement. there way directly import/run query in excel? can edit "command text" in "connection properties" of existing database connection, requires copying , pasting .sql code. browsing , selecting file want helpful. i using sql server 2008 r2 , excel 2010. i read variable first, can use in query. use this: strpath = "p:\...sql" open strpath binary #1 mydata = space$(lof(1)) #1, , mydata close #1 now have query in mydata variable. may need reformat remove line returns before try run it.

Correctly passing a path from zsh (cygwin) to vim on windows -

i have following alias/function in .zshrc open gvim file names arguments. vim() { if [[ $# -ge 1 ]]; gvim "$*"; else gvim; fi } it opens files in ~ fine, when try pass path, doesn't work. example, zsh vim ~/dir/test1.txt (a file exists on c:\users\myname\dir\test1.txt ) , gvim opens following file \c\users\myname\dir\test1.txt [new directory] doesn't exist? how can fix issue? cygpath might here, this: gvim `cygpath -w $*`

ios - UICollectionViewCells not appearing in a UICollectionView -

as title suggests have uicollectionview hooked uiviewcontroller through ib. have uicollectionview subclass called imagecell . in viewcontroller viewdidload method, register class this: cgrect collectionviewrect = cgrectmake(384, 60, 728, 924); uicollectionviewflowlayout *flow = [[uicollectionviewflowlayout alloc] init]; imagecollectionview = [[uicollectionview alloc] initwithframe:collectionviewrect collectionviewlayout:flow]; [imagecollectionview registerclass:[imagecell class] forcellwithreuseidentifier:@"cell"]; imagecollectionview.delegate = self; imagecollectionview.datasource = self; i call method called getphotos in viewdidappear (for ui reasons) gets photos service , call [imagccollectionview reloaddata]; inside getphotos . then in cellforitematindexpath following: imagecell *cell = [collectionview dequeuereusablecellwithreuseidentifier:@"cell" forindexpath:indexpath]; grkalbum *album = [albums objectatindex:indexpath.item]; cell.titlelab

Assigning variable in powershell and passing to commands -

i'm trying leverage get-mailboxfolderstatistics commandlet obtain item counts inbox folders list of users within distribution list. i've used get-distributiongroupmember commandlet filtering "name" , assigned variable. here need , perhaps there simpler method, want pass each of user names "identity" parameter of get-mailboxfolderstats command script each of users in given distribution group provide me folder stats desire. thank reading , help. so far have: $s = get-distributiongroupmember -identity 23rdfloor | select name piping result foreach command should work; $s = get-distributiongroupmember -identity 23rdfloor | select name $s | foreach-object {get-mailboxfolderstatistics -identity $_.name } http://www.mikepfeiffer.net/2010/02/exchange-management-shell-error-pipelines-cannot-be-executed-concurrently/

ruby - Why do method arguments not work for assignment? -

in ruby, many languages, method's arguments not automatically assigned instance variables. this works: def initialize(a) @a = end this doesn't: def initialize(@a) end in coffeescript, example, works: constructor: (@name) -> there lot of other syntactic sugar in ruby, such ||= operator, unary & on symbols, etc. there reason, technical or otherwise, why sugar isn't part of design? edit the scope of question not limited initialize . in coffeescript can do class foo baz: (@bar) -> the reason matz decided way, @ least now. there's open feature request quite few supporters trying convince matz. note should consider inheriting struct.new(:name, ...) define default constructor setting corresponding instance variables, accessors, == , eql? , hash , etc...

Attributes Python Adding a Set value -

for essay class need attribute stores grade should public , betweem 0.0 , 4.0. thinking set_grade(self,grade) how implement if statement make sure return number 0.0 between 4.0 class assessment: grade = 0 def get_grade(self): return self.grade """this operation creating concrete subclass of assessment""" class essay (assessment): """this operation getting grade grade essay class return grade""" def get_grade(self): return self.grade """this operation creating teamproject class individual score , team score grade""" class teamproject(assessment): ind_sc = 0 ts_sc = 0 """this operation getting grade individual score , team score , returning average""" def get_grade(self): return (self.ind_sc +self.ts_sc) / 2 how implement if statement make sure

Extract and Use System Output (Batch) -

i write batch file allows quicker assembling of multiple assembly files using a86 assembler , view result. there 2 cases, when there assembly error , when there no error. sample assembler input: a86 file1.asm file2.asm file3.asm file4.asm case 1: error. supposing there error in file3.asm, system output on line 4: error messages inserted file3.asm case 2: no error. system output on line 4: object: file1.bin in case 1, open file generated error using notepad++, using command notepad++ filename.asm . in case 2, open generated object in hex editor using command hxd filename.bin . what can done extract error/success file name system output? sorry, i'm not familiar a86 , have idea or two. if a86 returns 0 on success, non-zero on fail, way: @echo off setlocal enabledelayedexpansion if defined programfiles(x86) (set "pf=%programfiles(x86)%") else set "pf=%programfiles%" :: path notepad++ set "npp=%pf%\notepad++\notepad++.exe&q

java - Riemann Integrator Sum Issue -

here code riemann integrator: public class riemannintegrator { public static void main (string [] args) { double lower = double.parsedouble(args[args.length -2]); double higher = double.parsedouble(args[args.length -1]); double[] coefficients = new double[args.length - 3]; if (args[0].equals("poly")) { (int = 1; < args.length - 2; i++) { coefficients[i-1] = double.parsedouble(args[i]); } system.out.println(integral("poly", coefficients, lower, higher)); } } private static double integral(string s, double[] function, double lowbound, double highbound) { double area = 0; // area of rectangle double sumofarea = 0; // sum of area of rectangles double width = highbound - lowbound; if (s.equals("poly")) { (int = 1; <= ((highbound - lowbound) / width)

c++ - Constructing a boost::posix_time::time_duration from microseconds -

one can total number of microseconds time_duration via total_microseconds method, can't figure out how re-construct time_duration number. there seems no constructors such purpose in documentation, missing something? there boost::posix_time::microseconds : #include <iostream> #include <boost/date_time.hpp> namespace bpt = boost::posix_time; int main() { bpt::time_duration td = bpt::microseconds(12345678); std::cout << td << '\n'; }

php - How to calculate date time in one field -

i have table below named transaction_detail id_transd | id_trans | id_cust | inputtime | 1 | 1 | 1 | 2013-04-15 16:55:58 | 2 | 1 | 1 | 2013-05-15 16:55:58 | 3 | 1 | 1 | 2013-06-15 16:55:58 | 4 | 2 | 2 | 2013-06-15 16:55:58 | i want amount of inputtime (type : datetime) have same id_cust. i've done date, don't know how calculate time. sql syntax calculate date : select (date(max(inputtime)) - date (min(inputtime))) total transaction_detail id_cust = '$idp' any appreciated. before. have in website might need. http://www.sqlusa.com/bestpractices/datetimeconversion/

asp.net mvc - loading data by scrolling using javascript -

i displaying data on page , when click on load more data button load more data on same page below data displayed. want convert feature more data loaded user scrolls down page rather clicking on load more data . here have , have attempted. html view <section id="rosterimages"> <section id="users"> <div id="nameimage"> <figure id="content" class="thumbnail"> <img width="158" height="158" alt="gravatar" data-bind="attr:{src: gravatarurl}"/> <figcaption> <a title="email" id="emailicon" class="icon-envelope icon-white" data-bind="attr:{'href':'mailto:' + email()}"></a> </figcaption> </figure> </div> </section> </section> javascript sc

javascript - Does Jquery Trigger and Bind do that same as Publisher and Subscriber? -

i have implement simple publisher , subscriber using javascript. came across jquery trigger , bind. trigger , bind same publisher , subscriber.... yes, in way. event handling trigger() , bind() use publish/subscribe pattern. these functions work jquery objects only, not javascript objects.

string - Comparing dates in Java -

i read date functions cant think best way solve problem. i have couple of dates database string , want compare may current date. using compareto , there problem using function guess because of comparing strings. this function: public int datecompare(string today, string date2){ return today.compareto(date2); } and when use in sample dates: datecompare("04/19/2013","04/18/2013"); it returns 1, , when change value of first parameter "04/20/2013" still returns 1. please help... java has date object. should using instead. import java.util.calendar; import java.util.date; public class comparedates { public static void main(string[] args) { // create calendar, default today calendar cal = calendar.getinstance(); // subtract 1 day cal.add(calendar.date, -1); // compare result (1) system.out.println(datecompare(new date(), cal.gettime())); // add 2 days cal.a

classification - Python how to train the naives bayes classier -

i need classifier classify reviews positive or negative. each doc had done stopwords filtering , lemmatation , computed tf-idf each term , stored them doc_bow follow each doc. doc_bow.append((term,tfidf)). now, wan train classifier, have no idea how do. found example http://streamhacker.com/2010/10/25/training-binary-text-classifiers-nltk-trainer/ , still can't it. how td-idf used or affect classifier? i know little in area, can share understand. please correct me if wrong. see link, there no reference using tf-idf scores classification. should @ link understand how use naive bayes classifier. in general, code looks (i took code segment link) import nltk.classify.util nltk.classify import naivebayesclassifier nltk.corpus import movie_reviews def word_feats(words): return dict([(word, true) word in words]) negids = movie_reviews.fileids('neg') posids = movie_reviews.fileids('pos') negfeats = [(word_feats(movie_reviews.words(fileids=[f])), &

python - Django form_valid is not working -

i new django . can me code. trying calculate duration between 2 datefield save. class employeecreate(createview): model = employee form_class = employeecreateform success_url = "/employee-list/" def form_valid(self, form): self.object.total_leave = (self.object.to_date - self.object.from_date).days +1 self.object.save() return httpresponseredirect(self.get_success_url()) there couple of issues you should use form.instance instead of self.object call super method so update code as: def form_valid(self, form): self.instance.total_leave = (self.instance.to_date - self.instance.from_date).days +1 self.instance.save() return super(employeecreate, self).form_valid(form) refer docs form handling class-based views

emulation - javascript library which emulates Windows' WScript object? -

i'm looking emulation, in javascript, of wscript object. i've started creating such object , defining methods , properties work wscript object. goal wrap functionality need , take in different direction. the reason doing avoid wholesale changes large body of jscript scripts. i'd prefer globally swap "wscript" (e.g.) "mywscript" , leave ".echo" , ".stdout.write" etc things handled new object's same-named handlers. what haven't looked @ extending wscript object itself. rather reinvent wheel, there wscript clone/workalike/emulation out there somewhere? later wscript object doesn't seem able extended. not string, example. a couple of days later hey, i'd take jscript.net implementation if there one!

c++ - Error 12006 in WinHttpCrackUrl -

i'm trying build address variable. can pass winhttpopenrequest . char *unameaddr = (char*) exebaseaddress + 0x34f01c; printf("%s \n", unameaddr); string url = "http://xxxx.xxxx.com/xxxx/?u="; string username = unameaddr; string combine = url + username; cout << combine << endl; //http://xxxx.xxxx.com/xxxx/?u=myusername <-- url_components urlcomp; lpcwstr pwszurl1 = (lpcwstr)combine.c_str(); dword dwurllen = 0; then have pass here: hrequest = winhttpopenrequest( hconnect, l"get", urlcomp.lpszurlpath, null, winhttp_no_referer, winhttp_default_accept_types, 0); urlcomp.lpszurlpath should http://xxxx.xxxx.com/xxxx/?u=myusername any advice? application crashes when gets process part. error 12006 error_internet_unrecognized_scheme url scheme not recognized or not supp

c++ - Threading In Classes -

i creating asynchronous class logs strings file. should creating thread within class itself? thinking start function void async_log::start (void) { std::thread thread_log( [&]() { std::ofstream fout; fout.open(filename); while(true) { if(q.size()) { std::lock_guard<std::mutex> lock(m); fout << q.front() << "\t @ time: " << std::clock() << std::endl; q.pop(); } } fout.close(); }); } or better leave threading main. first concern if threading unique (so if instantiate class 2 times 2 different files thread_log on written or have conflict). there nothing wrong have dedicated thread in class, want note several things: inside thread implement busy waiting log messages. redundant , expensive! thread consumes cpu when there no messages in queue. need blocking queue there, block on pop() method. can find implementation of bl

Watir-webdriver with firefox -

i'm working on web-application automation using ruby , ruby's framework watir-webdriver firefox v20.0.1, when use file_field function file, gives following errors: element not visible , may not interacted (selenium::webdriver::error::elementnotvisibleerror) before, running same code firefox profile 'default' time working fine, , changed firefox profile 'new' , getting these errors. not able set firefox profile 'default' on v20.0.1. whether correct way or not, please me! have tried gem update webdriver from command line ensure have latest webdriver code?

php - SetCookie not working in WordPress -

i cannot cookie set through wordpress theme. putting following code on top of header.php page theme: <?php error_reporting(e_all); ini_set("display_errors", 0); if(!$_get['c_id']) { $locationcookie = $_cookie['aboutlocations']; if($locationcookie) { $state = $locationcookie['state']; $city = $locationcookie['city']; } } else { $state = $_get['c_id']; $city = $_get['cid']; } setcookie("aboutlocations[state]", $state,time()+3600*24*100, cookiepath, cookie_domain ); setcookie("aboutlocations[city]", time()+3600*24*100, cookiepath, cookie_domain); ?>

javascript - issue in if condition for page navigation -

$( 'li' ).on( 'click', function( event ) { console.log("inside music player"); var projindex = $(this).index(); selectedmedia=$(this).text(); console.log("------"+projindex); console.log("------"+selectedmedia); var extension = selectedmedia.substr( (selectedmedia.lastindexof('.') +1) ); console.log("extension-----"+extension); if(extension=="mp3" || extension=="wav") { var musiclink="#musicplay_page"; var selectedlink = document.getelementbyid('medialink'); selectedlink.href=musiclink; $('#musicplay_page').add(playmusiclist(selectedmedia)); } else if(extension=="mp4") { var videolink="#videoplay_page&

Unable to parse bindings in Knockout.js -

facing common "binding issue". below viewmodel function detaillistviewmodel() { this.details = new details(); this.productdetails = ko.observablearray([]); this.show = function (item) { $.getjson("products.json", {}, function (data) { this.productdetails.push(this.details.init(data)); }); }; } function details() { this.author = ko.observable(); this.text = ko.observable(); this.init = function (temp) { return { author: temp.author, text: temp.text }; }; } var tasklistviewmodel = { tasks: ko.observablearray([]), addtask: function () { self.tasks.push(new task({ bomid: this.bomid() }, { createdby: this.createdby() })); }, showproductinfo: function (item) { detaillistviewmodel.show(item); } }; $(function () { $.getjson("tasks.json", function (alldata) {

php : action on form's not working- beginner -

i'm beginner php, have small problem doing action when submitting form the form that <form name="form1" method="post" action="?flag=1"> <input type="submit" name="button" id="button" value="submit"> </form> and php code - on same page- <?php if ($flag) {echo "helllllllllo";} ?> and didn't work, tried make action on other page action="otherpage.php?flag=1" but didn't work pls :) ? $_get variables - variables see in query string $_post variables - variables send form if method="post" if need check if flag exists do: if(isset($_get['flag'])){ without isset can undefined index notice

perl - Change symbolic links -

i need change symbolic links in given directory use shortest relative path. example: change kat/../kat/link or usr/sth/sth/kat/link into kat/link how can using perl? you can simplified path using abs_path , removing current directory make relative: use warnings; use strict; use cwd qw/getcwd abs_path/; $silly_path = 'foo/../foo/../foo/../foo'; $simplified = abs_path($silly_path); $cwd = getcwd(); print "canonical path: $simplified\n"; print "current directory: $cwd\n"; $simplified =~ s|^\q$cwd/||; #make relative if within current directory. print "simplified path: $simplified\n"; this assumes links in perl's current working directory. replace directory if want. result in relative path link within current directory, or simplified absolute path points outside current directory. you can files in directory using glob , use -l $file file test operator test if $file symbolic link.

excel - VBA prevent user changing cell value with reference to only the initial cell value -

Image
i'm trying stop fields being changed user. don't know columns fields in, value contain. my current approach this: private sub workbook_sheetchange(byval sh object, byval target range) dim columnheaderrange range set shtdata = worksheets("data") set columnheaderrange = union(shtdata.columns(columnnumber(5, "example1")), _ shtdata.columns(columnnumber(5, "example2")), _ shtdata.columns(columnnumber(5, "example3"))) set columnheaderrange = application.intersect(target, columnheaderrange) elseif not (columnheaderrange nothing) application .enableevents = false .undo msgbox "change not possible.", 16 .enableevents = true end else exit sub end if my columnnumber function in above code takes row , field value parameters , returns column number. since i'm using fixed field values though, fail

Painting on a QGraphicsScene without loosing the picture already on it. Qt C++ -

so question says, have qgraphicsview on ui. have made function puts image onto qgraphicsview: // read new image file qimage image(":/images/myfile.png"); /// declare pointer scene qgraphicsscene *scene = new qgraphicsscene(); // add pixmap scene qimage 'image' scene->addpixmap(qpixmap::fromimage(image)); // set scene equal height , width of map image scene->setscenerect(0,0,image.width(),image.height()); // set scene graphicsview on ui ui->graphicsview->setscene(scene); however want able paint dots @ specific x y values on image. have function quite nicely function called dots appear , picture vanishes :(. know because im setting scene again 1 dots on program gets rid of 1 thats using (the image one) for(unsigned int = 0; < pixels.size(); i++) { x = pix_iter->second; y = pix_iter->first; scene->addellipse(x, y, 1, 1, pen, qbrush(qt::solidpattern)); pix_iter++; } ui->graphicsview

java - Print argument from Console -

i'm tring run argument ubuntu console. ./mytool -h and print of "1". someone can please ? thanks ! public static void main(string[] argv) throws exception { system.out.println("1"); for(int i=0;i<argv.length;i++) { if (argv.equals("-h")) { system.out.println("-ip target ip address\n"); system.out.println("-t time interval between each scan in milliseconds\n"); system.out.println("-p protocol type [udp/tcp/icmp]\n"); system.out.println("-type scan type [full,stealth,fin,ack]\n"); system.out.println("-b bannergrabber status\n"); } } argv entire array. trying match, entire content of array string -h . try doing this: public static void main(string[] argv) throws exception { system.out.println("1"); for(int i=0;i<argv.length;i++) {

Python Serial: How to use the read or readline function to read more than 1 character at a time -

i'm having trouble read more 1 character using program, cant seem figure out went wrong program, i'm new python. import serial ser = serial.serial( port='com5',\ baudrate=9600,\ parity=serial.parity_none,\ stopbits=serial.stopbits_one,\ bytesize=serial.eightbits,\ timeout=0) print("connected to: " + ser.portstr) count=1 while true: line in ser.read(): print(str(count) + str(': ') + chr(line) ) count = count+1 ser.close() here results get connected to: com5 1: 1 2: 2 3: 4 4: 3 5: 1 actually expecting this connected to: com5 1:12431 2:12431 something above mentioned able read multiple characters @ same time not 1 one. i see couple of issues. first: ser.read() going return 1 byte @ time. if specify count ser.read(5) it read 5 bytes (less if timeout occurrs before 5 bytes arrive.) if know input terminated eol characters, better way use ser.readline() that contin

android - automatically stop recording in AudioRecord class -

i found code storing audio in .wav format link .the code has 2 buttons start , stop recording.i want stop audio recording after sometime.it uses audiorecord class of android store audio.is possible so? 04-19 08:20:00.688: e/androidruntime(2405): fatal exception: main 04-19 08:20:00.688: e/androidruntime(2405): java.lang.runtimeexception: unable start activity componentinfo{com.example.androidwaverecorder/com.example.androidwaverecorder.mainactivity}: java.lang.nullpointerexception 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.access$600(activitythread.java:141) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 04-19 08:20:00.688: e

base - How can I quickly compress a short hex string and decompress it in c# -

i have 16 character hex strings this: b5a43bc5bdceefc6 2c7c27f05a488897 1514f4ec47c2ebf6 d91ed66bc999eb64 i want shorten them , have shortened string contain upper case letters. deflatestream , gzipstream increase length. anyone can me shorten these 16 characters hex string 6 characters or fewer? alternatively, shortening 32 character hex string 12 characters or fewer okay. you can convert hexadecimal number higher base sexagesimal: quickest way convert base 10 number base in .net?

c# - Getting data from a deeply nested json object -

i'm stuck on problem 2 days, how can data out of nested json object. i have found online json tools http://www.jsoneditoronline.org/ http://jsonformat.com/ when paste json it, shows objects arrays etc, can dig down data , information want. when debug code , put break point on: foreach (jtoken data in rates.toarray()) can see data i'm after, cannot data out, depends on try depends on error get, last error was. error converting value "@ratechange" type 'web.ui.controllers.homecontroller+rateinfo'. could not cast or convert system.string web.ui.controllers.homecontroller+rateinfo. any appreciated. my class public class rateinfo { public string ratechange { get; set; } public string promo { get; set; } public string pricebreakdown { get; set; } public bool nonrefundable { get; set; } public string ratetype { get; set; } public int currentallotment { get