Posts

Showing posts from September, 2012

html - How to disable jQuery click event on label? -

here example fiddle html: <div class="wrapper"> <label class="control-label" for="topicwords">label</label> <div class="controls"> <input type="text" id="topicwords"> </div> </div> <br/><br/> <span id="message"></span> js: $('.wrapper').on('click','input#topicwords', function() { $('#message').fadein('fast').text('clicked').fadeout('slow'); }) click event runs on both input#topicwords or label . how make run when input#topicwords clicked is there other way except than: $(".control-label[for='topicwords']").on('click', function() { return false; }); or shortcut: $(".control-label[for='topicwords']").on('click', false); update: wrapper's content dynamic, don't have div class controls. if und...

java - Issue in ArrayList in android -

in app using arraylist save string values.these values taken asynctask , these values set textview in adapter.but set values second position in arraylist .in log showing arraylist values contains values.but while setting not display first value.code mentioned below. indexofselectedid = photoall_id.indexof(photoid_c); (int = indexofselectedid ; < photoall_id.size(); i++) { all_postid.add(photoall_id.get(i)); url = urls.baseurl + "mobile_api.php?action=post&post_id=" + photoall_id.get(i) + "&access_token=" + accesstoken + "&user_id=" + userid; new getimage().execute(url); } (int = 0; < indexofselectedid; i++) { all_postid.add(photoall_id.get(i)); url = urls.baseurl + "mobile_api.php?action=post&post_id=" + photoall_id.get(i) + "&access_token=" + accesstoken + "&user_id=" + userid; new getimage().execute(url); } adapter = new imagepageradapter (); viewp...

descriptor - Why attribute lookup in Python is designed this way (precedence chain)? -

i've ran descriptors in python, , got ideas descriptor protocol on "__get__, __set__, __delete__", , did great job on wrapping methods. however, in the protocol , there're other rules: data , non-data descriptors differ in how overrides calculated respect entries in instance’s dictionary. if instance’s dictionary has entry same name data descriptor, data descriptor takes precedence. if instance’s dictionary has entry same name non-data descriptor, dictionary entry takes precedence. i don't point, isn't ok in classic way(instance dictionary -> class dictionary -> base class dictionary)? , if implement way, data descriptors can hold instances, , descriptor not have hold weakrefdict hold values different instances of owner. why put descriptors lookup chain? , why data descriptor placed in beginning? let's see on example: class getsetdesc(object): def __init__(self, value): self.value=value def __get__(self, o...

hbase - why copyfield can not use PatternReplaceCharFilterFactory in solr -

my solr cloud version 4.10.3 in coudera cdh5.4.7.i want use copyfield copy hbase rowkey field , use patternreplacecharfilterfactory delete pattern.but doesn't work.when search document,the rowkey_column , rowkey same,not cut anything.for example,rowkey "hdsa00_01$41872607-9_11654094_1001292270_1443404975000$0" ,and rowkey_column must "41872607-9_11654094_1001292270_1443404975000$0" .but same rowkey.why?please me! config in schema.xml here,rowkey string type: <field name="rowkey_column" type="rowkeycolumn" indexed="true" stored="true" /> <copyfield source="rowkey" dest="rowkey_column"/> <fieldtype name="rowkeycolumn" class="solr.textfield"> <analyzer> <charfilter class="solr.patternreplacecharfilterfactory" pattern="^\s{9}\$|^healtharchives\$" maxblockchars="20000" /> <tokenizer class="solr.keyw...

java - (cannot find csv file created) Saving android sqlite database table into csv file which can be opened for viewing by human on a computer -

my objective write android sqlite database table csv file can read human on computer. want able open csv file on computer viewing of data. i have researched on stackoverflow exporting database table csv , 1 of code use exporting sqlite database csv file in android . have tried several other code on stackoverflow. other code suggested on stackoverflow correct cant seem meet objective. basically code similar link above. my code can run without compilation error, meaning can run without error. however, faced problem. either file not created onto computer viewing or created in android internal folder. tried search on window search button ".csv". not find file supposed created. need csv file database table data inside it. i appreciate if can guide me on goes wrong or can locate actual csv file.i using android phone. following code of concern. public void writetocsv(){ (int i=21; i<37; i++){// write each average table csv file string tablename...

Excel Custom Function to Retrieve XML Data -

i create custom function retrieve specific data available in form of xml url link. first time dealing xml in excel, let alone vba, , struggling it. i have been able write procedure (local currency exchange rate retrieval) 1 can run pressing custom button, runs code below: sub fx_retrieve() dim fx string dim customdate string fx = range("fx") customdate = range("customdate") application.screenupdating = false activesheet.unprotect rows(2).clear activeworkbook.xmlimport url:= _ "http://www.cbu.uz/section/rates/widget/xml/" & fx & "/" & customdate, importmap:= _ nothing, overwrite:=true, destination:=range("c2") range("d:d").entirecolumn.autofit rows(2).horizontalalignment = xlcenter columns(6).clearcontents activesheet.protect application.screenupdating = true end sub just in case, xml output looks this: 2015-12-29 usd ...

entity framework - Can't find local SQL database from within Visual Studio in my ASP .NET MVC 4 project -

i have project uses ef 5 (code first) in visual studio 2012. when build database works, isn't showing in sql explorer reason. checked connection object @ runtime , can see name of local database not listed in sql explorer. what's odd project doesn't have problem on machine. project under source control check see if have running copy of sql server running. i experienced same thing; creating project , entityframework objects, , running project. vs 2012 created database in 2008 r2 db running @ time, hadn't opened in vs, didn't see new db. wasn't until opened db in vs appeared.

r - Extracting the 7th number from a 13 digit number -

this question has answer here: using substring on column in r 1 answer i want extract 7th number 13 digit number.for instance 9111110123341, 0 7th number , have if statement saying if number between 0 , 5 assign m new column . possible in r? don't use text processing functions numeric operations: extract_digit <- function(x, n) floor(x / 10^(ceiling(log10(x)) - n )) - floor(x / 10^(ceiling(log10(x)) - n + 1)) * 10 extract_digit(9111110123341, 7:10) #extract 7th 10th digits #[1] 0 1 2 3

android - How can I extract string from OnPostExecute to my Main Activity -

i'm still new, repeat, new in android studio , i'm trying display place name,vicinity,lat , long using listview. got listview ready couldnt string onpostexecute. tried using https://stackoverflow.com/a/12575319/5776859 did not work @ all, or maybe didnt correctly. hope me or show me proper way string , double onpostexecute. public class placesdisplaytask extends asynctask<object, integer, list<hashmap<string,string>>> { jsonobject googleplacesjson; googlemap googlemap; @override public list<hashmap<string, string>> doinbackground(object... inputobj) { list<hashmap<string, string>> googleplaceslist = null; places placejsonparser = new places(); try { googlemap = (googlemap) inputobj[0]; googleplacesjson = new jsonobject((string) inputobj[1]); googleplaceslist = placejsonparser.parse(googleplacesjson); } catch (exception e) { log.d...

Access VBA decimal seperator point istead of comma in XML Download -

we run simple ms access database can import data either xls or xml file (webservice). the problem numbers in xls file have format: 123.456,78 , in xml file: 123,456.78. since in germany need the first format. there simple method in vba change format type when using xmldoc function?

objective c - How to check validity of password for wifi network -

basically have info such network interface, name of wifi network, password, etc, , trying check if wifi password correct trying log wifi , getting received message check if correct or not. far have tried connect wifi network using network setup command line command worked until tried getting output application, wondering if knows simple way can use command line tool application or built in ways use not rely on command line. thanks. you should try corewlan framework . documentation poor, framework simple , there example (it outdated , you'll deprecation warnings)

python - assign value in a list -

while true: p = [] q = [] h = [] e = [] m in range(n): p = (i-d[m-2][1])/d[m-2][0] q.append(p) print q r = q[0] if r < g[1][0]: r == g[1][0] elif r > g[1][1]: r == g[1][1] print r for problem of coding above, want explain in simpler manner. i = [3,5] r = [5,6] if i[0] < r[0]: i[0] == r[0] print however, not [5,5] in example, why? output still [3,5] the following lines comparisons rather assignments: r == g[1][0] r == g[1][1]     i[0] == r[0] i suspect meant write r = g[1][0] r = g[1][1] i[0] = r[0]

javascript - How to get the value of h1 tag using JS? -

i have 3 pages, 2 pages wordpress pages , other 1 custom page template form. 2 pages created using wp-job manager plugin. 1st page has had dropdown menu , contains list of jobs. on 2nd page description of job. now, want value of h1 tag on 2nd page after user click input button , pass 3rd page , displayed in 1 of input textbox (position input textbox) using js. how this? here's link of 2nd page 3rd page html: <header class="entry-header"> <h1 class="entry-title">collections trainer</h1> </header> vanilla javascript solution (no framework required): var h1text = document.queryselector(".entry-title").textcontent;

android - Managing multiple Flavours... exponential growth? -

imagine situation in need have versions of apk or without ads, or without customjarsdk , 3 markets, googleplay, amazonapps , samsungapps. in perfect world whould 7 flavours: with ads without ads with customjarsdk without customjarsdk for googleplay for amazonstore for samsungapps and in perfect world there whould way combine flavours in gradle, example: with ads + samsungapps + customjarsdk without ads + googleplay etc... is possible? or cursed , forzed have flavours...????? for googleplay ads for googleplay ads , customjarsdk for googleplay without ads for googleplay without ads , customjarsdk for amazonstore ads for amazonstore ads , customjarsdk for amazonstore without ads for amazonstore without ads , customjarsdk for samsungapps ads for samsungapps ads , customjarsdk for samsungapps without ads for samsungapps without ads , customjarsdk it quite difficult answer question. depends resources different in flavor. currently you can...

angularjs - Changing the data source of ui select on event -

i want change data source of select each time select new. this how markup of directive looks: <ui-select on-select="fclick($item,$model)" on-remove="rclick($item,$model)" reset-search-input="true" close-on-select="true" multiple ng-model="namesmodel.selected" theme="select2" ng-disabled="disabled" style="width: 100%;"> <ui-select-match placeholder="select user...">{{$item.name}}</ui-select-match> <ui-select-choices repeat="user in users"> <div ng-bind-html="user.name | highlight: $select.search"></div> </ui-select-choices> </ui-select> for example: initial source like: scope.users = [{name:"user1",address:"address1"},{name:"user2",address:"address2"}] whenever select user1 want call rest service , change value of scope.use...

Android Install error with release unsigned apk -

i try install application on release build type , generic error: "parse error. there problem while parsing package" installing debug apk works successfully. installing release apk adb shows information: c:\android-sdk-windows\platform-tools>adb install app-release-unsigned.apk 2577 kb/s (1606360 bytes in 0.608s) pkg: /data/local/tmp/app-release-unsigned.apk failure [install_parse_failed_no_certificates] this logcat v/applicationpolicy: isapplicationstateblocked userid 0 pkgname com.android.packageinstaller i/activitymanager: start u0 {act=android.intent.action.view dat=file:///storage/emulated/0/download/app-> > release-unsigned.apk typ=application/vnd.android.package-archive cmp=com.android.packageinstaller/.packageinstalleractivity (has extras)} uid 10019 on display 0 d/customfrequencymanagerservice: acquiredvfslocklocked : type : dvfs_min_limit frequency : 1190400 uid : 1000 pid : 961 pkgname :...

php - Delete from two tables -

i trying delete series of rows database using delete button, data split across 2 tables, joined 1 common field. have created following, delete isn't working right. $watchlist_id = $_get['id']; // delete watchlist if ($submit == 'delete watchlist') { require_once("db_connect.php"); $deletewatchlist_bad_message = ''; if ($db_server) { $purge_watchlist_query = "delete watchlist_films watchlist_id = '$watchlist_id'"; mysql_query($purge_watchlist_query) or die("delete failed. " . mysql_error() . "<br />" . $purge_watchlist_query); $delete_watchlist_query = "delete watchlists watchlist_id = '$watchlist_id'"; mysql_query($delete_watchlist_query) or die("delete failed. " . mysql_error() . "<br />" . $delete_watchlist_query); } else { $deletewatchlist_bad_message ...

java - Copy jpg from folder to folder on Linux -

i'm using files.copy(sourcefile,destfile) apache's commonsio lib, in order copy jpg 1 folder on linux machine. actually i'm doing pic's in folder : file folder = new file(sourcepath); file[] foldercontent = folder.listfiles(); file tmp = null; file sourcefile = null; file destfile = null; //copy pics other folder : for(int i=0;i<foldercontent.length;i++){ if(foldercontent[i].getname().endswith("jpg")){ sourcefile = new file(sourcepath); destfile = new file(destpath); //copy main dir: files.copy(sourcefile,destfile); } } but in new folder empty files (with correct name). when tested simple test 1 file ,like : files.copy(sourcefile,destfile); file copy successfully. does have clue ?? (is java-linux known issue ?) thanks! this no linux issue. first, use source folder source file, not file itself. also, possibly, use use destination folder copy target. assuming destpath destinati...

c# - WCF - The remote endpoint no longer recognizes this sequence -

i having strange issue calling method on wcf. web , service code made through development, working fine on local developer machines , qa server. when published uat server windows service returned: the remote endpoint no longer recognizes sequence. due abort on remote endpoint. value of wsrm:identifier not known sequence identifier. reliable session faulted. the methods worked fine, built transport objects database calls threw exception when returning object. there similar question same error, none of suggested solutions applied. exact same code worked fine on machines threw exception when installed on server. i'm still not sure why, cause of behaviour interface returned method had ienumerable<> property. replacing list<> resolved issue. i'd love know why worked on every other machine tried on not uat server. the .net versions installed on both identical. the difference can see different operating systems. it worked fine on: wind...

forms - php select options in different steps -

very basic question: have following (array?) select box within form need change jump/step in numbers appear in drop down. @ moment in multiples of 100 , 300-1500 need multiples of 100 1000 , 1250 , 1500 . for($i = 300; $i <= 1500; $i += 100) have tried using function range() ? can configure start, end, , step. http://php.net/manual/en/function.range.php

css - Shorter declaration for inputs in Sass -

inputs , buttons have lot of predefined styles, had been reseted in first place, example borders , backrounds. if borders , backgrounds styled later differenty, there way make declaration shorter? .mybutton1, [role="button"].mybutton1, input[type="submit"].mybutton1, input[type="rest"].mybutton1, input[type="button"].mybutton1, button.mybutton1 { { font-size: 10px; background-color: red; border: solid; } .mybutton2, [role="button"].mybutton2, input[type="submit"].mybutton2, input[type="rest"].mybutton2, input[type="button"].mybutton2, button.mybutton2 { { font-size: 10px; background-color: blue; } use common style in input styles , differentiate class, check below codes. [role="button"], input[type="submit"], input[type="rest"], input[type="button"], button { font-size: 8px; } .mybutton1 { font-size: 10px; } .mybutton2 { font-size: 14px...

javascript - Add checked cell in a table using jquery -

i have tried add cell number in table. want add on cell checked (using check box). want using javascript / here code / <html> <head> </head> <body> <form name="addvalue"> <table id="countit" border="1px"> <tr> <td><input type="checkbox" name="choice"/></td> <td>some value</td> <td>some value</td> <td class="count-me">12</td> </tr> <tr> <td><input type="checkbox" name="choice"/></td> <td>some value</td> <td>some value</td> <td class="count-me">2</td> </tr> <tr> <td><input type="checkbox" name="choice"/></td> ...

ruby on rails - rendered page completely changes, after adding a call to `render` -

i have in controller; def get_response response = httparty.get('url') render json: response.to_json end def edit @newevent = event.find(params[:id]) json = get_response byebug end now when go edit page, shows json response, not want. i want response usable via edit page. call response. id (currently isn't working, said, can json , show, removed edit page, not want want json used inside edit page) after rereading several times, think understand problem. what happened i think confusing rails magic™, handy , yet makes super hard beginners make step using rails generated code own versions , understand why stuff breaks. a controller action empty edit was, implicit render <name-of-controller-action> . write actual render yourself, rails not implicit render . did 'overwrite' rails one. yielding result of seeing json rendered , not edit page anymore. how solve it what trying adding content edit view (that ...

python - How to advance iteration while inside an iterator spreadsheet rows -

i need advance iteration of rows read , excel spreadsheet while still inside iterator loop. try: r in range(insheet.nrows): cdat = insheet.cell(r, 0).value if not cdat == xlrd.empty_cell.value: if hasnumbers(cdat): #strip digits client pneumonic #pdb.set_trace() if re.sub(r'\d','',cdat) == clntid: #pdb.set_trace() #this call belongs client memid = cdat fincallblock = true while fincallblock: #output line formatted callheader #inc row counter can't ==> next(r) cdat = cdat.strip(insheet.cell(r, 0).value) if cdat == u"call resolved": pdb.set_trace() fincallblock = false the code crashes marked with: -> next(r) ...

architecture - Rails "sub-environment" -- still production (or test, etc.) but different -

how should best handle code part of single rails app, used in several different "modes"? we have several different cases of app driven same data sources (mysql, mongodb, solr) , shares core logic, assets, etc. across multiple different uses. background/details: html vs rest api common scenario have html , rest interfaces. these differences handled through routing (e.g. /api/v1/user/new vs /user/new ) -- minor differences provide same functions. seems reasonably clean me. multi-tenant common scenario app "multi-tenant", determined subdomain of url, e.g. partner1.example.com , partner2.example.com (or query-string parameter api customers) -- each has number of features or properties differ. handled filter applicationcontroller using data largely stored in set of tenant-specific database tables tenant-specific functionality encapsulated methods. seems reasonably clean me. offline tasks 1 scenario great deal of data acquired through large number o...

javascript - Bluebirdjs swallowing errors when binded to 'this' -

taking following example: window.addeventlistener('unhandledrejection', function(e) { console.error(e); }); var p = new promise(function(resolve, reject) { console.log('start'); resolve(); }); p.bind(this).then(function() { console.log('then'); //this.callfunction here throw new error('err'); }); i expect error caught in unhandledrejection event listener , error outputted console. works fine when .bind(this) not in code error seems swallowed when used. explanation why case appreciated. thanks.

github - Can't push bazaar repository into git using dpush -

i not able push bazaar repository git. have used command : bzr dpush git+ssh://git@github.com/harsh-a1/dhis_2.22.git,branch=master am getting following error: bzr: error: file id "none" not present in tree bzrlib.inventory.chkinventory object @ 0x7f3613337290 i want see how git merges different bazaar ones....am fed of merging bazaar giving try. found above method on internet linking bazaar github not working....is there hope? we have migrated source code https://github.com/dhis2/dhis2-core , should able use git directly now.

ssl - Issue creating a connection to SQL server 2014 with ODBC data source and TLS activated -

i trying create / modify system data source application needs connect our microsoft sql express 2014 database through odbc data source. connection used work before enabled ssl encryption flow but, have encrypted link, connection not work anymore. here details: we run microsoft sql server express 2014 sp1 latest cumulative update (cu #3) (which necessary deactivate ssl 3.0 , tls 1.0 , run tls 1.1 , tls 1.2) the database instance named instance, configured run tcp/ip connection , fixed port. we enabled "force encryption" option , configured certificate through "sql server configuration manager" we can establish connection database either using management studio or sql command line utility we disabled usage of ssl/tls prior version tls 1.1 done through microsoft schannel. required update sql express 2014 sp1 latest cumulative update (cu #3) the odbc data source try configure (through odbc data source administrator) "system dsn" , uses "sql ...

mysql - php mysqli with insert and update queries -

this question exact duplicate of: php mysqli insert , update queries 3 answers i creating feedback form users can write feedback , store in database using php mysqli without refreshing whole page . got success message without entered data can me ? asked yesterday same question php mysqli insert , update queries feedback_form.php <?php session_start(); $login = ($_session['login']); $userid = ($_session['user_id']); $login_user = ($_session['username']); $fname = ($_session['first_name']); $lname = ($_session['last_name']); $sessionaddres =($_session['address']); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...

ios - How to attach image from ImageView to E-mail within an App -

got following. made simple ios / swift app needs send image specific e-mail. got working: take picture grap picture existing photo's image shown in image view send button thats leads me mail configured: recipient, subject , messagebody. what need working how can add selected image image view added e-mail when press send. following code 1 use: for taking , selecting images: @iboutlet var imageview: uiimageview! @iboutlet weak var piclabel: uilabel! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func fotoknop(sender: anyobject) { } @ibaction func chooseimagefromphotolibrary() { let picker = uiimagepickercontroller() picker.delegate = self picker.sourcetype = .photolibrary presentviewcontroller(picker, animated: true, completion: nil) } @ibaction...

c# - WCF not required fileds -

this class generated automatically .cs class .xsd make of fields not required. not work "isnullable", [datamember(isrequired = false)]: wsdl <xs:element name="addrtypecode" nillable="true" type="xs:string" /> <xs:element name="streetname" nillable="true" type="xs:string" /> .cs /// <remarks/> [system.codedom.compiler.generatedcodeattribute("xsd", "4.0.30319.1")] [system.serializableattribute()] [system.diagnostics.debuggerstepthroughattribute()] [system.componentmodel.designercategoryattribute("code")] [system.xml.serialization.xmltypeattribute(namespace="example")] public partial class address { [datamember(isrequired = false)] private string addrtypecode; [datamember(isrequired = false)] private string streetname; /// <remarks/> [datamember(isrequired = false)] public string addrtypecode { { ...

multithreading - I got the following error while running the command to start Jboss EAP 6.1 -

i got following error while running command start jboss eap 6.1 home path ./domain.sh error [org.jboss.as.host.controller] (controller boot thread) jbas010932: caught exception during boot: org.jboss.as.controller.persistence.configurationpersistenceexception: jbas014676: failed parse configuration it seems problem configuration of domain.xml file. have edited it? it can find problem if post whole "host controller" log information , domain.xml file.

objective c - NSDictionary getting changed when removing a object from NSMutableArray? -

i'm having 1 dictionary & array in remove object array means reflect in dictionary below code, nsmutablearray * plandetailarr; nsdictionary *singleitemdict; - (void)viewdidload { [super viewdidload]; plandetailarr=[[nsmutablearray alloc]init]; singleitemdict=[[nsdictionary alloc]init];} //parsing json response -(void)responsefun:(nsmutabledictionary *)response { singleitemdict=response; plandetailarr=response[@"plandetails_array"]; //removing 2 values array [plandetailarr removelastobject]; [plandetailarr removeobjectatindex:0]; } in above code remove values in array only.when print array & dictionary after removing values reflects in dictionary me please.. note :as print response getting removed. you need copy of dictionary. since pointing same object actual object's values change. singleitemdict=[response copy]; plandetailarr=[response[@"plandetails_array"] mutablecopy];...

javascript - Clear $ionicHistory when particular page is accessed -

Image
i having bit of problem clearing $ionichistory . as seen above when user clicks on ok on payment screen, i'd clear out app’s entire view history , redirect user nearby screen. the view history prior nearby screen on user reaches payment screen needs cleared. user sees menu icon on nearby screen, instead of back icon. what happens: view history prior payment screen on user clicks ok on cleared. when user lands on nearby page, , presses back (which should not able do), end on payment screen again, cannot access prior payment screen. my code far: app.js .config(function($stateprovider, $urlrouterprovider) { $stateprovider .state('app', { url: '/app', abstract: true, templateurl: 'templates/menu.html', controller: 'appctrl' }) .state('app.payment', { url: '/payment/:business', views: { 'menucontent': { templateurl: 'templates/payment.html', contro...

c# - Linq Outer join Object reference not set to an instance of an object DefaultIfEmpty -

i trying produce list of units required carry out audit date of audit if been carried out , if no audit leave if blank. i have following in method: public actionresult auditreportlist(int stnassureauditid) { //get data list var people = new list<people.models.person>(peopledb.people); var reports = new list<stnassureauditreport>(db.stnassureauditreports); var units = new list<people.models.unit>(peopledb.units); var auditunits = new list<stnassureunit>(db.stnassureunits).where(x => x.stnassureauditid == stnassureauditid); var auditreportlist = u in auditunits join r in reports on u.unitid equals r.unitid ur in ur.defaultifempty() select new { carriedout = (a == null ? string.empty : a.carriedout.tolongdatestring()), ...

C# Linq unique not work on lists -

this question has answer here: distinct() doesn't work 4 answers i trying following code check if list contains duplicated data: internal class program { private static void main(string[] args) { var list = new list<obj>() { new obj() { id = "1", name = "1" }, new obj() { id = "1", name = "1" } }; console.writeline(allitemsareunique(list)); } public static bool allitemsareunique<t>(ienumerable<t> items) { return items.distinct().count() == items.count(); } } internal class obj { public string id; public string name; } and result true! why? why? by default, comparison use references , in case, 2 object references not same. you need implement iequatable<t> provide type-specific equals() method distinct() use.

javascript - simple random generator doesn't randomize correct -

i have created number generator ... yes generate random numbers... generator works fine every time reload page , press button give me random number. lets generator give me number 289578 when press button first time. if reload page. give me random number 803175. if press button, without reloading page give me number 803176 after gives me number 803177 once more give me number 803178.. if reload page give me number 8031771 reload , press button again give me number 80317711. so instead of giving output on 6 different numbers start adding 1 until reload page , start adding 1000000. without randomize numbers. any ideas ? want keep javascript.. please no jquery comments. code: var id = math.floor((math.random()*1000000)+1); document.getelementbyid("add-new").addeventlistener("click", function() { id += 1; }); your not doing randomness inside click handler, add 1. maybe want just document.getelementbyid("add-new").addeventliste...

git - Easiest way to "cherry-pick a merge" -

i know title little woolly - hence quotes! say have branch, b_feature branched , merged main development branch b_master . there exists branch, b_release , wish add these changes (as point release). b_master , b_release have been diverged , never merged again. ---------bm----k1-----mm-----> b_master (k1 isn't included in b_release) \ \ / \ c1--c2--c3 (b_feature) \ \----br---------mr-----> b_release \ / ca-cb-cc i know can cherry-pick whole thing single diff git cherry-pick -m mm , giving ----br--squashed----> b_release where squashed commit containing changes of feature, message of merge mm . but if want retain change history , individual commit messages? can manually cherry-pick approximate workflow: git checkout b_release git checkout -b b_release_feature git cherry-pick c1^..c3 git checkout b_release git merge b_release_feature git commit --amend --reedit-message=mm git branch -d b...

Java Iterating Through 2D-Array -

i have 2d array in java so: int 2d_arr[5][5]; take, example, board looks this: 1 1 1 1 1 0 1 1 1 1 1 1 2 1 0 0 1 1 1 1 0 0 1 1 1 starting 2 in 3rd row, want able move in every direction (up, down, left, right, , diagonals). in code, how traverse array in every direction till find 0? my theoretical idea iterate in every direction sequentially. example, start going up, check values on line above 2 1 1 2 since didn't find zeros, check top right diagonal 1 1 2 still no 0s, go onto right. find first 0, break. attempt: know how bunch of if , loops, looking way edit code simpler , easier read version but i'm new java don't know best way go this. ideas? a twod iterator start. expect rest without effort. finding first 0 in scenario involve iterating through each direction , iterating across board in direction until iteration ends or find zero. doing spiral search involve starting iterator in each direction , doing step , check on each 1 ...

mysql - Select the ROW having the Maximum Value of a certain Column -

for example, if query returns 2 rows or more, select row having recent date. i'm doing this: select * table1 name=mark , max(timestamp(date(str_to_date(date_registered,'%d/%m/%y')))) the error returned is: #1111 - invalid use of group function you should use order statement: select * table1 name=mark order str_to_date(date_registered,'%d/%m/%y') desc limit 1

how to automatic increase specific column value in mysql -

table 1 id | uname | flag 1 | abc | 0 2 | abc | 0 3 | abc | 0 4 | bcd | 0 5 | bcd | 0 6 | cdf | 0 7 | ghi | 0 8 | ghi | 0 i want increase flag value according uname occurrence, starting 0 table 1 id | uname | flag 1 | abc | 2 2 | abc | 1 3 | abc | 0 4 | bcd | 1 5 | bcd | 0 6 | cdf | 0 7 | ghi | 1 8 | ghi | 0 i want update table you can modify table using update variables: set @u := ''; set @rn := 0; update table1 set flag = if(@u = uname, @rn := @rn + 1, if(@u := uname, 1, 1) ) order uname, id desc; unfortunately, mysql not let set variables in update when use order by . if want 1 statement, can use join : update table1 t1 join (select t1.*, (@rn := if(@u = uname, @rn := @rn + 1, if(@u := uname, 1, 1) ) ) rn table1 t1 cross join (select @...