Posts

Showing posts from January, 2010

excel - What is the difference between PivotTable.RefreshTable and PivotTable.Update? -

what difference between methods pivottable.refreshtable , pivottable.update ? i have been googleling , haven't figured out if pivottable.refreshtable enough update pivottable or if pivottable.update significant. update merely updates layout - doesn't refresh data.

Capturing name in source page using xpath in python -

i have following url source page: <input type="hidden" name="qqq" value="aaa" /> <input type="hidden" name="www" value="bbb" /> <input type="hidden" name="eee" value="ccc" /> <input type="hidden" name="wanted" value="ddd" /> i want extract wanted value ddd that. tried is: token=tree.xpath('//input[@type="hidden"]/input[@value="ddd"]/@name') but gives me qqq try xpath: //input[@type='hidden'][@value='ddd']/@name

c++ - No time reported -

i've got c++ program implements gaussian elimination. compiles , runs ok in calculation part, before it's supposed tell time spent on calculation crashes segfault. #include <iostream> #include <time.h> #include <omp.h> #include <vector> #include <cstdlib> using namespace std; int main() { const unsigned int n = 10; // initialize random seed: srand (time(null)); vector<vector <double> > a(n, vector<double>(n+1)) ; double buf; vector<double> x(n); unsigned int i,j,k; clock_t t; t = clock(); double prectime=omp_get_wtime(); //#pragma omp parallel shared() private() num_threads() //matrix , right-side vector initialisation for(i = 0; < n; i++) { for(j = 0; j < n+1; j++) { a[i][j]=(1+rand() % 100)/25.0; //cout << "a[" << << "][" << j <<"] = " <<

AngularJS: Check user role to decide if user have permission to view pages or not -

i have problem authentication mechanism. have call api current user roles, check decide user can view pages of app. idea: call api in myapp.run block , check: angular.module('myapp') .run(['$rootscope', 'authenservice', '$location', function($rootscope, authenservice, $location) { var currentuser; function checkrole() { if(angular.isdefined(currentuser) && angular.isobject(currentuser) && ... && currentuser.isadmin && $location.url() === '/dashboard') { return true; } return false; } /* ** @name: getcurrentuser ** @description: current user info, use promise $q */ authenservice.getcurrentuser() .then(function getsuccess(currentuserinfo){ currentuser = currentuserinfo; //if user not admin , current page not dashboard page, redirect dashboard page if(!checkrole()) { $location.path('/dashboard'); }

javascript - NodeJS download csv file to buffer -

i'm tying download small csv , need store in variable before process: var http = require('http'); var csvdata; var request = http.get('http://url', function(response) { response.pipe(csvdata); }); request.end(); response.pipe() works file stream, how can store response csvdata var? just create listener data , end events: var http = require('http'); var csvdata = ''; var request = http.get('http://url', function(response) { response.on('data', function(chunk) { csvdata += chunk; }); response.on('end', function() { // prints full csv file console.log(csvdata); }); });

Does mysql latin1 also support emoji character? -

now because below phenomenon feel totally not understand character set. @ first think utf8mb4 support emoji character e.g. 😀. see below: as of mysql 5.5.3, utf8mb4 character set uses maximum of 4 bytes per character supports supplemental characters but accidentally found phenomenon,see below: mysql> show variables 'character%'; +--------------------------+---------------------------------------+ | variable_name | value | +--------------------------+---------------------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | utf8mb4 | | character_set_system

xamarin.forms - Xamarin Forms timepicker 24hour -

i'm new xamarin.forms , can't seems find how show dialog in 24hour format instead of am/pm can me ? thank you this page usefull learn how format dates in c#: https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx and code able show 24 hour format: timepicker timepicker = new timepicker { format = "hh:mm" };

ios - Get text from text field on Table cell -

i have custom cell uitextfield . should set delegate , in custom cell class or in view's class ? i trying in both, no results. set delegate storyboard. here did: -(void)textviewshouldreturn:(uitextfield *)textfield { if ([textfield.text isequaltostring:@""]){ return; } uialertview *helloearthinputalert = [[uialertview alloc] initwithtitle:@"name!" message:[nsstring stringwithformat:@"message: %@", textfield.text] delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [helloearthinputalert show]; } but part working if put cell.notetextfield.delegate=self : -(bool)textfieldshouldbeginediting:(uitextfield *)textfield{ self.tableview.frame=cgrectmake(self.tableview.frame.origin.x, self.tableview.frame.origin.y-30, self.tableview.frame.size.width, self.tableview.frame.size.height); return yes; } add

sharepoint - System center service manager Web portal -

Image
i going install "system center service manager web portal" , there 2 option 1- web content server. 2-sharepoint web part. if install web content server, provide me web console or not ? and benefit integrate sharepoint ? in self service portal components web parts. if don't install second option don't able see self service portal forms , views.

javascript - How to Create a Customized Search Function for Shortcut -

Image
goal: when click on button icon reading-glass a, text field should entering right left. after have pressed button, cursor should located in text field , ready retrieve input data , color frame around button instance yellow should appear. when use curser outside of text field , suddently press left button of mouse, text field , yellow color around button should disappear. problem: not how create it. info: *i'm using bootstrap , jquery. *today, not have available sourcecode. what need 2 actions on button: show input field fire form the code below that. input have 0 width on page load. jquery functions binds click event on button. when it's clicked if input field has width. when not, prevent default action (submitting form), , instead animates input width of 200px. after focuses on field. the second time click on button, input won't have 0 width, buttons acts normal , submit form. hope suits you. $(function() { $('#sea

python - Does django need to set TEST_RUNNER first to run doctest? -

i started deadly simple django project try django's doctest: # models.py """ >>> 1+1 == 2 true """ and run python manage.py test get: creating test database alias 'default'... ---------------------------------------------------------------------- ran 0 tests in 0.000s ok destroying test database alias 'default'... same running python manage.py play . i fixed setting: installed_apps = ( ... 'django_nose', ) test_runner = 'django_nose.nosetestsuiterunner' nose_args = ['--with-doctest'] my question whether setting needed or not? cause it's not mentioned in doc: https://docs.djangoproject.com/en/1.4/topics/testing/ my django version 1.7, difference between 1.4 , 1.7? since 1.6, doctests no longer automatically discovered django. you'll find more on how integrate doctests in 1.6 release documentation .

Microsoft Access report shows empty row at the end -

i have access report. problem display empty row @ end. in query there no empty values report shows empty row. ideas? https://drive.google.com/file/d/0b5xfogik1wswumrkrktla2viynm/view?usp=sharing https://drive.google.com/file/d/0b5xfogik1wswcff3snzpekvwtlu/view?usp=sharing on form set "allow additions" false. don't know on report. a report has onnodata event use cancel opening of report. used popup message "the report, specified parameters, return no data." code popup message, run docmd.cancel, or me.close acreport, me.name. you can base report on query has allowupdates set false (in qbe, set properties). idea render report in preview mode.

Proxy HTTPS with HTTP in Node.js express -

i wrote express app http proxy, intercept , analyse of network traffic. parts of traffic app interested in http, still want app proxy https users can use without setting. my express app created http server. when testing, changed proxy setting in chrome switchyomega, proxy https connections http. http works well, express app couldn't these proxy requests https. so wrote simple tcp proxy check on them, , find they're this: connect hostname:443 http/1.1 host: hostname proxy-connection: keep-alive user-agent: my_agent encrypted https i believe these requests http, why express isn't receiving them? for sure if change browser proxy setting ignore https, app works well. want know if there workaround can use proxy protocols http , 1 port. thx. update- code express app app.use('*', function (req, res, next) { // print request app receive console.log('received:', req.url) }) app.use(bodyparser.text({type: '*/*'})) app.use(cookiepa

gwt - change font of gwtbootstrap3 app -

i'm using gwtbootstrap3 app , want change font of app, want this: body{ font-family:tahoma; } i tried customise widget, have fo widgets , don't think it's optimal. how can that? this might 1 of infrequent cases want use !important , i.e.: body{ font-family:tahoma !important; } before do, however, read when using !important right choice .

Clojure: Rename and select keys from map with one iteration -

in clojure, want both rename-keys , select-keys map. simple way of doing with: (-> m (rename-keys new-names) (select-keys (vals new-names))) but itetate on entire map twice. there way 1 iteration? sure, there way single iteration. you using reduce-kv function : (reduce-kv #(assoc %1 %3 (get m %2)) {} new-names) or loop: (into {} (for [[k v] new-names] [v (get m k)])) if want simple piece of code, use fmap function algo.generic library : (fmap m (map-invert new-names))

c# - Flush the buffer after receiving packets -

this question has answer here: socket tcp c# how clear input buffer? 2 answers i using below code receiving tcp packets tool. while(socket.connected) { var buffer = new byte[4096]; int receivelength = socket.receive(buffer); if (receivelength != 0) { byte[] response= new byte[4096]; processpacketdata(buffer, out response); socket.send(resposne); } //sleep(100); } when using code, problem facing is,for socket.receive() function buffer doesn't getting flushed. every time, when calling socket.receive(buffer), new data packets getting appended old packets contained in buffer. want avoid situation. there solution this? receive not receive packets. receives amount of bytes greater 0 bytes. use return value receivelength find out how received , process amount.

how php function preg_match_all outputs matches array -

<?php // \\2 example of backreferencing. tells pcre // must match second set of parentheses in regular expression // itself, ([\w]+) in case. backslash // required because string in double quotes. $html = "<b>bold text</b><a href=howdy.html>click me</a>"; preg_match_all("/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/", $html, $matches, preg_set_order); foreach ($matches $val) { echo "matched: " . $val[0] . "\n"; echo "part 1: " . $val[1] . "\n"; echo "part 2: " . $val[2] . "\n"; echo "part 3: " . $val[3] . "\n"; echo "part 4: " . $val[4] . "\n\n"; } ?> in example first finds matches using pattern , put them inside matches array. not understand how finds parts(val[0],val[1],......)(basically no idea part) quite simple: index 0 holds entire string matched and, 1 n, have various capturing groups defined.

Conditional query in ElasticSearch? -

i'm relatively new elasticsearch , need advice. after several tries, did not found solution , that's why need you. i want make conditional query based on document content. let me explain, have documents in es: { "name": "product n°1", "type": "mail", "sub": "letter" }, { "name": "product n°2", "type": "video", "sub": null }, { "name": "product n°3", "type": "mail", "sub": "postcard" } the user can filter types , sub checkboxes (so, user can search more 1 type , sub @ same time) edited customers can selects checkbox types of products want es (for ex: video, image, mail), can select of them. the "document" type has 4 sub-types: letter, postal card, paper, printed , can select sub type want retrieve too. so, admit customer selected video , mail, , letter sub

ios - compiler error `FacebookSDK/FacebookSDK.h' file not found` (Facebook api graph 2 + Parse.com) -

the sdk (v 4.0) no longer 1 framework named "facebooksdk", rather few different packages naming convention of "fbsdktypekit", types different things core , login. i'm using parse.com sdk handle users facebook login. now, when installed new facebook sdk (4.0) , parse.com sdk well, compiler error facebooksdk/facebooksdk.h' file not found . guess parse.com sdk not updated work new facebook sdk in 100%, maybe can tell me if there , solution situation?

java - Glassfish/JVM production configuration -

i found article (besides many other): https://open.bekk.no/glassfish-production-tuning i want know if these settings fine , else need change/add or have careful of (glassfish , jvm settings)? have been using default settings during development , don't know if these setting ok... as mentioned in comments tuning of jvm , memory complicated topic. the server performance depends lot on technologies , libraries use , how use them. e.g. use database? , if, how connect , access db... mention few impact factors... from expierence can more memory will not protect web application failure if have memory leaks caused e.g. open db connections or growing session size after time in production. i not know kind of application , technologies use, give general aproach... approach find values jvm , glassfish: i recommend run load test e.g. jmeter , monitor garbage collection , memory usage of application. also check size of user sessions in glassfish during tests time time

swagger ui - Customising the index.html file? -

i've been messing around spring boot , pointed @ swagger way of documenting rest api. i managed working except can't figure out how customise index.html file. whenever go http://localhost:8080/index.html loads default pet store search bar 1 , not 1 customised. i've gone through tonne of pages online , tried hundred things nothing has worked. any appreciated. in swagger index.html code have looks this: $(function () { var url = window.location.search.match(/url=([^&]+)/); var patharray = location.href.split( '/' ); var protocol = patharray[0]; var host = patharray[2]; var base = protocol + '//' + host; if (url && url.length > 1) { url = url[1]; } else { url = base + "/api-docs"; } window.swaggerui = new swaggerui({ url: url, ... this loads base, json code swagger api @ /api-docs might understand.

How to ensure MySQL replication is accurate? -

i've used replication sql database. when compare table sizes differ slightly. find odd contain same number of rows. i've read due slave server being more optimized great. makes difficult know if has gone wrong. would checking slave periodically with show slave status\g be enough check if there inconsistencies? show if there error or if 1 of main threads had stopped. i thought check database size with select table_schema "data base name", sum( data_length + index_length ) / 1024 / 1024 "data base size in mb", sum( data_free )/ 1024 / 1024 "free space in mb" information_schema.tables group table_schema ; is there easier way of checking slave identical master? to check data integrity use percona's pt-table-checksum verify data integrity. pt-table-checksum performs online replication consistency check executing checksum queries on master, produces different results on replicas inconsistent master. optional ds

xml - Working out parent element name -

i have following xml fragment <view> <file> <name>somefile_name</name> </file> </view> <view> <view> <directory> <name>somedirectory_name</name> </directory> </view> <view> <pipe> <name>somepipe_name</name> </pipe> </view> and following xslt template <xsl:template match="view" mode="view_mode" > <xsl:if test=".//name" > <data name="objectname"> <xsl:atribute name="value"> <!-- prefix object name type per directory:somedirectory_name. each use of name() have tried results in matching view element. xpath can use gain name element's parent element name ie 'file', 'pipe', or 'directory' --> <xsl:value-of select=".//name" /> </xsl:atribute>

tsql - I am using SQL Server 2005 facing multiple rows displaying error -

here's table1 structure mrno ipno plno 1 2 1324 2 3 1325 3 4 1326 table2 structure mrno ipno plno plndt plntm 1 2 1324 20140430 13:24 1 2 1324 20140430 15:12 1 2 1324 20150501 12:01 1 2 1324 20150501 16:01 1 2 1324 20150501 17:21 1 2 1324 20150502 10:11 1 2 1324 20150502 13:01 1 2 1324 20150502 15:13 here's required output show data follows mrno ipno 30th_plntm_data 01st_plntm_data 02nd_plntm_data 1 2 13:24 12:01 10:11 1 2 15:12 16:01 13:01 1 2 17:21 15:13 sql code: select mrno, ipno, 30th_plntm_data.plntm, 01st_plntm_data.plntm, 02nd_plntm_data.plntm table1 t1 left join table2 30th_plntm_data on 30th_plntm_data.plno = t1.plno , 30th_plntm_

regex - Match a pattern in vim, not in the beginning of line -

i trying search pattern in vim, pattern must not in beginning of line, aka first non white space character of line, indentation purpose. eg. : should() not found this() should() found using /should , both should pattern found. i've tried use like, "not start of line" , not working : /[^^] *should . i've made work using : /\w.* *should , not ideal. use \zs set start of match after non-blank character followed blanks: /\s\s*\zsshould

Android volley library, where to use and where not to -

as our typical old asynctask network connection getting replaced volley. it's fast have used know. downloaded images , showed. when again restarted app didn't take time download. caching images sometime ? , recommended not use in heavy download, reason ? or reason keeps images , in memory ? saw i/o video of volley. need clear explanation. thanks i use volley get, post api calls because volley holds responses in memory during parsing. large download operations, consider using alternative downloadmanager . source: https://developer.android.com/training/volley/index.html

ActiveMQ: how to programmatically monitor embedded broker -

i want monitor embedded activemq 5.8 broker inside code. how can done? do need jmx connection? want prevent exposing jmx is there way of accessing org.apache.activemq.broker.jmx beans without jmx? are there hooks, listeners, events, ... can attached broker itself? if bad idea, why? you can access standard jmx mbeans within process has embedded broker without creating jmx connector expose them outside world. first need tell embedded broker enable jmx not create connector. brokerservice = new brokerservice(); brokerservice.setpersistent(false); brokerservice.setadvisorysupport(false); brokerservice.setschedulersupport(true); brokerservice.setpopulatejmsxuserid(true); brokerservice.setschedulersupport(true); brokerservice.getmanagementcontext().setcreateconnector(false); then in code can access jms mbeans normal instance brokerviewmbean: protected brokerviewmbean getproxytobroker() throws malformedobjectnameexception, jmsexception

sql - Postgres Join Query is SOMETIMES taking the cartesian product -

Image
i'm attempting join multiple tables 1 query , getting inconsistent results database, believe query taking cartesian product of users, when want users in directconversation. the schema reference: the query (where $id stands variable user.id): select c.*, count(dm.id), u1.first_name, u1.last_name, u1.company, u1.picture, u2.first_name, u2.last_name, u2.company, u2.picture "directconversation" c, "directmessage" dm, "profile" u1, "profile" u2 u1."id_user" = c."id_user1" , u2."id_user" = c."id_user2" , c.id = dm."id_directconversation" , dm.viewed = 'f' , dm.deleted = 'f' , c."id_user1" = $id or c."id_user2" = $id group c.id, u1.id, u2.id; the expected result (the result when user id = 1 ): id | id_user1 | id_user2 | count | first_name | last_name | company | picture

css3 - matchmedia polyfill implement -

how , why polyfill can work? w.matchmedia = w.matchmedia || (function( doc, undefined ) { var bool, docelem = doc.documentelement, refnode = docelem.firstelementchild || docelem.firstchild, // fakebody required <ff4 when executed in <head> fakebody = doc.createelement( "body" ), div = doc.createelement( "div" ); div.id = "mq-test-1"; div.style.csstext = "position:absolute;top:-100em"; fakebody.style.background = "none"; fakebody.appendchild(div); return function(q){ div.innerhtml = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>"; docelem.insertbefore( fakebody, refnode ); bool = div.offsetwidth === 42; docelem.removechild( fakebody ); return { matches: bool,

How to install MySQL WorkBench in Debian wheezy Operating System? -

i tried install mysql workbench in debian operating system using workbench linux distribution, not working. sudo apt-get install mysql-workbench this install mysql workbench on debian. both wheezy , jessie. works on ubuntu.

android - Can i do soft coding in selenium webdriver using java? -

so here's problem have write driver.find() method every element cannot iterated , of course on every page elements change.so question is, there way can soft code test rather hard coding becomes difficult make changes.is there way can parameters or values or xpaths etc table libreoffice. here part of current implementation: driver.findelement(by.xpath("//a[contains(.,'modules')]")).click(); driver.findelement(by.xpath("//a[contains(.,'sales module')]")).click(); driver.findelement(by.partiallinktext("file")).click(); driver.findelement(by.xpath("//a[contains(.,'new')]")).click(); driver.findelement(by.partiallinktext("enquiry")).click(); driver.findelement(by.xpath("//a[contains(.,'domestic')]")).click(); if(driver.findelement(by.xpath("//div[contains(.,'sales enquiry form')]"))!=null){ system.out.println("success"); } else{ system.out.prin

scrollbar - Default javafx tableview scroll bar position -

Image
i having tableview @ .fxml file below, <tableview fx:id="tblviewer" prefheight="340.0" prefwidth="800.0" styleclass="tableview" stylesheets="@clsmain.css" /> i have select box of tables. when selecting table data columns populated tableview. if columns more, tableview automatically render horizontal scroll bar same vertical scroll bar. problem when scroll right end , if changing dropdown selection not let me go left side. , of columns truncated left. showing in image. if have solution me out please. kind regards. updated: here binding tableview , data private void initclstable() { system.out.println("in inintclstable"); bindings.bindcontentbidirectional(tblviewer.getcolumns(), getviewmodel().getcolumnlist()); bindings.bindcontentbidirectional(tblviewer.getitems(), getviewmodel().getdatalist()); } here selection taken place: (when us

javascript - how to post multiple requests using angular.js -

i working on dynamic form in angular data can multiple paths other data on save, needs send multiple post requests server. possible in angular? here html , <fieldset class="form-group pl-sm" ng-repeat="file in files"> <div> <input type="text" class="form-control" autocomplete="off" name="filelocation" ng-model="file.name"> </div> <input type="checkbox" class="switch-input" name="" ng-model="file.xxxx" /> <input type="checkbox" class="switch-input" name="" ng-model="file.yyyy" /> <div class="col-sm-3"> <select class="form-control" name="filecenters" ng-model="file.centers" required> <option value="development">development</option> <o

python - Locating the largest three-digit product - which is also a plaindrome -

def reverseinteger(x): x_string = str(x) x_list = list(x_string) x_reversedlist = reversed(x_list) x_reversedstring = "".join(x_reversedlist) x_reversed = int(x_reversedstring) return x_reversed def paliproduct(i1, i2): while i1 < 1000 , i2 < 1000: product = i1 * i2 i1 += 1 i2 += 1 if product == reverseinteger(product): return product print(paliproduct(100, 100)) i using python (which obvious)... question why shell did not try possible values of i1 i2 (100-999) , broke after conducting 1 round 100 , 100... it returns finds palindrome because tell using return : if product == reverseinteger(product): return product if want find of palindromes need modify how paliproduct function works: def paliproduct(i1, i2): palindromes = [] while i1 < 1000 , i2 < 1000: pro

string - Want to convert text file of complex numbers to a list of numbers in Python -

i have text file of complex numbers called output.txt in form: [-3.74483279909056 + 2.54872970226369*i] [-3.64042002652517 + 0.733996349939531*i] [-3.50037473491252 + 2.83784532111642*i] [-3.80592861109028 + 3.50296053533826*i] [-4.90750592116062 + 1.24920836601026*i] [-3.82560512449716 + 1.34414866823615*i] etc... i want create list these (read in string in python) of complex numbers. here code: data = [line.strip() line in open("output.txt", 'r')] in data: m = map(complex,i) however, i'm getting error: valueerror: complex() arg malformed string any appreciated. from information, complex builtin function: >>> help(complex) class complex(object) | complex(real[, imag]) -> complex number | | create complex number real part , optional imaginary part. | equivalent (real + imag*1j) imag defaults 0. so need format string properly, , pass real , imaginary parts separate arguments. example: num = "[-3.744

javascript - Bootstrap nav's background-color not changing when active? -

hi guys when click on bootstrap's nav-bar background-color(of nav bar) not changing according css code. please help! carousel.js/carousel.css , login.html $(document).ready(function () { $('#maincarousel').carousel({ interval: 4000 }); var clickevent = false; $('#maincarousel').on('click', '.nav a', function () { clickevent = true; $('.nav li').removeclass('active'); $(this).parent().addclass('active'); }).on('slid.bs.carousel', function (e) { if (!clickevent) { var count = $('#indexmenu').children().length - 1; var current = $('#indexmenu li.active'); current.removeclass('active').next().addclass('active'); var id = parseint(current.next().data('slide-to')); if (isnan(id)) { $('#indexmenu li').first().addclass('active'); } } clickevent = false; }); }); body { padding-top: 20px; } #mycarousel .nav small { display:

MySql Workbench Can't connect to database directly -

Image
i have right configuration database connection. currently configuration works if don't specify default schema but when put database name, prompts dialog saying please enter password following service: service:mysql@127.0.0.1:3306...some long text user:xbin_sql password: but when type password promts error failed connect .... access denied.... i don't know why password , username correct

java - Regular expressions on Scala - Searching from the beginning of String -

currently, when search "th" matches "the" "these" , "other"...i don't want "other" because not @ beginning of word. i'm trying use regular expressions on scala , running problems. having trouble implementing "\a" matches @ beginning of string. i'm working on autocomplete tool code seen below , i'm using contains...however matches on part of word. what's best way match start of word using \a? val newlist = arraybuffer[string]() val pattern = new regex (\\a searchtext) def searchlist (searchtext:string):unit = { println("search has been called") println(searchtext) for(s <- words){ println("for test") if(s contains(searchtext)){ println("if test") newlist += s println(newlist.mkstring("\n")) } } } use startswith instead of contains , search beginning of string.

ruby - Display invalid value for Date in Rails -

i have custom date validator looks this: # app/validators/date_validator.rb class datevalidator < activemodel::eachvalidator date_regex = /\d{2}\/\d{2}\/\d{4}/ def validate_each(record, attribute, value) before_type_cast = "#{attribute}_before_type_cast" raw_value = record.send(before_type_cast) if record.respond_to?(before_type_cast.to_sym) raw_value ||= value return if raw_value.blank? record.errors[attribute] << (options[:message] || "must in correct date format") if (raw_value =~ date_regex).nil? end end in model, use validator following code: validates :date_assigned :date => true my problem is, when user enters invalid date, i'd display invalid date on form can correct it. currently, when enter "11111" date assigned field on form, believe rails typecasting converting nil (date_assigned date value in db), instead of "11111" being displayed, nothing is. if user enters "01/01/0

How to sync files stored in git-annex with and from gitlab.com -

i trying use git-annex gitlab.com getting error when trying sync annexed files: git annex sync --content (merging origin/git-annex git-annex...) (recording state in git...) gitlab: api not accessible remote origin not have git-annex installed; setting annex-ignore problem git-annex installation on remote. please make sure git-annex-shell available in path when ssh remote. once have fixed git-annex installation, run: git config remote.origin.annex-ignore false commit (recording state in git...) ok pull origin ok pull origin ok push origin what possibly doing wrong? i using latest version of git annex (5/08/2015).

javascript - ReactJs setState updating not in sync with what is being typed in the input box -

issue: it's strange. type input box of child component , type "onchange" method should sending updates parent component. first thing type fails update, else type updates out of sync current input. i'm noob reactjs , no master javascript don't know going on. example: here console output of object update state , new state after "setstate" was first time trying update "value1": object {value1: "5"} object {value1: "0", value2: "0", value3: "0", opening: "0"} second time tryin update "value1": object {value1: "55"} object {value1: "5", value2: "0", value3: "0", opening: "0"} as can see first time nothing updated. second time updated partially. code: var calculator = react.createclass({ getinitialstate:function(){ return { inputvalues:{ value1: "0",

java - Acess a variable from a method in a another method -

/* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ package controle_financeiro; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import java.sql.statement; /** * * @author iago */ public class telacadastrocategoria extends javax.swing.jframe { /** * creates new form telacadastrocategoria */ public telacadastrocategoria() { initcomponents(); } @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { jlabel1 = new javax.swing.jlabel(); nomecategoria = new javax.swing.jtextfield(); botao_cadastra_tela_cadastro_categorias = new javax.swing.jbutton(); botao_voltar_tela_cadastro_categorias = new javax.swing.jbutton();

css - Caching: Set expiration date for images -

in order improve loading speed of webpage want set expiration date images. not sure though how this. i loading image through css, through cloudfront s3 bucket in aws. specify expiration date? this example of how load pics: .bg-header { background: url("https://dt25rte355.cloudfront.net/assets/12456.jpg"); background-size: cover; height:480px; in directory containing files, create new file called .htaccess , add following inside: <filesmatch "\.(gif|jpg|jpeg|png)$"> header set cache-control "max-age=172800" </filesmatch> you can add additional file types regular expression, , apache add specified header every image request. note method require files hosted on server.

c# - Using list item contents as string name -

i'm using c# , making lists sqlite query responses. list1 contains field name of field in list2 list1[i].field = fieldname i want use fieldname stored in list1[i].field access item in list2 like: list2[ii].+list1[i].field+ i have no idea if possible in way in c# i'm relatively new , going off knowledge of php work. for type of data structure, use dictionary (key/value pairs) dynamically select properties of object. specific example, accomplished reflection, not commonly used since other structures make easier. list2[ii].gettype().getproperty(list1[i].field).getvalue(list2[ii], null); reflection isn't fastest type of solution typically, , it's not great come in behind , maintain code lot of reflection if can avoided. alternatively, use linq transfer list2 list of object types list of dictionary objects list2[ii][list1[i].field] accomplish same thing. var listdictionaries = list2 .select(l => new dictionary<string, object>()

javascript - React.js + bootstrap-table working only on first load, but transitions break the table -

using http://bootstrap-table.wenzhixin.net.cn here's component containing table code: var component = react.createclass({ render: function() { return ( <div classname="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main"> <div classname="row"> <ol classname="breadcrumb"> <li><a href="#"><span classname="glyphicon glyphicon-home"></span></a></li> <li classname="active">users</li> </ol> </div><!--/.row--> <div classname="row"> <div classname="col-lg-12"> <h1 classname="page-header">tables</h1> </div> </div><!--/.row--> <div classname="row">

c++ - General techniques for debugging the "multiple definition of ..." error? -

i looking general debugging "tricks" finding source problem of kind of error message: build/nat.cpp.o:(.bss+0x0): multiple definition of `input::hellocounter' build/sam.cpp.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status here, input::hellocounter global variable defined in header file, header file well-guarded ifndef... . pasting source here should pointless there many. wondering whether have general techniques debugging in such situation, e.g., inserting special code expose issue? information, using ubuntu 14.04, clang/g++ compiler. this implementation-specific issue. did not specify compiler or operating system using, no particular platform can offered. however, example, in similar situation on linux use nm(1) tool binutils search object code files ones define symbol, locating object code files define it, , determine ones should not have defined. once it's known object code file's definition should not there, co

c++ - HLSL - Sampling a render target texture always return black color -

okay, first of all, i'm new directx11 , first project using it. i'm relatively new computer graphics in general might have concepts wrong although, particular case, not think so. code based on rastertek tutorials . in trying implement shader shader, need render scene 2d texture , perform gaussian blur on resulting image. part seems working fine when using visual studio graphics debugger output seems expect. however, after having having done post processing, render quad backbuffer using simple shader uses final output of blur resource. gives me black screen. when debug pixel shader vs graphics debugger, seem sample(texture, uv) method returns (0,0,0,1) when trying sample texture. the pixel shader works fine if use different texture, normal map or whatever, resource, not when using of rendertargets previous passes. behaviour particularly weird because actual blur shader works fine when using of rendertargets resource. i know cannot use rendertarget both input , outpu