Posts

Showing posts from August, 2012

php - CodeIgniter form validation rule won't run if string is empty -

i have custom rule, regex[table_name.column_name.post_value] , using in following manner: $this->form_validation->set_rules( 'postal_code', 'postal code', 'regex[countries.postal_code_regex.country_code]' ); and here custom rule's function in my_form_validation.php : public function regex($str, $field){ list($table, $col, $post_val)=explode('.', $field); // grab regex $regex = $this->ci ->db ->limit(1) ->select($col) ->where($post_val, $_post[$post_val]) ->get($table) ->row($col); return preg_match('/'.$regex.'/', $str) === 1; } how codeigniter run rule if user sends empty string? note: cannot use required rule depends on whether database has regex or not. try below code: public function regex($str, $field){ list($table, $col, $post_val

php - Doctrine collection is null upon object initialization [In some cases only] -

this problem: create object, collection object. objects, in controllers, collections return empty collectionarray object, returns null. reading in so, better initialize manytomany relationships in entities constructor, case? documented? this example of problem: $p = new person(); $p->getrelatives(); // null, should empty collectionarray. in mean time, in controller class... $w = new woman(); w->getmen(); // returns empty collectionarray class -.- hope guys can point me in right direction, don't want go through entities , create constructor them because of this! besides, whats annoying non deterministic behavior in collections returned. and that's reason, why documentation says, all collections should initialized : <?php use doctrine\common\collections\arraycollection; /** @entity */ class user { /** @manytomany(targetentity="group") */ private $groups; public function __construct() { $this->groups =

Openshift Perl script can't connect to MYSQL -

embarrassed have ask of openshift guys, perl won't connect mysql, though php fine. following code works fine on client (i added openshift env variables on local machine) fails on openshift app: my $db_name = 'campaignmotor'; $db_host = $env{'openshift_mysql_db_host'}; $db_port = $env{'openshift_mysql_db_port'}; $db_pw = $env{'openshift_mysql_db_password'}; $db_user = $env{'openshift_mysql_db_username'}; sub db_connect { $dsn = "dbi:mysql:database=$db_name;host=$db_host;port=$db_port"; $dbh = dbi->connect($dsn, $db_user, $db_pw); return $dbh; } i unending messages like: error 2002 (hy000): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2) following php config on web app works fine: $db['default']['hostname'] = getenv('openshift_mysql_db_host') . ':' . getenv('openshift_mysql_db_port'); $db['

html - How do you assign onclick within for loop in javascript? -

function initnav(){ var cbox=document.getelementsbyclassname('box'); for(var i=0;i<cbox.length;i++){ cbox[i].innerhtml=cbox[i].id; <!--so far have set captions after setting ids same how want them appear.--> <!--what comes next doesn't work.--> getelementbyid(cbox[i].id).onclick=mclick(cbox[i].id); } }; function mclick(id){alert(id);} the whole thing in js file, , promptly linked html file. as planned, buttons should appear , clickable, happening instead 1 of them visible , 1 not working when click on it. when create lot of div-oriented buttons, wish run loop , able assign each of them clickable instead of writing lines many are. how assign onclick within loop in javascript? you're calling function instead of assigning it. getelementbyid(cbox[i].id).onclick = mclick; of course, function receive event argument instead of id. (passing id inside loop huge pain; easiest fix not bother trying.) gets at

excel vba code to replace empty cell with text based on adjacent cells number range -

please me, i'm frustrated excel. because i'm not it. i've been tasked following. take blank cells in column c, reference value in adjacent cell in column b, , print statement in cell. i tried function no avail. =if(and(c3 = "", 0 < b3 < 5000), "order more", "don't order") i got circular error. thought must need use vba. here snippets of code have far: worksheets("sheet1").activate each rw in sheet1.rows if rw.columns("c") = "" , range.rw.columns("b") i'm not sure how make work. don't know if that's correct. i've been trying use internet it's more confusing. posting response since it cumbersome explain on comment it tested , works excel 2010. sub test() dim lfirstblank long, llastrow long dim rrange range llastrow = cells(rows.count, 3).end(xlup).row lfirstblank = _ range("c3:c" & llastrow).specialcells(xlcelltypeblanks).cells(1,

android - Logcat: "Skipped 33 frames" -

today while running app saw message in logcat "skipped 33 frames.the application may doing work in main thread". second part doesn't concern me application strucking when message displayed.but @ same time said "skipped 33 frames".. mean screen view comes frame frame in case of video.!!! the message getting system log. happens 2 reasons(as know). when application doing work on main/ui thread. prevent should time consuming works database query , network operations in separate thread , post result main thread. if system running on slow(low ram/ slow processor). emulator prime example of problem. note custom rom's cynogen , chinese android mobiles tend throw error. post whole lot of logcat nexus.

c# - Permission based security model -

in windows forms payroll application employing mvp pattern (for small scale client) i'm planing user permission handling follows (permission based) implementation should less complicated , straight forward. note : system simultaneously used few users (maximum 3) , database @ server side. this usermodel . each user has list of permissions given them. class user { string userid { get; set; } string name { get; set; } string nic {get;set;} string designation { get; set; } string password { get; set; } list <string> permissionlist = new list<string>(); bool status { get; set; } datetime entereddate { get; set; } } when user log in system keep current user in memory. for example in bankaccountdetailentering view, can control permission access command button follows. public partial class bankaccountdetailentering : form { bool accounteditable {get; set;} public bankaccountdetailentering () {

sql - Oracle - copying stored procedures to remote database -

an assignment have part of pl/sql studies requires me create remote database connection , copy down tables local, , copy other objects reference data, views , triggers etc. the idea @ remote end, views etc should reference local tables provided local database online, , if not, should reference tables stored on remote database. so i've created connection, , script creates tables @ remote end. i've made pl/sql block create views , triggers @ remote end, whereby simple select query run against local database check if online, if online series of execute immediate statements creates views etc reference table_name@local, , if isn't online block skips exception section, similar series of execute immediate statements creates same views referencing remote tables. ok become unsure. have package contains few procedures , function, , i'm not sure what's best way create @ remote end behaves in similar way in terms of picks reference tables from. is case of enclosin

TCP in C Programming -

i want know how client or server gets acknowledgement packet client or server after sending packet in tcp channel in c programming. why don't need handle in code? how client receive acknowledgement packet, if sends data packet server? happen internally? the tcp protocol designed provide stream protocol. typical programming interface socket interface can give chunk of data protocol stack transfer receiver. actual implementation hides when data has been queued in receiving protocol stack or has been handed off receiving application. have make distinction. sou apparently want signal mechanism know, , when client has read data protocol stack. can done designing , implementing protocol on top of tcp protocol. when 1 side doesn't have send meaningful data sends heartbeat message. message indicates tcp connection still alive. regarding questions: why don't need handle in code? because underlying layer has done your. how client receive acknowledgement packet

javascript - Jquery fadeIn in callback for fadeOut not lasting -

hope can shed light on issue me.... i'm using setinterval alternate displaying headlines on webpage. fades out previous one, in callback function fades in new one. used work fine, separated callback function fadeout because wanted run without delay, , i'm getting initial headline, when comes time change, fade in split second , disappear again. function processsidebar(data) { var headlines = $.parsejson(data); var sindex = 0; function newsidebar(surl, sindex) { $(".sidebar").html(headlines[sindex].date + '<br><a href="' + surl + '">' + headlines[sindex].line + '</a>'); $(".sidebar").fadein(400); } newsidebar("getme.php?blog=1&headline=1", sindex); setinterval(function() { ++sindex; if (sindex == headlines.length) {sindex = 0} var

pandas - Running get_dummies on several DataFrame columns? -

how can 1 idiomatically run function get_dummies , expects single column , returns several, on multiple dataframe columns? since pandas version 0.15.0, pd.get_dummies can handle dataframe directly (before that, handle single series, , see below workaround): in [1]: df = dataframe({'a': ['a', 'b', 'a'], 'b': ['c', 'c', 'b'], ...: 'c': [1, 2, 3]}) in [2]: df out[2]: b c 0 c 1 1 b c 2 2 b 3 in [3]: pd.get_dummies(df) out[3]: c a_a a_b b_b b_c 0 1 1 0 0 1 1 2 0 1 0 1 2 3 1 0 1 0 workaround pandas < 0.15.0 you can each column seperate , concat results: in [111]: df out[111]: b 0 x 1 y 2 b z 3 b x 4 c x 5 y 6 b y 7 c z in [112]: pd.concat([pd.get_dummies(df[col]) col in df], axis=1, keys=df.columns) out[112]: b b c x y z 0 1 0 0 1 0 0 1 1 0 0 0 1 0 2 0 1

c# - Left align text but right align button inside of a panel using Bootstrap and ASP.NET -

i writing first web application using twitter bootstrap , asp.net c# on back-end. have buttons , labels inside of bootstrap panel. align labels left , buttons right. here code far: <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">overview</h3> </div> <div class="panel body"> <p> <asp:label id="bandsproducedlabel" runat="server" text="bands produced:"></asp:label> <asp:button class="btn btn-default" id="bandsproducedbtn" runat="server" text="hello" style="text-align:right" /> </p> <\div> <\div> how can accomplish task? small snippet

asynchronous - Find notification source(/post id) using facebook graph api -

i using facebook graph api query of user's notifications - far good. want query post caused notification. in this documentation on facebook says response.data[i].object object whole post be, unfortunately don't .object @ all. function getting notifications: getusernotifications: function () { var deferred = $q.defer(); fb.api( "/me/notifications", {since:'last week','limit': limit}, function (response) { deferred.resolve(response); } ); return deferred.promise; }, and here permissions use: fb.init({ appid: id, status: true, // check login status cookie: true, // enable cookies allow server access session xfbml: true, // parse xfbml read_stream: true, manage_notifications: true, user_groups: true }); of course, every permission later injected in login scope: fb.login(function(response){}, {scope: &#

oop - C++ nonmember accessing member functions -

i'm working different team on project. other team constructing gui, which, gui frameworks inheritance driven. on other hand, code on side ('bottom end', guess 1 say) c (though believe it's technically c++ via msvc2010 toolchain w/o "treat c" flag. both modules (ui , this) must compiled separately , linked together. problem: need has popped bottom end call redraw function on gui side data given it. here things go bad. how can call set of member functions, 1 w/ complex dependencies? if try include window header, there's inheritance list gui stuff mile long, bottom end isn't build against complex gui libs...i can't forward declare way out because need call function on window? now major communication design flaw, though we're in bad position right major restructuring isn't option. questions: how should have been organized bottom end contact top redraw, going ball of c code ball of c++ node. what can circumvent issue? the

jquery - Selecting elements following a selected element -

Image
i creating custom accordion menu using jquery. what want accomplish this: if ul within ul (for example line 39 in image) set display... want change of ul tagged elements following, within specified div, no display having no luck .next() or .nextall() code example <div id="wrapper"> <ul class="a-menu"> <li> main menu 1 <ul> <li>sub 1 menu 1</li> <li>sub 1 menu 2</li> </ul> </li> <li> main menu 2 <ul> <li> sub 2 menu 1 <ul> <li>sub 3 menu 1</li> <li>sub 3 menu 2</li> <li>sub 3 menu 3</li> </ul> </li> <li> sub 3 menu 2 <ul> <li> sub 3 menu 1&

Search with multi field in asp.net mvc and sql server -

please me problem below: i have 1 table in sql server field: product, customer, year, quantity,... , have search form 3 textbox: txtprod, txtcust, txtyear , search button i want result: if of 3 textboxs null or empty: show of record if 1 of 3 textbox empty, searching 2 others conditions if 2 of 3 textbox empty, searching condition. please me how write select in sql server or linq in asp.net mvc thanks much! assume value of txtprod, txtcust , txtyear filled prod, cust, , year variables in controller, , table map entity name entity var items = entity in modelcontext.entity select entity; if (!string.isnullorempty(prod) && !string.isnullorwhitespace(prod)) { items = items.where(item => item.product == prod); } if (!string.isnullorempty(cust) && !string.isnullorwhitespace(cust)) { items = items.where(item => item.customer == cust); } if (!string.isnullorempty(year ) && !string.isnullorwhitespace(year )) {

c# - Select random file from folder -

my folder contain more 100 zip files.i want select random 6 zip file folder. i try: directoryinfo test= new directoryinfo(@"c:\test").getfiles(); foreach (fileinfo file in test.getfiles()) { random r = new random(); //try apply random logic fail. if (file.extension == ".zip") { string a=""; (int listtemplate = 0; listtemplate < 6; listtemplate++) { += file.fullname; //want choose random 6 files. } } } is there way this.thanks help. to this, want randomize order in files being sorted. using sort shown in answer (you can use more cryptographic approach if want) var rnd = new system.random(); var files = directory.getfiles(pathtodirectory, "*.zip") .orderby(x => rnd.next()) .take(numoffilesthatyouwant); you

ios - View is clipped automatically -

Image
i have uiview of size 320*178 it's showing part (around 320*120) . unable figure,how view clipped. have set property yes unknowingly or i'm missing something. i have drawn view in storyboard, no code. any appreciated. thanks in advance. i knew kind of silly mistake developers come across. on running code, myview clipping. focused on thing how can view clipped automatically.finally after going through suggestions,i tackled setting background color of myview redcolor. then, found clipping magic lost 2-3 hrs myview's size 45-55 overlapped unknown view code.

java - The og.likes cannot work for Pages or Photos -

i have thought use open graph perform facebook android app. https://developers.facebook.com/docs/opengraph/guides/og.likes/ but see won't work fb pages , photos. then how can perform fb pages , photos ? the og.likes action can refer open graph object or url, except facebook pages or photos.

java - Array Printf issue -

i'm working on simple program supposed list numeric values in array; way. how have output like: printing array: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 it has lined seen above , line must contain 10 numbers. seem have formatted correctly output doesn't that. here getting: printing array: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 i'm not sure i'm doing wrong here's code: //disregard name 'juice', give programs weird names public class juice { public static void main(string[] args) { //sets array int[] numbers = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22}; //title system.out.println("printing array: "); //counting elements (int = 0; < numbers.length; i++) { //prints each element value 4 spaces in between syste

CSS: fixed position -

i'm new here thank in advance help. i have 3 columns page , want have 1st , 3rd ones fixed (they don't have scroll middle column). everything works fine positioned these 3 columns in container div has 100% width , 100% height min width , height. my problem 3rd column positioned on right of page (my footer has same problem) doesn't block @ min width defined container. if change position absolute 3rd column works scrolls content. can help? thank

java - How can I get the session values from an external.js by using Struts2 jQuery -

i need recover value session in external js. before, did in script embedded in jsp lines , worked properly: $(window).load(function(){ var selectedserver = "<s:property value='%{#session.selectedserver}'/>"; var selectedmarket = "<s:property value='%{#session.selectedmarket}'/>"; }); but now, want external js , alert(selectedserver); after these lines, show me literal: <s:property value='%{#session.selectedserver}'/> , not value. ¿is syntax different in external.js ? any suggestion appreciated. you can use javascript global variables in external script, or use function parameters pass values should obtain in jsp external function. <script> var selectedserver = "<s:property value='%{#session.selectedserver}'/>"; var selectedmarket = "<s:property value='%{#session.selectedmarket}'/>"; </script> function(selectedserver, selected

php - Cron job not running on XAMPP Mac OS X but works otherwise -

i trying run cron job using xampp on mac. i've tried following commands, file isn't created @ all. if run manually, using localhost/writer/writer.php , works. i've looked on google , nothing address or resonates problem. appreciated. the commands tried: * * * * * /applications/xampp/xamppfiles/bin/php /applications/xampp/xamppfiles/htdocs/writer/writer.php * * * * * php /applications/xampp/xamppfiles/htdocs/writer/writer.php code being run test purposes. <?php $file = 'people.txt'; // append new person file $current = "john smith\n"; // write contents file file_put_contents($file, $current); ?> note, i've tried running sample cron outside of xampp, doing: (it worked). * * * * * echo 'test' > /desktop/test.txt also, if in directory , " php writer.php " works well. i found solution. quite stupid of me , yes, silly @ best. the file being output @ root, , verify, did check cd ~/ . there was, file

php - MySQL - Using special characters -

i'm having problems using special characters in mysql. my code retrive info 2 tables 2 combobox problem words special characters messed up. this html page 2 combobox: <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>adicionar clube</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> </head> <body> <form action="adicionarclubebd.php" method="post" enctype="multipart/form-data"> nome: <input type="text" name="nome"id="nome"/><br> logo: <input type="file" name="logo" id="logo"/><br> telefone: <input type="text" name="telefone"id="telefone

excel vba - Extracting a page from a pdf using a keyword -

ok im quite sure cant excel vb or free even. im writing these macros work, , 1 of them needs able chose pdf based on keywords. go pdf, search either titles of pages or text on pages using different set of keywords. when finds page matches 1 of keywords in second set, extract whole page, is, single page pdf. this can attached email. this small part of purpose of macro. understand, im going have find sdk, pay it, , write separate program in c# or visualbasic run when macro needs. i dont need code, maybe point in right direction :d in end got program called pdftk.exe, free, , runs in command line. can export bookmarks listing txtfile. search text file string/keywords. jump down line or 2 , grab associated page number. use same exe extract page , save specific name, vba macro can grab newly created 1 page pdf. ive seen code on site creating delays while process doing thing, try implement also.

ruby - Uploading a pdf to rails using paperclip not working -

i using paperclip upload pdf's db. pdf isn't uploaded db, creates blank entry, so: 2.1.0 :001 > yearlyguide.last yearlyguide load (1.4ms) select "yearly_guides".* "yearly_guides" order "yearly_guides"."id" desc limit 1 => #<yearlyguide id: 2, pdf_file_name: nil, pdf_content_type: nil, pdf_file_size: nil, pdf_updated_at: nil, start: nil, end: nil, created_at: "2014-06-09 14:10:50", updated_at: "2014-06-09 14:10:50"> my controller looks this: def new @yearguide = yearlyguide.new end def create @yearguide = yearlyguide.create if @yearguide.save redirect_to '/' else render 'new' end end and model this: class yearlyguide < activerecord::base has_attached_file :pdf validates_attachment :pdf, content_type: { content_type: "application/pdf" } end my new.html.erb this: <%= bootstrap_form_for(@ye

python - matlplotlib pdf savefig: markers change -

under windows matplotlib changes linewidth of white, filled markers when saving pdf. saving png works fine. using anaconda python3.3 , matplotlib 1.3.1 i found closed thread on github: open markers incorrect in pdf output question matplotlib linewidth when saving pdf . under linux, using eps or pdf makes no difference. has encountered similar issue ? the circular markers cutted @ outside border masked white rectangle. code: from matplotlib import pyplot plt fig = plt.figure(figsize=(1.5,1.5)) ax = fig.add_subplot(1,1,1) ax.plot([1,2,3,4],[5,6,7,8],'wo') fig.savefig('testfig.pdf',bbox_inches='tight', format='pdf') plt.show() edited: damn. foxitreader related issue. sumatra pdf fine.

c# - select all xml child nodes that start with a string -

i using c# . i have xml node child nodes follows : <priceid>32</priceid> <store_1> 344</store_1> <store_32> 343 </store_32> i select nodes start store is there way can ? i know there way select nodes specific names .. xmlnodelist xnlist = quote.selectnodes("store_1"); does know me ? you can use linq2xml var xdoc = xdocument.parse(xmlstring); var stores = xdoc.descendants() .where(d => d.name.localname.startswith("store")) .tolist();

javascript - Chrome Plugin and Content Security Policy errors -

when uploading unpacked chrome extension, following error: could not load extension '/users/me/example'. invalid value 'content_security_policy': both 'script-src' , 'object-src' directives must specified (either explicitly, or implicitly via 'default-src'), , both must whitelist secure resources. may include of following sources: "'self'", "'unsafe-eval'", "http://127.0.0.1", "http://localhost", or "https://" or "chrome-extension://" origin. more information, see http://developer.chrome.com/extensions/contentsecuritypolicy.html my manifest looks following: { "name": "example inc.", "manifest_version" : 2, "version": "0.4.4", "content_scripts": [ { "matches": [ "*://*.example.cc/*" ], "js": [ "production/jquery.libs.min.js&

elasticsearch - Can I specify a fallback preference for a "should" query? -

if have 2 documents in index, locale values en , pt , { "slug": "my-object", "locale": "en", } { "slug": "my-object", "locale": "pt", } and run query result should in locale don't have, fr , { "query": { "bool": { "must": [{ "term": { "slug": "my-object" } }], "should":[{ "term": { "locale": "fr" } }] } }, "size": 1 } is there way make fall doc en locale, not pt or other? basically, want "it should in french, accept english." good news! looks recent updates slated 1.3 release should allow work in general case (more 1 result, supporting pagination). isn't in form of "should" query, though, called top_hits aggregator: https://github.com/elasticsearch/elasticsearch/pull/6124 https://github.com/elasticsearc

swing - Java : Scroll Over JScrollPane -

Image
i've got vertically scrolling jpanel, on jpanel couple of jscrollpanes, when user scrolls down through panel, if users mouse goes on jscrollpane no longer able scroll jpanel, have move mouse off jscrollpane , onto panel. gets quite annoying after while. to end there way tell java continue scrolling parent jpanel unless user clicks on child jscrollpane , tries scroll it? i believe you're looking jscrollpane#setwheelscrollingenabled(boolean handlewheel)

ios - Objective-C iPhone - Open URL in Safari immediately and exit app -

Image
i able open url in safari using: [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"www.myurl.com"]]; it works fine, takes more 10 seconds in simulator. i've tried putting code inside app delegate's didfinishlauchingwithoptions method or view controller's viewdidload method, still takes on 10 seconds load. black screen nothing on entire duration before opens safari. there way decrease load time? simulator bug?? still trying devices registered test on actual devices. the funny thing when add uibutton's action method, app loads right away, user must tap uibutton launch url in safari. my objective here have app upon startup, launches hard-coded url in safari. app should exit able again when user taps on app icon. suggestions? here's snippet of attempted before in viewcontroller.m has 10 second black screen if want try yourself: - (void)viewdidload { [super viewdidload]; [[uiapplication sharedapplication] openurl

sql server - SQL date not converting in OPENROWSET query but does work as admin user -

select cast('01/05/2014' date) returns: 2014-05-01 but have csv file dates (all in may) written in uk format above. in fact, i'm using top 10 records have date: 01/05/2014 my problem when run below code, results all: 2014-01-05 00:00:00.000 | 2014-01-05 | 2014-01-05 | 2014-01-05 | 2014-01-05 | jan 5 2014 12:00am | 05/01/2014 this code: select top 10 sdispdate ,convert(date, sdispdate, 103) ,cast(sdispdate date) ,convert(date, cast (sdispdate date), 103) ,cast(convert(date, sdispdate, 103) date) ,cast(sdispdate varchar(50)) ,convert(varchar(20), sdispdate, 103) openrowset('microsoft.ace.oledb.12.0','text;database=d:\import;hdr=yes;format=delimited(,)', 'select * [mydatafile.csv]') so problem cannot convert uk date uk date. feel issue must have openrowset - ideas? update : i've run same query on sql 2008r2 server (same mine) , got correct result. both servers show us_english language , mdy dateformat when running dbcc useropti

How to use XSLT to convert a XML to Table [CODE UPDATED 11/6] -

i have xml file want convert table or csv xslt. tried altova mapforce 2014to map columns still,not able gen out outcomes. lot. xml file have <records> <person id="756252" date="15-oct-2014"> <gender>male</gender> <namedetails> <name nametype="primary name"> <namevalue> <firstname>ken</firstname> <surname>wu</surname> </namevalue> </name> <name nametype="aka"> <namevalue> <firstname>kenneth</firstname> <surname>wu</surname> </namevalue> </name> <name nametype="aka2"> <namevalue> <firstname>can</firstname> &l

apache pig - Date wise listing of hadoop file in pig -

i did : hadoop dfs -ls /user/abc/fun/ and worked fine , listed files in increasing order alphabetically. want listing of files according date in increasing order i.e. latest date file placed @ bottom something this: hadoop dfs -ls ltrh /user/abc/fun/ it didn't worked read pig's wiki not valid fsshell command. please suggest how desired result. appreciated.thanks!!! there couple of ways if want inside pig shell , not script save following command hadoop fs -ls /user/abc/fun/ | sort -k6,7 inside test.sh file. give chmod +x permissions inside grunt shell can sh ./test.sh desired result. suppose want include inside pig script , run using pig -f can use %declare basedir hadoop fs -ls /user/abc/fun/ | sort -k6,7 | tail -1

Java regex split text (both the delimiter and the order may be unknown) -

i'm trying split text "name:jack,berk,john;teacher:smith,jan;course:math;" , hope result contains 3 sub-strings (or less, depends on appearance of 'name' 'teacher' 'course'), is: "name:jack,berk,john;" "teacher:smith,jan;" "course:math;" but appearance order of identifiers 'teacher,name,course' not fixed, can 'course ,name, teacher' , can lack 1 or two, has 'name' identifiers. also delimiter between identifiers not fixed, in example ';' ,but can '、\\s,' . i have tried many times not works. string str = "name:jack,berk,john;teacher:smith,jan;course:math; str = str.replaceall("(.*)(.)(name|teacher|course)(.*)(.)(name|teacher|course)(.*)", "$1--$3$4--$6$7"); system.out.println(str); any suggestions appreciated. edit: regex without looking specific delimiter. rather splitting string match on regex: (name|teacher|course):(.

python - Redis performance -

Image
i'm learning redis , trying measure time performance. in setup set 5 000 000 keys , measured time each unique operation. i have got following plot (x-label number of operations (set), y-label time in milliseconds): i'm noticing performance of redis going extremely down. have measured performance 1 000 000 keys: i can monitor constant areas bad performance. anyway operating time goes down after interval of time. my question if has done similar researches in area of redis performance, he/she discuss these results. me interesting , important understand reason server such "time jumping" , how can improve performance. if needs python-code: def setkeyvalue(key, value): assert (key != none), "please, key" redis_server.set(key, value); def loopkeyvalues(number): timeuse = [] start_tot = time.time() x in range(number): start = time.time() #sethashkeyvalue('mydata',x, x**2) setkeyvalue(x, x**2)

What happens during serialization in java, if two object refrences are pointing to the same serializable Object? -

what happens during serialization in java, if 2 object refrences pointing same serializable object? does serializable objects saved twice ? example : class king implements java.io.serializable { private string name="akbar"; } class kingdom implements java.io.serializable { king goodking=new king(); king badking=goodking; } public class testserialization { public static void serializeobject(string outputfilename, object serializableobject) throws ioexception { fileoutputstream filestream=new fileoutputstream(outputfilename); objectoutputstream outstream=new objectoutputstream(filestream); outstream.writeobject(serializableobject); outstream.close(); } public static void main(string[] args) { kingdom kingdom=new kingdom(); try { testserialization.serializeobject("king

c - Open file in a different directory -

i have simple task. have open file in directory. have .c file in src, when compile move programs (a.out) in bin directory. want read file in directory asset. these folders in main folder. if this file* fp = fopen("../asset/team_list", "r"); it won't open file. why can't open file in directory? guess forgot put extension of file file* fp = fopen("../asset/team_list.doc", "r");

How to create reflection class in java and is there any possible way to pass more than two class as argument -

i'm trying pass more 2 class in code given below getmethod(methodname, new class[] { rootbean.getclass() }) and want create object argument class can call method of arugment class. if(obj==null) { classa.getmethod((methodname, new class[] { rootbean.getclass() })); } else { // other operation } you getmethod(methodname, new class[] { rootbean.getclass(), otherbean.class }); however class#getmethod takes variable length argument, no need create array, pass class agrument separated comma getmethod(methodname, rootbean.getclass(), otherbean.class);

c# - GridView still being refreshed when not in UpdatePanel -

Image
problem , description: i have gridview programmatically added dropdownlists on rowdatabound every cell. the dropdownlists have data sources . when press 'save' button, meant read selecteditems in dropdownlists , save them database. however, when click on button, causes postback , deletes of controls in gridview , therefore, none of them can found in button_click event. after asking questions before , trying different techniques try store dropdownlists in cache/session state etc, can't seem able keep dropdownlists or data when click button. therefore, trying add updatepanel , use ajax try stop refresh of gridview. my attempt such: <asp:gridview id="gv_rota" runat="server" autogeneratecolumns="false" onrowdatabound="gv_rota_rowdatabound"> <headerstyle backcolor="#6a3d98" forecolor="white" height="20" />