Posts

Showing posts from June, 2013

jquery - CSS perspective and translateZ not working properly in FF and Safari -

i have created cover flow using css3 perspective , translatez, demo here it has transition effect when clicking through. works perfect on chrome , ie10, mobile safari 7. however, has few problems on firefox , desktop safari. on firefox(latest 29.0.1), clicking on image not put 0 position (flat view). cannot click through layers below. when first image current image, cannot click on third 1 directly, unless click second , make current first. on desktop safari (5, on both pc , mac), transition works partly, not smooth acceptable. main problem no matter image clicks, triggers downloads immediately, while code supposed download when image current one. structure simple: html <div class="product-download"> <div id="product-image"> <img src="//placehold.it/360x259" /> <span class="download-title">product image</span> </div> <div id="in-situ-image"> <img sr...

python - A better tool than Fixtures to populate a Django Database? -

i set fixtures in django project populate database. works has serious limit: can't create lots of stuff. in theory, can put elements want, since need write them 1 one, it's impossible have 20 000 items in db. i need tool fill primary keys itself, , able generate random typed data fill fixtures (e.g: emails, integers in range, dates in range, phones). nice functionally set functional rules in data generation. does knows way (library, ...) in django project? took @ https://github.com/joke2k/faker - tool seems good, no integration django. otherwise, guess write myself using faker (since writing fixture file consists on json generation), don't reinvent wheel :) thanks. factory boy: https://factoryboy.readthedocs.org it's fixtures replacement works unit testing or otherwise making fixture data. can write classes hook models , generate populated model instances , can construct them save database, or not.

php - RegEx: Issue parsing forum post body (with quote) -

this type of thing hammer away on until can right, in case believe it’s part of regex i've never had head around completely. greedy vs. non-greedy stuff. i have content: [quote=mick-mick topic=33586] gave dayz hour of life. can never back. :/ had wait wait. slow loads server selection screen once chose server took 3 minutes server. i'll still give h1z1 shot sure. :) [/quote] test the regex i’m attempting use is: /(\[quote=[a-za-z0-9]+\](.*)\[\/quote\])?(.*)/m but it’s matching quote line. as can see need username (mick-mick), topic id, , content of quote, , content following quote. also, quote may not exist in content @ all. can me on this? missing? using preg_match in php. final update: to match multiple quotes and grab content isn't in quote got little difficult. but, here goes : (?: \[quote=([a-z0-9\-]+) \s*topic=(\d+)\] (.*?) \[/quote\] | (.+?) (?=\[quote|$) ) this time use alternating non-capture group around...

javascript - Karma Jasmine tests always fails with stacktrace at line 9 -

i have weird problem. whenever i'm trying test , test fails, shows stacktrace line number 9. i'm using angularjs along jasmine , karma. found out doesn't depend on browser. error looks this: typeerror: 'undefined' not object (evaluating 'new google.maps.latlng') @ /users/user1/project1/test_ctrl.js:9 @ /users/user1/project1/spec/test_ctrl_spec.js:170 so, tells me test fails on line 170 (this correct), cause of error inside test_ctrl.js @ complete different line number number 9. , line number shown on every test fails. anyone idea how solve this? this appears issue using karma-coverage, since istanbul code coverage tool minifies source code. there open issue on karma-coverage repo. if temporarily disable coverage reporter in karma config file, should work fine.

android - How to change Layout params in Activity from Fragment -

i have these layouts in activity: linearlayout1 linearlayout2 frame1 frame2 (view.gone) and have fragmenta in frame1. how can make frame1.setvisibility(view.gone); frame2.setvisibility(view.visible); fragment = fragmnt2(); fragmenttransaction.replace(frame2, fragment); from fragment? how can access parent activity fragment? you can use getactivity() parent activity make sure oncreate has been called first otherwise getactivity() null.

ajax - fancy box Youtube video issues with Headers -

i´m trying load video trough fancybox. in development server works charm in production server same error. it´s wordpress website xmlhttprequest cannot load https://www.youtube.com/watch?v=n2ks9fgj36y&feature=youtu.be . origin http://www.dgmedios.com not allowed access-control-allow-origin. i write access-control-allow-origin * in server , nothing seems work. any suggestion please? in advance. d.

struts2 - <s:property/> value in JavaScript giving error -

i trying access <s:property value="names"/> values in javascript getting error. here names list. tried put <s:property value="names"/> in variable still not converting array. not sure going wrong . have put in javascript in jsp page. evaluated value of <s:property value="names"/> coming [abc,xyz] . appreciated! code: <script type="text/javascript"> $(document).ready(function() { var temp= new array(); temp=<s:property value="names"/>; }); </script> while debugging shows: <script type="text/javascript"> $(document).ready(function() { var temp= new array(); temp=[xyz,abc]; }); </script> its gives error xyz undefined. you can try this < script type="text/javascript" > $(document).ready(function() { var temp= new array(); <s:iterator id="names" valu...

jquery - Make the Accordion works on click event of a button -

i have accordion in page at end of each header, have button, want accordion open content when user click on button , not on header. my idea identify comes click, don't if best approach. // button @ end of header $("#divatender").click(function (data) { if ($("#content1").is(":visible") == true) { $("#accordion").accordion({ active: false }); } else { $("#accordion").accordion({ active: 0 }); } }); //change event of accordion $("#accordion").on("accordionchange", function (event, ui) { // how can discover button triggered or not }); html <div id="accordion"> <h3 class="segundopost" style="color: #ffffff !important;"> new contract <div id="divatender" style="float: right; margin-right: 10px;"> atend </div> </h3...

how to create a page object with css identifer & attribute -

how define page object css identifier attribute for example, <div class="presc" date-range="3 months">3m</div> <div class="presc selected" date-range="6 months">6m</div> <div class="presc" date-range="1 year">1y</div> how use attribute name data-range? div(:date_range_3m, css:div.prescription[@data-range = '3 month') the accessor want is: div(:date_range_3m, css: 'div.presc[date-range~="3"][date-range~="months"]') some notes changes/problems: the date-range="3 months" considered attribute space separated value list. these types of values, can compare against each of individual words. why suggested selector has [date-range~="3"][date-range~="months"] . note has problem match date-range="months 3" date-range="3 months other values" . the class value "presc" rather ...

head - Manipulate HTML page via PHP -

hello have included php file in end of html page. want add style file before end of tag head. need via php file, have no choice. i have , index.php file , @ end of file loading script.php need add script in header of index page using script.php folder structure: index.php script.php the index.php file have code: <!doctype html> <html> </head> <body> </body> </html> <?php include "script.php" ?> how can put in head of html/php when have script.php file @ end of page. there no direct way this. can think 2 nasty workarounds problem though: if script has buffering activated (called ob_start somewhere before head closed), string , clean wirh ob_get_clean, insert code , echo again. this: <?php $output = ob_get_clean(); $output = substr_replace($output, $your_code, strpos($output, '</head>'), 0); echo $output; ?> since modern browsers quite forgiving, can put style tags after...

delphi - Magento Import of tier prices with SOAP API V2 doesnt work -

hope here. try create tier prices in magento groups using soap api v2. using version 1.9.0.0 of magento developing delphi, using wsdl. what following, looping through tier prices of erp system: mycatalogproducttierpriceentity := catalogproducttierpriceentity.create; mycatalogproducttierpriceentity.customer_group_id := group_price_mage_group_id; mycatalogproducttierpriceentity.website := inttostr(website_id); mycatalogproducttierpriceentity.qty := round(winlineartikelstaffelmenge); mycatalogproducttierpriceentity.price := 2.85;//winlineartikelstaffelkundenpreis; mycatalogproducttierpriceentityarray[j] := mycatalogproducttierpriceentity; inc(j); mycatalogproducttierpriceentity := nil; finally assign price array product entity: mycatalogproductcreateentity.tier_price := mycatalogproducttierpriceentityarray; but prices wont show in magento admin, no error listed… either on creating product or updating it. other fields updated / created correctly. i made test , entered 2 gro...

ruby - (SOLVED) WEBrick SSL Script does not start Rails 4 -

hello have been following tutorial enable ssl certificates using webrick, rails 4 , rubymine http://www.networkworld.com/columnists/2007/090507-dr-internet.html the problem when fire script , visit https://localhost:3443 shows me list of files, know i'm doing wrong code :): #!/usr/local/bin/ruby require 'webrick' require 'webrick/https' require 'openssl' pkey = cert = cert_name = nil begin pkey = openssl::pkey::rsa.new(file.open('ssl/server.key').read) cert = openssl::x509::certificate.new(file.open('ssl/server.crt').read) end s=webrick::httpserver.new( :port => 3443, :logger => webrick::log::new($stderr, webrick::log::debug), :documentroot => "./public", :sslenable => true, :sslverifyclient => openssl::ssl::verify_none, :sslcertificate => cert, :sslprivatekey => pkey, :sslcertname => [ [ "cn",webrick::utils::getservername ] ] ) s.start

java - why the coordinates of a view is always Zero -

i created simple example know how can coordinates of given view . below attempts, , display 0.0 . idea why happens? code: private int [] tv1location = new int[2]; private int [] tv2location = new int[2]; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); rect tv1rect = new rect(); rect tv2rect = new rect(); tablelayout tl = (tablelayout) findviewbyid(r.id.tablelayout); textview tv1 = (textview) findviewbyid(r.id.tv1); textview tv2 = (textview) findviewbyid(r.id.tv2); tv1.getlocalvisiblerect(tv1rect); tv1.getlocationonscreen(tv1location); tv2.getlocalvisiblerect(tv1rect); tv2.getlocationonscreen(tv2location); tv1.settext("xcords: "+tv1.getx()+", ycords: "+tv1.gety()); tv2.settext("xcords: "+tv2.getx()+", ycords: "+tv2.gety()); //tv2.settext("xcords: "+tv2location[0]+", ycords: "+t...

ios - Positioning image of navigationBar backButton -

i add image navigation controller button this: self.navigationitem.backbarbuttonitem = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"itbutton.png"] style:uibarbuttonitemstylebordered target:nil action:nil]; it works fine, therefore, image not aligned < symbol. image little above symbol, want both centered. don't know why. i've tried adjust using: [self.navigationitem.backbarbuttonitem setimageinsets:uiedgeinsetsmake(10, 0, 0, 0)]; but nothing changed. there many ways fix issue, facing same issue have solved way -(void)viewwillappear:(bool)animated { [super viewwillappear:animated]; if([self.navigationcontroller.viewcontrollers objectatindex:0] != self) { uibutton *backbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 26, 26)]; [backbutton setimage:[uiimage imagenamed:@"home.png"] forstate:uicontrolstatenormal]; [backbutton setshowstouchwhenhighlighted:true]; [backbut...

php - Submit form to two places -

i have issue need simple contact form have action post data collection service, , thank page conversion tracking. the data collection service page not allow sort of redirection unfortunately, best bet submit both thank page, , data collection service. i don't know how to though... can please steer me in right direction? i've done lot of searching, can't work jquery or javascript. any advice / feedback / methods appreciated. per reply below, i'm trying ajax redirect after sends data collection service this, can't work: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> // shorthand $( document ).ready() $(function() { $("#ajaxform").submit(function(e) { var postdata = $(this).serializearray(); var formurl = $(this).attr("action"); $.ajax( { url : formurl, type: "post", data : postdata, su...

django - fabric and git ask me passphrase -

i'm using fabric automate deploy. if connect ssh production server: freelance@freelance:~$ cd /var/www/freelance/ freelance@freelance:/var/www/freelance$ git pull up-to-date. freelance@freelance:/var/www/freelance$ git pull up-to-date. freelance@freelance:/var/www/freelance$ whoami freelance git don't ask me (because have set keys on bitbucket). but if use fabric, works, ask me passphrase: (ve)bepxxx-3411:freelance d$ fab git_pull [peaidjosparino.cloudapp.net] executing task 'git_pull' [peaidjosparino.cloudapp.net] run: git pull [peaidjosparino.cloudapp.net] passphrase private key: [peaidjosparino.cloudapp.net] login password 'freelance': [peaidjosparino.cloudapp.net] out: up-to-date. [peaidjosparino.cloudapp.net] out: done. disconnecting peaidjosparino.cloudapp.net... done. the user same, server same. any ideas? update: uname -a (ve)bdxx-3411:freelance d$ fab test_prova [peaidjosparino.cloudapp.net] executing task 'test_prova...

ios - How is my code producing this crash: [NSConcreteData count]: unrecognized selector sent to instance -

i getting crash showing in bugsense: -[nsconcretedata count]: unrecognized selector sent instance 0x14e57f10 - nsinvalidargumentexception in code: + (nsmutablearray *)applyfilters:(nsmutablearray *)theitems fromfilter:(nsdictionary *)filters { nsmutablearray *items = [[nsmutablearray alloc] initwitharray:theitems]; if ([[filters allkeys] count] > 0) { nsmutablearray *tempfiltereditems = [[nsmutablearray alloc] init]; (nsstring *key in [filters allkeys]) { nsmutablestring *convertedkey = [nsmutablestring stringwithstring:key]; [convertedkey replaceoccurrencesofstring:@" " withstring:@"_" options:nscaseinsensitivesearch range:nsmakerange(0, [convertedkey length])]; nsarray *tempfilterattributes = [nsarray arraywitharray:filters[key]]; (ns...

Include file in excel to use in VBA -

i using code user browses specific file written text file. there way include file in excel file doesn't have located. file 4mb kml file. application.filedialog(msofiledialogopen).allowmultiselect = false intchoice = application.filedialog(msofiledialogopen).show if intchoice <> 0 newfile = application.filedialog( _ msofiledialogopen).selecteditems(1) end if set fs = createobject("scripting.filesystemobject") set f = fs.opentextfile(newfile) print #1, f.readall set f = nothing set fs = nothing hmm, microsoft says total number of characters cell can contain: 32,767 characters . read file line line - using readline in loop instead of readall - cells of hidden sheet, though formatting might lost. http://support.microsoft.com/kb/186118/en

architecture - How are user sessions/data stored on web servers? -

i'm starting web development in earnest, more static pages, , keep wondering, how data stored per user on server? when 1 user submits form post, , gets looked on page, how can server tell user1's fooform data user2's fooform data? know can keep track of users cookies , http requests, how server keep these data sets available? there tiny virtual machine each user session? or kind of paging system user's content served, , server swaps process out while system thread? i've wondered how site million concurrent visitors manages serve them , keep individual user sessions contained. i'm familiar os multithreaded architecture , algorithms, idea of doing anywhere 1 million separate "threads" on anywhere 1 n separate machines mind blowing. do algorithms change scale does? i'll stop before ask many questions , gets broad, i'd love expertise elucidate me, or point me resource. thanks reading.

jquery - Is there a way to animate display:none? -

i filtering divs based on selection dropdown menus, keeps divs selected value visible , else gets css attribute display:none; there way animate it's not such harsh transition? jquery $(function(){ $("#map-date, #map-type, #map-county").change(function (){ var filters = $(this).val(); $("div.map-thumb").css({"display":"none"}); $("div[class*='" + filters + "']").show(); }); }); haml .row#map-thumbnail-wrapper .medium-4.columns %select#map-type %option.filter{value: "all"} type of program - mapchoices['program'].each |program| %option.filter{value: program.downcase.gsub(' ', '-')}= link_to program, '#' .medium-4.columns %select#map-date %option.filter{value: "all"} date constructed - [*2007..date.today.year].each |year| %option.filter{value: year}= year .medium-4.column...

angularjs - $observe within an Angular directive is only firing on the first attribute change -

i'm trying write custom directive attribute directive observing seems change on initial scope change. after that, binding in view (observed firebug) doesn't update longer. seems scope problem i'm out of ideas. jsfiddle link showing code problem: http://jsfiddle.net/catalyst156/2gp78/ (contents of fiddle below, might useful mess around fiddle itself). controller: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js></script> <script> var myapp = angular.module('myapp', []); myapp.directive('testdirective', function () { return { restrict: 'a', replace: true, scope: { toggle: '@' }, link: function (scope, element, attrs) { console.log('...linking testdirective...'); attrs.$observe('toggle', function (value) { console.log('directive: toggle observer'); ...

android - Which method gives the exact coordinates as those given by GestureDetector -

i want develop app. can detect if user touches specific view , action happen. implemented simpleongesturelistener detect , listen users' touches across screen. problem is, below posted methods, give different coordinates of same view , not know 1 should use compare coordinates given simpleongesturelistener . methods give coordinates of views: tv1.getlocalvisiblerect(tv1rect); tv1.getlocationonscreen(tv1loconscreen); tv1.settext("xcords: "+tv1.getx()+", ycords: "+tv1.gety()); to find out if view contains point touched can use cgrectcontainspoint(your view frame, cgpoint of tap) you can cgpoint of tap gesture recognizer by cgpoint location = [recognizer locationinview: view recognizer attached to];

continuous integration - TeamCity cannot find rspec command -

i'm trying teamcity run tests on rails app, doesn't see rspec rspec: command not found i have created "command line" build step containing following: rspec spec/ if open terminal @ generated directory, after build step fails, can run tests without problem, suggests me it's i'm doing wrong in teamcity environment setup (as opposed project code). i believe problem is failing switch correct version of ruby (i'm using rvm ruby version management). demonstrate debugging i've done far, have changed "command line" build step following: echo '#do rspec spec/' rspec spec/ echo '#which rspec?' echo `which rspec` echo '#do bundle update' bundle update echo '#which ruby using?' echo `which ruby` echo '#which ruby want?' echo `more gemfile | grep "ruby "` echo '#which bundle using?' echo `which bundle` echo '#available rubies?'...

linux - how to remove only the duplication file under some directory ( with the same cksum ) -

i build following script in order remove files same cksum ( or content ) the problem script can remove files twice following example ( output ) my target remove duplication file , not source file , script output: starting: same: /tmp/file_inventury.out /tmp/file_inventury.out.1 remove: /tmp/file_inventury.out.1 same: /tmp/file_inventury.out.1 /tmp/file_inventury.out remove: /tmp/file_inventury.out same: /tmp/file_inventury.out.2 /tmp/file_inventury.out.3 remove: /tmp/file_inventury.out.3 same: /tmp/file_inventury.out.3 /tmp/file_inventury.out.2 remove: /tmp/file_inventury.out.2 same: /tmp/file_inventury.out.4 /tmp/file_inventury.out remove: /tmp/file_inventury.out done. . my script: #!/bin/bash dir="/tmp" echo "starting:" file1 in ${dir}/file_inventury.out*; file2 in ${dir}/file_inventury.out*; if [ $file1 != $file2 ]; diff "$file1" "$file2" 1>/dev/null ...

TYPE_CLASS_NUMBER input type on android scrolls ScrollView to it's right end. Why? -

i have horizontalscrollview, in have edittext. if don't set input type, works expected. however, if use type_class_number, scrolls right end when select it. why? how fix problem? text input has left gravity/justification , number input has right gravity/justification. you can override either in layout xml or programmatically. <edittext android:id="@+id/etnumbers" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="left" android:inputtype="number" android:hint="@string/et_number_hint"/> or edittext etnnumber = (edittext) findviewbyid(r.id.etnumbers); etnumber.setinputtype(inputtype.type_class_number); etnumber.setgravity(gravity.left); post existing implementation , can edit actual code solution.

rails favicon issues, negative route constraints -

when visit domain.com/favicon.ico 404's, localhost:3000/favicon.ico renders favicon successfully. i think it's catching on root parameter route because layout rendered differently generic 404 page when tried fake route /aliwejfl/aliwejf . get '/:nickname' => 'users#profile' i know can whitelist mime types in route constraints: constraints(format: 'html') # routes here end but there way blacklist? figured out when writing question. forgot regular expressions allowed. constraints(format: /(?!ico)/) # routes end that way get /not_favicon.ico 404.

ruby on rails - Reset PK number based on association -

i have post , comments table. post has many comments, , comment belongs post. i want have primary keys start @ 1 when create comment post , can access comments in rest-ful manner, e.g: /posts/1/comments/1 /posts/1/comments/2 /posts/2/comments/1 /posts/2/comments/2 how can achieve rails 3? using mysql database. bonus: using sequel orm; approach compatible sequel, not activerecord, awesome. well, can't use id this, id primary key here. can add field database table comment_number , make unique in scope of post: #migration def change add_column :comments, :comment_number, :integer, null: false add_index :comments, [:post_id, :comment_number], unique: true end #class class comment < activerecord::base belongs_to :post validates :post_id, presence: true validates :comment_number, uniqueness: { scope: :post_id } end now in place need ensure column populated: class comment < activerecord::base #... before_create :assign_comment_num...

c# - Regex split on parentheses getting double results -

im taking string "4 + 5 + ( 7 - 9 ) + 8" , trying split on parentheses list containing 4 + 5, (7-9), + 8. im using regex string below. giving me 4 + 5, (7-9), 7-9 , + 8. hoping easy. thanks. list<string> test = regex.split("4 + 5 + ( 7 - 9 ) + 8", @"(\(([^)]+)\))").tolist(); remove set of parenthesis have in regex: (\(([^)]+)\)) // regex ( ) // outer parens \( \) // literal parens match ( ) // parens don't need [^)]+ // 1 or more 'not right parens' the parens create match 'inside literal parens', 7 - 9 see. so should have: @"(\([^)]+\))"

php - Firebase .on not working with authentication -

update i able @ least client side code work authentication using firebase-simple-login.js , auth.login('anonymous') . server side (ie "write") still not work. original question i creating app firebase integration , need secure firebase data. being able delete if know firebase url , without authentication less ideal. i not trying log users in (or @ least not in traditional sense), want make sure there sort of authentication going on when read , write firebase data. have spent hours on , cannot seem make work (so "easy"). first, firebase security rules - simple { "rules": { ".read" : "auth != null", ".write": "auth != null" } } i pushing firebase server side code , reading results client side. simple polling app - poll responses pushed firebase in following format: clients\clienta\polls\pollid(random)\randomdataid(from firebase)\response data . using firebase/php-jwt gen...

vb.net - Namespace conflicts in Asp.net MVC -

i long-time semi-professional asp.net programmer has made leap asp.net forms environment mvc. in process of re-developing 1 of web apps exists in forms mvc, , liking mvc environment , glad making leap. but...am encountering issues, 1 namespaces. so let's imagine following: 1) create new mvc 4 project called mymvcproject 2) create app_code folder , add new class1.vb file follows: namespace mynamespace public class class1 property myproperty string end class end namespace ok far good. want access class in controller or follows: imports mynamespace public class default1controller inherits system.web.mvc.controller function index() actionresult dim obj new class1 return view() end function end class in asp.net forms environment, go. however, in mvc project unable import "mynamespace" , therefore unable create class1. go looking , find following in object browser: >[other references...] v[vb] mymvcproject ...

c - GCC generating useless code in ISR -

i have simple interrupt service routine(isr) written atmega328 , compiled avrgcc (using -os) using avr studio. isr (timer0_ovf_vect) { txofcnt++; //count overflows , store in uint16_t } if note assembly generated (below), uses r24, r25 job incrementing volatile uint16_t txofcnt, push-write-pop r1, r28, r29 without ever reading them. has push/pop of r0 without ever using in between. i flat out don't understand why r1 pushed, cleared , poped. why gcc feel need load eimsk , gpior0 registers , not use them. bonus points if can tell me gpior0 for, datasheet says exists has no description. 00000258 <__vector_16>: isr (timer0_ovf_vect) { 258: 1f 92 push r1 25a: 0f 92 push r0 25c: 00 90 5f 00 lds r0, 0x005f 260: 0f 92 push r0 262: 11 24 eor r1, r1 264: 8f 93 push r24 266: 9f 93 push r25 268: cf 93 push r28 26a: df 93 push r29 26c:...

javascript - Using jQuery to append as sibling rather than child element -

i can't seem find functionality i'm looking for. need append dom elements, siblings, disconnected node. seems pretty straight forward, , according jquery documentation should able either .after() or .add(), neither word: var $set = $('<div class="parent"></div>'); $set.add('<div class="child"></div>'); $set.add('<div class="child"></div>'); $set.add('<div class="child"></div>'); $('body').append($set); http://jsfiddle.net/kh9uj/17/ , http://jsfiddle.net/kh9uj/19/ it works if chain them using .add(): $('<div class="parent"></div>') .add('<div class="child"></div>') .add('<div class="child"></div>') .add('<div class="child"></div>') .appendto('body'); http://jsfiddle.net/kh9uj/23/ but n...

MongoDB - admin user not authorized -

i trying add authorization mongodb. doing on linux mongodb 2.6.1. mongod.conf file in old compatibility format (this how came installation). 1) created admin user described here in (3) http://docs.mongodb.org/manual/tutorial/add-user-administrator/ 2) edited mongod.conf uncommenting line auth = true 3) rebooted mongod service , tried login with: /usr/bin/mongo localhost:27017/admin -u sa -p pwd 4) can connect says upon connect. mongodb shell version: 2.6.1 connecting to: localhost:27017/admin welcome mongodb shell! current date/time is: thu may 29 2014 17:47:16 gmt-0400 (edt) error while trying show server startup warnings: not authorized on admin execute command { getlog: "startupwarnings" } 5) seems sa user created has no permissions @ all. root@test02:~# mc mongodb shell version: 2.6.1 connecting to: localhost:27017/admin welcome mongodb shell! current date/time is: thu may 29 2014 17:57:03 gmt-0400 (edt) error while trying show server startu...

c++ - OpenSSL EVP_DigestSignFinal segfault -

i'm trying sign message using openssl c api. following code segfaults because of exc_bad_access during either of calls evp_digestsignfinal . i'm using openssl 1.0.1g. tried switching newer digestsign* functions older sign* functions, , still segfaults. private_key set evp_pkey_set1_rsa rsa key loaded pem file. first call evp_digestsignfinal fills s_len maximum possible length of signature signing algorithm, signature not being big enough shouldn't issue, , second call writes signature buffer , fills s_len length of signature. i appreciate this. vector<unsigned char> rsa_sha512_sign( const vector<unsigned char>& document, shared_ptr<evp_pkey> private_key) { evp_md_ctx* md; if (!(md = evp_md_ctx_create())) { throw runtime_error("error initializing env_md_ctx."); } if (evp_digestsigninit(md, null, evp_sha512(), null, private_key.get()) != 1) { throw runtime_err...

java - hibernate update only some fields -

in cases want update 1 collumn, don't want object data base , have it's id , value want update. as other values null, hibernate updating null. wonder criteria erase other columns update. i read dynamic-update=true , exclude unmodified properties. nulls still there @ update. does have idea? thanks! felipe you have object database, change value , save it. if don't want that, have write own query.

html - Align Bootstrap 3 Navbar-right and include search box also right-aligned -

i'm using bootstrap 3 build site , having following problem: the site design working has right-aligned navigation should include search bar following final link. here's visual: http://imgur.com/eevc0is i can seem make work if keep navigation left aligned after logo. can't navigation , search bar in nice right-aligned line. i have same have now, search bar on other side. here's code: <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-b...

python - Django redirect on error to main home page or app root -

i'm trying not hardcode url of app in view (really controller) of app. code looks this: event/view.py def index(request): try: //do stuff response return render(request, 'rma/service.html', response) except: return redirect("/rma") in case app installed on web server under /var/www/html/rma. in production (or anywhere else) installed @ subdirectory or html/ how can redirect main page because if specific page fails main page display better logic of what's going on (sources missing in db, table not imported, etc.) i'd like: return redirect(<magic>.main.index) or like: return redirect(app_root) all example found redirecting inside html (the template) rather in code in view.py any ideas? have tried? return httpresponseredirect("/")

git - Revert changes to a specific file from a specific commit -

a few weeks ago (i.e. many commits ago), made git commit touched many files. of commit great. however, i'd undo changes i'd made 1 of files, don't want override changes had been made file after commit. is there way me revert specific commit on 1 of files in commit? get patch-ready diff file in commit, , reverse-apply patch: git show <commit-id> -- <path> | git apply -r - make sure result, , if so, add , commit appropriate message.

python exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in -

i using scrapy python , have code in python item pipline def process_item(self, item, spider): import pdb; pdb.set_trace() id = str(uuid.uuid5(uuid.namespace_dns, item['link'])) i got error : traceback (most recent call last): file "c:\python27\lib\site-packages\scrapy-0.20.2-py2.7.egg\scrapy\mid dleware.py", line 62, in _process_chain return process_chain(self.methods[methodname], obj, *args) file "c:\python27\lib\site-packages\scrapy-0.20.2-py2.7.egg\scrapy\uti ls\defer.py", line 65, in process_chain d.callback(input) file "c:\python27\lib\site-packages\twisted\internet\defer.py", line 3 82, in callback self._startruncallbacks(result) file "c:\python27\lib\site-packages\twisted\internet\defer.py", line 4 90, in _startruncallbacks self._runcallbacks() --- <exception caught here> --- file "...

MySQL Generate unique identifier before insert -

i writing program logs packets of data mysql database. the program forwards these packets , speed absolutely critical. want able forward these packets posible. logging database done in background batch inserts of queued packets. i don't want wait database write packets disc before forwarding them, need way of identifing individual packets. how can this? basicaly need generate unique identifier each packet without using auto_increment have wait database then. the unique thing individual packets time in came in, using time identifer seems bad idea (for example if time gets set backwards ntp/user/leapsecond/etc...) is there way? can reserve unique identifers database without needing go disc?

c# - Why 8bytes plaintext becomes 16bytes Cipher? -

Image
its simple code. don't understand, when blocksize 8byte, cipher size 16bytes, why? expecting same blocksize . simple thinking, give 64bits plaintext , expect have 64bits cipher. , don't see reason padding here. seems after every 8bytes( blocksize ) cipher becomes 8bytes more. 16bytes block becomes 24bytes cipher etc. why this? want know. and curiosity, there possibility/way have 8bytes cipher 8bytes block? the 3des code: (only encryption part) static void main(string[] args) { console.writeline("enter plain text: "); string original =console.readline(); tripledescryptoserviceprovider mytripledes = new tripledescryptoserviceprovider(); byte[] encrypted = encryptstringtobytes(original,mytripledes.key, mytripledes.iv); string encrypt = convert.tobase64string(encrypted); string decrypted = decryptstringfrombytes(encrypted,mytripledes.key, mytripledes.iv); console.writeline("encryted: " +enc...

bash - delete .git directory. locked and permission denied -

i have tmp .git files can't remove no matter try. i've tried chmod , rm terminal: chmod a+wx zzz_delete/ seth-laptop:lepton_master seth_mac$ sudo rm -rf zzz_delete/ rm: zzz_delete//.git/objects/tmp_object_git2_a03228: permission denied i ran bash script force chmod: chmod: unable change file mode on /zzz_delete/.git/objects/tmp_object_git2_a03228: operation not permitted i tried delete windows machine. permission denied. how can change permissions , remove tricky folder? it exists special attribute not allow root delete file. try see if immutable bit set on file with: lsattr /zzz_delete/.git/objects/tmp_object_git2_a03228 if answers like ----i-------- tmp_object_git2_a03228 gotcha! have unset before removing: sudo chattr -i nomefile what immutable bit : immutable bit can used prevent accidentally deleting or overwriting file must protected. prevents creating hard link file. see chattr(1) man page i...

(IOS) When i want to make a button disable in a cell, its make many other disable -

i making ios app. issue when want make button disable in cell, make many other disable. try many issue don't know why. tag of button ok, think don't use sender correctly. code : - (ibaction) fiyeitpressed:(uibutton*)sender { uibutton *fiyeitbutton = (uibutton*) sender; [fiyeitbutton setenabled:no]; nslog(@"%d",[fiyeitbutton tag]); nsstring *fiyenumberstring = [playlistvote objectatindex:sender.tag]; int fiyeint = [fiyenumberstring intvalue] + 1; fiyenumberstring = [nsstring stringwithformat:@"%d",fiyeint]; [playlistvote replaceobjectatindex:sender.tag withobject:fiyenumberstring]; [self savefortable]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; playlisttableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; cell.songname.text = [playlistso...

javascript - How should I structure my nested data for this D3.js chart? -

Image
after reading quite few d3.js tutorials, i'm still uncertain best way structure data when there several nested levels. example, have bunch of categories. each category, have 2 years worth of data, aggregated monthly. so, this: {"cat1": {"2012":[{"start_data":[1,2,3,...]},{"end_data":[4,5,6,...]}], "2013":[{"start_data":[1,2,3,...]},{"end_data":[4,5,6,...]}]}, "cat2": {"2012":[{"start_data":[1,2,3,...]},{"end_data":[4,5,6,...]}], "2013":[{"start_data":[1,2,3,...]},{"end_data":[4,5,6,...]}]}, ... } every array start_data or end_data has 12 items -- 1 each month. i create interactive chart looks this: since mockup terrible... going on want user able select year (or aggregate), whether viewing start_data values or end_data values (or aggregate, neglected put on mockup), , category. the structu...

c++ - Beginner in OpenMP - Problems in cicle -

i beginner in openmp , trying parallelize following function: void calc(double *x, int *l[n], int d[n], double *z){ #pragma omp parallel for(int i=0; i<n; i++){ double tmp = d[i]>0 ? ((double) z[i] / d[i]) : ((double) z[i] / n); for(int j=0; j<d[i]; j++) x[l[i][j]] += tmp; } } but n=100000 sequential time 50 seconds , 2 or more threads goes several minutes. the l array of pointers has randomly between 1 , 30 elements (given corresponding position in d array) , elements varies between 0 , n, know have load-balance problem if had guided or dynamic scheduling (even auto) times worse. i know problem in accesses x array because not being contiguously acceded there way fix problem , have kind of speedups in function? thanks in advance! assuming can afford use space it, can speed up. the basic idea create separate array of sums each thread, when they're done add corresponding elements in separate copies, , add ...

Translating Matlab (Octave) group coloring code into python (numpy, pyplot) -

i want translate following group coloring octave function python , use pyplot . function input: x - data matrix (m x n) a - parameter. index - vector of size "m" values in range [: a] (for example if = 4, index can [random.choice(range(4)) in range(m)] the values in "index" indicate number of group "m"th data point belongs to. function should plot data points x , color them in different colors (number of different colors "a"). the function in octave: p = hsv(a); % x 3 metrix colors = p(index, :); % ****this m x 3 metrix**** scatter(x(:,1), x(:,2), 10, colors); i couldn't find function hsv in python, wrote myself (i think did..): p = colors.hsv_to_rgb(numpy.column_stack(( numpy.linspace(0, 1, a), numpy.ones((a ,2)) )) ) but can't figure out how matrix selection p(index, :) in python (numpy). specially because size of "index" bigger "a". thanks in advance help. so, want take m ...

javascript - Working with express.io in a separate router file -

i'm trying use router , socket.io together. i've created separate router file , try conjunct route , socket.io app = require('express.io')(); //var app = express(); //var router = express.router(); app.http().io(); var mysql = require('mysql'); var connection = mysql.createconnection({ host :'aaaa', port : 3306, user : 'bbbb', password : 'cccc', database:'dddd' }); connection.connect(function(err) { if (err) { console.error('mysql connection error'); console.error(err); throw err; } }); /* home page. */ app.get('/', function(req, res) { var query = connection.query('select * xe_livexe_rss limit 0,1',function(err,rows){ console.log(rows); //res.json(rows); res.render('index', { title: 'express',rss:rows }); req.io.route('ready'); }); }); app.io.route('ready...