Posts

Showing posts from February, 2013

asp.net - Downloading in pdf format -

this how i'm downloading gridview in excel. pls pdf download code: string strfilename = "salary_statement" + datetime.now.tostring("ddmmyyyy"); gridview1.allowpaging = false; gridview1.headerrow.cells[2].visible = true; gridview1.headerrow.cells[3].visible = true; (int = 0; < gridview1.rows.count; i++) { gridviewrow row = gridview1.rows[i]; } gridview1.headerrow.style.add("background-color", "#e5e1e1"); (int = 0; < gridview1.rows.count; i++) { gridviewrow row = gridview1.rows[i]; row.attributes.add("class", "textmode"); } response.clear(); response.buffer = true; response.addheader("content-disposition", "attachment;filename=" + strfilename + ".xls"); response.charset = ""; response.contenttype = "

ruby on rails - How to order associated columns case insensitive -

i'm trying order projects customer company names, error: pg::undefinedtable: error: missing from-clause entry table "customers" line 1: ... "projects"."archived" = $1 order lower(customers.... ^ : select "projects".* "projects" "projects"."archived" = $1 order lower(customers.company) asc . this how tried far: projects = project.includes(:customer).order("lower(customers.company) asc") if leave out lower(…) works fine. you need write using references . project.includes(:customer) .order("lower(customers.company) asc") .references(:customers)

c++ - QString functions giving incorrect results on CentOS -

i using c++ qt library , following code working on windows not working on centos : if(line.startswith("[", qt::caseinsensitive)) { int index = line.indexof(']', 0, qt::caseinsensitive); qstring subline = line.mid(index+1); subline = subline.trimmed(); tokenlist = subline.split("\t"); } else { tokenlist = line.split("\t"); } i have line [ x.x.x.x ] ../dir/file.extension , want ignore [x.x.x.x] part while breaking line tokens. using vc9 on windows debug , working fine. edit: have removed mid() , used right() still same problem persists, working on windows not on centos. edit: after debugging on linux using qmessagebox have concluded control never going inside if block, tried using if(line.data()[0] == '[') same results. your code can simplified. line.remove(qregexp("\\[\\s+\\d+\\.\\d+\\.\\d+\\.\\d+\\s+\\]")); tokenlist = line.split("\t");

Is that possible sharing one webroot for multiple cakephp app? -

i have 2 php applications. 1 main , 1 admin app. admin upload contents on folder , other app can fetch it. problem files stored in folder like: /home/user/files/... and must fetched both of application. to simplify admin can upload file /home/user/files/ , can see /home/user/files/ , applications stay on /var/html/.. can done without symbolic links? i suggest use virtualhosts configuration( example ). can keep data in folder changing documentroot <virtualhost *:80> documentroot /folder/whatever/you/want servername www.subdomain.example.com # other directives here might want allow single ip admin user options indexes multiviews followsymlinks allowoverride none order deny,allow deny allow your_ip </virtualhost> www.subdomain.example.com serve files uploaded(by admin app) in webroot(via http). can change upload point of cakcphp application bootstrap uploads variable. try way or admin routing usual method.

mean stack - How to Query Subdocuments of 1 Schema that match the contains of another Model Subdocument Schema -

i writing mean stack application defines 2 (2) models. var job = db.model('job', { ... kind: { baby: false, pet: false, house: false, } }); var person = db.model('person', { ... kind: { baby: false, pet: false, house: false, } }); i create kind field sub-document since getting stored in field input of type checkbox in angularjs app. my question relates query of job person has same kind equal true. for example, if person has checked baby , pet in profile query jobs have baby , pet true. is way store checkbox inputs html form in mongodb? if so, query string achieve results. if not, correct way store checkbox inputs in mongodb? i dont know amount of data involved in people , jobs collections neither purpose of query/main objective of app. based on that, here thoughts: have angular service data people , jobs collections , store app loads. everytime checkbox checked/unchecked u

javascript - I have issue with setTimeout/clearTimeout -

i have following js document.addeventlistener("domcontentloaded", function() { document.queryselector("#pageredirect").addeventlistener("change", changehandler); }); function changehandler() { var timer; if (pageredirect.checked) { timer = settimeout(function() { window.location.href = 'http://www.google.com'; }, 3000); console.log(pageredirect.checked); } else { //dont redirect cleartimeout(timer); console.log(pageredirect.checked); } } <input type="checkbox" id="pageredirect" name="pageredirect" /> i dont redirect when checkbox uncheck is. where's fault ? thanks. the issue location of variable declaration timer id. it's inside function, when attempt clear it, it's not got id assigned in settimeout . need move declaration outside of function can keep handle of timer between invocations: var timer; function

ruby - Rails "undefined method for ActiveRecord_Associations_CollectionProxy" -

i have models: class student < activerecord::base has_many :tickets has_many :movies, through: :tickets end class movie < activerecord::base has_many :tickets, dependent: :destroy has_many :students, through: :tickets belongs_to :cinema end class ticket < activerecord::base belongs_to :movie, counter_cache: true belongs_to :student end class cinema < activerecord::base has_many :movies, dependent: :destroy has_many :students, through: :movies has_many :schools, dependent: :destroy has_many :companies, through: :yard_companies end class school < activerecord::base belongs_to :company belongs_to :student belongs_to :cinema, counter_cache: true end class teacher < activerecord::base belongs_to :movie, counter_cache: true belongs_to :company end class contract < activerecord::base belongs_to :company belongs_to :student end class company < activerecord::base

powershell - Choice of input values for a PS function. -

i have function accepts range of input values. of times, users pick 1 of 3 values (value1, value2, value3). occasionally, might input value not in set (value 5). though, want provide user choice, avoid typos etc, don’t want restrict them 3 values. use following code, doesn’t serve purpose. suggestions? function get-something(){ param([validateset('value1','value2','value3')] [string] $yourchoice) return $yourchoice } one option might have 4 parameter sets, value1, value2, , value3 being switch parameters used select 1 of 3 common values, , value being string parameter used specify arbitrary value, each within it's own parameter set they're mutually exclusive.

Hadoop services are not getting stated if i use particular zlib library -

i'm trying use different zlib library hadoop. when i'm using particular library, hadoop services not getting started. services starting if use different library. difference between libraries are, not working 1 using device file send data kernel driver compression. issue ? , error log in hadoop.

algorithm - Pseudo-code for Network-only-bayes-classifier -

Image
i trying implement classification toolkit univariate network data using igraph , python . however, question more of algorithms question in relational classification area instead of programming. i following classification in networked data paper. i having difficulty understand paper refers " network-only bayes classifier "(nbc) 1 of relational classifiers explained in paper. i implemented naive bayes classifier text data using bag of words feature representation earlier. , idea of naive bayes on text data clear on mind. i think method (nbc) simple translation of same idea relational classification area. however, confused notation used in equations, couldn't figure out going on. have question on notation used in paper here . nbc explained in page 14 on the paper , summary: i need pseudo-code of " network-only bayes classifier "(nbc) explained in paper , page 14. pseudo-code notation: let's call vs list of vertices in graph. len(

javascript - CSS: How to scale an <img> to cover entire parent <div>? -

question: http://jsfiddle.net/log82brl/15/ the <img> isn't shrink wrapping expect min-width:100% i'm trying shrink <img> until either height or width matches container click anywhere in <iframe> toggle container shapes please try edit <img> css: 1) maintain aspect ratio 2) cover entire surface area of container div 3) only edit image this centering approach looks kinda sketch it's pretty robust my question specifically: scale <img> fill (maintain aspect ratio cover entire surface) of parent <div> parent <div> resizes maybe somehow use css flex box-layout or something? maybe transform? answer : http://jsfiddle.net/log82brl/17/ set html source transparent base64 pixel (credit css tricks ) <img id="img" src="data:image/gif;base64,r0lgodlhaqabaiaaaaaaap///yh5baeaaaaalaaaaaabaaeaaaibraa7" /> use css background property #img { width: 100%;

onclick - javascript click function not working on multiple buttons -

here javascript code. problem last create function working not other.for example here have 4 create() function last 1 working properly. if have 3 3rd 1 work fine not others........please suggest wrong code....please i'm new javasript. please check code in codepen here window.onload=function() { var number_operation_table=document.getelementbyid('number_operation_table'); create('lt','<'); create('gteq','>='); create('lteq','<='); create('gt','>'); function create(prefix,operator) { number_operation_table.innerhtml+="<tr><td><input type='text' name='"+prefix+"_val1' id='"+prefix+"_val1'/>"+operator+"<input name='"+prefix+"_val2' type='text' id='"+prefix+"_val2'/></td> <td><button id='check_"+prefix+"'>check</button&g

javascript - Maxlength limit for onClick button input -

i'm creating simple form allow customers input number form field, should have limit of 6 characters. the numbers submitted our database, customer needs see them before submitting. i have used script below create number submission form input text field (which can sent db). went method majority of our audience on on mobiles, didn't think standard text field input user friendly (open alternatives on this). <input name="ans" type="text" size="6" maxlength="6"><br> <p><input type="button" value="1" onclick="document.calculator.ans.value+='1'"> <input type="button" value="2" onclick="document.calculator.ans.value+='2'"> <input type="button" value="3" onclick="document.calculator.ans.value+='3'"></p> <p><input type="button" value="4" onclick="docum

javascript - Onclick in dropdown toggle is not working -

i have toggle-dropdown , trying call function read(); upon clicking dropdown. not working, have tried using ondrop , onchange , others.. <a data-toggle="dropdown" class="dropdown-toggle" onclick="read();"> <i class="fa fa-globe"></i> <span class="badge"> <%=unread%> </span> </a>

java - Declare dependency to war file in Gradle -

based on gradle docs , define external jars means adding build.gradle following snippet (considering have {project_root}/libs/foo.jar) in place: dependencies { runtime files('libs/foo.jar') } however, using same dependency declaration *.war files doesn't work. possible? project i'm trying depend on builds war file. since war layout different jar file standard layout, it's not possible declare war dependency file java project. possible ideas: clone project , define dependency (very stupid idea, i'm ashamed suggest sth that) contact author , ask him/her if can copy class need use. if can copy class along credits. contact author , ask him/her if make sense make codec open source (i know right now) , release standalone jar library (maybe along other classes used in project).

html5 - How to pass object in Thymeleaf + Spring flow without values -

from search page, user can click create new button. if user enter p_no in search page, , user click create new, number being carried out create new page. should not pass value. wrong code below. personentry.html(create page) : <form id="entry" action="#" th:object="${person}" method="post"> <div id="boxes"> <div class="col-md-1"> <input type="text" class="form-control" id="pno" th:value="${person.p_no}" disabled="disabled" /> </div> </div> </form> controller.java: @controller @requestmapping("/searchpersons") public class searchpersoncontroller { @requestmapping(value = "/createnewbtn", method = requestmethod.post) public modelandview creatnewperson(person person) { modelandview modelandview = new modelandview(); modelandview.setviewnam

How to email the auto generated Email-able report of TestNG + Web driver using Java -

email-able report generated testng don't know how can email report prospective stakeholders. want through script in java using selenium web driver. if can in different way helpful. you need have smtp server, instead of writing separate code recommend integrate selenium webdriver jenkins has inbuilt mechanism circulating reports whomsoever want.

excel - VBA Shell command no longer working -

heyho, earlier today ran issues shell command in vba using excel2010 64bit. have fixed them hardcoded workaround, know why stopped working. here code snipped: dim mypath string dim myfolder string mypath = "d:\somefolder\" myfolder = "somesubfolder\" shell mypath & myfolder & "some.bat" until 2 weeks ago, consistently executing bat, stopped working. i have played around bit , checked other syntaxes using shell command , have yet make sense of it. whenever tried execute snipped "runtime error 5, invalid procedure call or argument" however, working 2 weeks ago, , haven't touched file. according ms documentation other arguments shell optional cannot problem. in end, instead of looping through directories, hardcoded paths in multiple commands this: shell """fullpath_to_.bat-files""" funny thing is, have multiple other vba scripts use old syntax described further up, meaning combining

php - Count of same records from two columns using if condition -

i have table question_attempts . table having 2 columns rightanswers , youranswer . i want count of records rightanswer = youranswer . entire code actually. $quizsections = mysql_query("select * quiz_sections"); while($quizsectionsrslt = mysql_fetch_array($quizsections)){ $quizsectionsid = $quizsectionsrslt['id']; $quizsectionsheading = $quizsectionsrslt['heading']; $quizsectionsquizid = $quizsectionsrslt['quizid']; $quizsectionsfirstslot = $quizsectionsrslt['firstslot']; echo $quizsectionsheading."<br />"; $quizslots = mysql_query("select * quiz_slots `quizid`=$quizsectionsquizid limit ".($quizsectionsfirstslot-1).", 10"); while($quizslotsrslt = mysql_fetch_array($quizslots)){ $quizslotids = $quizslotsrslt['questionid']; $questions = mysql_query("select * question_attempts `questionid`=$quizslotids"); $num_rows = mysql_num_rows($quizslots); while($answe

ios - Remove -Objc flag from Cocoapods install -

my project won't build if keep -objc flag in other linker flags , inherit flag cocoapods. can delete pods.debug.xcconfig , works, however, every time run pod update comes , have delete again. is there podfile script add automate removing -objc flag? i'm using cocoapods v0.37.2. i'd remove -objc following snippet taken pods.release.xcconfig , pods.debug.xcconfig. other_ldflags = $(inherited) -objc -l"c++" -l"sqlite3" -framework "avfoundation" -framework "alamofire" btw need remove -objc flag caused parse , facebook sdks. i don't know if still need this, able post_install script on podfile. have different targets , works well: post_install |installer| installer.pods_project.targets.each |target| target.build_configurations.each |config| xcconfig_path = config.base_configuration_reference.real_path xcconfig = file.read(xcconfig_path) new_xcconfig = xcconfig.sub('other_ldflags

What does "PersonBean myBean =(PersonBean)request.getAttribute("myBean");" mean in Java? -

i learning java , came accross code example. personbean mybean =(personbean)request.getattribute("mybean"); if(mybean=null) { mybean = new personbean(); request.setattribute("mybean",mybean); } here personbean mybean =(personbean)request.getattribute("mybean"); doing? mean in if statement there statement constructs object of class . purpose of first line here? can break down me ? this code gets "mybean" attribute request object (which contains incoming objects) , casts personbean. if not successful creates new personbean object name "mybean" , sets "mybean" object in request.

Correct screen name typos in Google Analytics -

i'm working on native mobile app spans ios, android, , windowsphone platforms. google analytics being leveraged track screen views , custom events (mostly based on user taps). there typo in screen names sent google analytics on 1 of platforms. as hypothetical example, let's there registration page in app, , 2 of platforms sent "registration" screen name , other platform sent "registraton" screen name. typo corrected on client app, data in google analytics still shows incorrect brief time period. does know if possible correct simple typos this? if so, can point me in right direction? i've researched talks sending data google analytics rather correcting existing data in google analytics. it's not possible @ moment you're asking. i've felt pain myself before, , in case happens capitalization mistakes (e.g. sending both "click" , "click"). you can use filter target both variations, there's no way go , ch

Python keep asking for raw_input in "while True" -

this question has answer here: asking user input until give valid response 10 answers i need python keep asking raw_input if answer different 1 or 2. here example: print """what want me do? 1) press 1 if want ..... 2) press 2 if want .....""" while true: answer1 = raw_input(" => ") if (answer1 == 1): .... .... elif (answer1 == 2): .... .... elif (answer1 != 1 or 2) or answer1.isalpha(): print "i need 1 or 2" the problem python keeping asking raw_input if user enter 1 or 2. wrong? you should put break statement in if , elif block if answer 1 or 2 break out of while loop. example - if (answer1 == 1): .... .... break elif (answer1 == 2): .... .... break

How do you escape raw HTML in Go? -

i have managed output text using following line: fmt.fprintf(w, "<p>some text</p>") but literally output html tags. how output can safely included in html echo in php? fmt.fprintf() has no knowledge of html syntax: outputs raw data without escaping (it may formatting not escaping). you don't use correctly though: second parameter format string, should call rather this: fmt.fprintf(w, "%s", "<p>some text</p>") else if text contains format-specific special characters, not expected result. what want escape html code can safely included in html documents/pages. excellent support html/template package provides powerful template engine automatic escaping functionality being 1 feature. here's simple example how achieve want: w := os.stdout text := "<p>some text</p>" fmt.fprintf(w, "%s\n", text) tt := `{{.}}` t := template.must(template.new("test").parse(tt)

angularjs - How to insert a new line inside a directive template in angular.js? -

hi know easy question how can insert new line in directive template? have long template. , hard me scan through horizontally. want have in new line. angular doesn't want. app.directive('broadcasted', function(){ return{ restrict: 'eac', // new line template not in single line template: '<div class="alert alert-success col-md-6" ng-repeat="x in bcards"><strong class="broadcast-text" ><% x.q_number %> - <% x.teller_id %></strong></div>', link: function($scope){ } }; }); how this: app.directive('broadcasted', function(){ return{ restrict: 'eac', // new line template not in single line template: '<div class="alert alert-success col-md-6" ng-repeat="x in bcards">' + '<strong class="broadcast-text" >' + '<% x.q_number %> - <% x.t

java - XPath check for attribute and show the value -

i need check bunch of .xml files specific permission, attribute. if there such permission attribute have find out value attribute has. this code produces nullpointerexceptions : public static void checkxmlpermissions(string path) { fileinputstream file; try { file = new fileinputstream(new file(path)); documentbuilderfactory builderfactory = documentbuilderfactory.newinstance(); //xpath initialisieren; documentbuilder builder = builderfactory.newdocumentbuilder(); document xmldocument = builder.parse(file); xpath xpath = xpathfactory.newinstance().newxpath(); string expression ="//*[@permission]";

python - Why my SGD is far off than my linear regression model? -

i'm trying compare linear regression (normal equation) sgd looks sgd far off. doing wrong? here's code x = np.random.randint(100, size=1000) y = x * 0.10 slope, intercept, r_value, p_value, std_err = stats.linregress(x=x, y=y) print("slope %f , intercept %s" % (slope,intercept)) #slope 0.100000 , intercept 1.61435309565e-11 and here's sgd x = x.reshape(1000,1) clf = linear_model.sgdregressor() clf.fit(x, y, coef_init=0, intercept_init=0) print(clf.intercept_) print(clf.coef_) #[ 1.46746270e+10] #[ 3.14999003e+10] i have thought coef , intercept same data linear. when tried run code, got overflow error. suspect you're having same problem, reason, it's not throwing error. if scale down features, works expected. using scipy.stats.linregress : >>> x = np.random.random(1000) * 10 >>> y = x * 0.10 >>> slope, intercept, r_value, p_value, std_err = stats.linregress(x=x, y=y) >>> print("slope

c# - Visual Studio 2013- Post-build event - copy by main project bin folder -

i want copy dll files projects in solution execute project folder post-build. is there way startup project destination path variable post-build event of projects in solution? here paths variables msdn site. https://msdn.microsoft.com/en-us/library/42x5kfw4.aspx?f=255&mspperror=-2147217396

Running same job in Parallel using Jenkins and build flow -

i trying run same automated job (deriv_client_add) in parallel different parameters: parallel( {build("gui/deriv_client_add", branch:params.branch, config:params.conf)} ) if run job multiple times different branch , config queues them up. there way run same job multiple times in parallel? thank ;) try below plugin suit requirement checkthis

how to convert yii framework project into php -

can 1 me. create yii framework project.how convert php in easiest way.actually know little concept of mvc using in php problem render,redirect,lot of pages create through mvc . how control admin panel . create differt admin panel media person , agent.i dont understand if extends ccontroller in yii how use in php also.. lot of confusion me project. can 1 me easiest way possible.if describe better me. please help. thank in advance. let me clear. php server-side scripting language. the yii framework instrument, supports development process , relieve "programmer" common activities. framework build on php, because of this, there no "converting". my advice you: check requirements given client carefully. after that, have probablary 2 options. coding functionality in php checkout cool framework , spent time learning

SQL Regex for an Address -

i have address field populated like: flat 1 flat 2 flat 2a flat 3 as can see, entries numbers , others contain numbers , letters. sort them via numbers, letters - is, i'd ordered above. currently this: func1(regexp_substr(demiseunit, '^[0-9]+')) func2(regexp_substr(demiseunit, '[0-9]+$')) however, unfortunately causes flat 2a go bottom of list. appreciated. if have "flat ##aa" can order val(replace(demiseunit,"flat ","")), demiseunit

http - use Java client like curl with param -

i use influxdb 0.9. in version, can write database like curl -xpost 'http://localhost:8086/write?db=mydb' -d 'cpu,host=server01,region=uswest value=1.0' now convert java url url = new url("http", "localhost", 8086, "/write?db=mydb"); httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("post"); con.setdooutput(true); outputstream wr = con.getoutputstream(); stirng s = "cpu,host=server01,region=uswest value=51.0"; wr.write(s.getbytes(utf_8)); wr.flush(); wr.close(); but doesn't work. "-d" meant represent post parameters? how can express in java? in example curl flag should --data-binary , not -d , can have different encoding. long string unaltered java code should fine. url encoding prevent line protocol insert working.

css - change image existing color from one to another one -

Image
i have calendar image want change color. dont have photoshop edit color. possible change color css? i want apply color color: #26416c; if it's image, you're limited editing image editor, or using experimental css technology using filter property : img { -webkit-filter: hue-rotate(90deg); filter: hue-rotate(90deg); } <img src="http://i.stack.imgur.com/v96i5.png" />

php - CodeIgniter: Your system folder path does not appear to be set correctly...using HTTPS -

i'm working website didn't build, uses codeigniter framework. had relatively simple task: secure site ssl certificate. no problem. except, site not load https, although still loads correctly using http. gives following error https: your system folder path not appear set correctly. please open following file , correct this: index.php now, error message seems self explanatory...change system path in index.php file, system path set in file: $system_path = '/codeigniter/2_1_3'; fine, folder doesn't exist in directory structure, , neither folder named 'system.' so, don't have clue how fix problem. isn't clear me how website functions @ since can't find folder supposed using system folder. any appreciated. please ask if there additional information need help.

annotations - How to annotate helper class to be visible inside JSF? -

i have helper class, neither stateful managed bean , nor stateless ejb , nor entity mapped table via jpa or hibernate . collection of static methods simple things return date formats , similar. given that, in order java class visible inside jsf, class must annotated in way container assigns visible jsfs, there way annotate helper class not match of standard jsf visible categories becomes visible? alternative, of course, have conduit method in managed bean passes call jsf helper class prefer not clutter managed bean if can call directly jsf. understand doing stateless ejb jsf considered anti-pattern methods in class wish use simple , non-transactional. mark class @applicationscoped . make sure has public no-arg constructor , class doesn't have state , methods thread safe. e.g. managed bean (pure jsf) //this important import javax.faces.bean.applicationscoped; @managedbean @applicationscoped public class utility { public static string foo(string anoth

mysql - Error #1109 - unknown table in field list caused by trigger -

this trigger. i want make trigger on 1 table (pelayanan). create definer=`root`@`localhost` trigger `before_insert_pelayanan` before insert on `pelayanan` each row if new.`estimasi` null or new.`estimasi` = 0 , `dbhpl`.`pelayanan`.`daya` <= 5500 set new.estimasi = 4; elseif new.estimasi null or new.estimasi = 0 , `dbhpl`.`pelayanan`.`daya` <= 33000 , `dbhpl`.`pelayanan`.`daya` >= 6600 set new.estimasi = 15; elseif new.estimasi null or new.estimasi = 0 , `dbhpl`.`pelayanan`.`daya` <= 197000 , `dbhpl`.`pelayanan`.`daya` >= 41500 set new.estimasi = 40; else set new.estimasi = 100; end if when execute trigger, has been created. but, when insert data table pelayanan, become #1109 - unknown table 'pelayanan' in field list. how can resolve this? i have remove dbhpl.pelayanan.daya become pelayanan.daya , daya . but, doesn't work. use new before column name. right code- mysql> create defi

serialization - How can I store instances of TabItem and load the instances on Application start (VB.NET) -

i'm storing instances of tabitem retrieving selected tab item tabcontrol's "selecteditem" property dictionary of type (string, tabitem) on button click 1 1. after few clicks have dictionary containing lots of tabitems. store entire dictionary permanently such can load on application start. suggestions on how , can store instances? know file option there other alternative? i tried serializing dictionary , store in file gives me error stating tabitem not serializable.

oracle - Trigger creation on a table for inserting value in a column -

how create trigger insert value in column depending on combination of 3 other columns of same table of newly inserted row in table. create or replace trigger execution_trigger after insert on jobs declare v_a varchar2(100); v_b varchar2(100); v_c varchar2(120); begin select category, method,tech v_a, v_b, v_c jobs if v_c = '10x' , v_b = '20x' , v_a = '30x' update jobs set execution = 1; else update jobs set execution = 2; end if ; null; end ; i not able execute this... you need before insert trigger here: create or replace trigger execution_trigger before insert on jobs each row begin if :new.category = '30x' , :new.method = '20x' , :new.tech = '10x' :new.execution := 1; else :new.execution := 2; end if; end; test: create table jobs (category varchar2(10), method varchar2(10), tech varchar2(10), execution number(5)); insert jobs (category, method,

apache - Apache2 - Mod_rewrite and .htaccess -

i using ubuntu 14.04 , apache 2. here phpinfo file: https://www.vivashost.com/phpinfo.php here .htacess file: options +followsymlinks rewriteengine on rewriterule ^feature-pricing-tables.html$ feature.html here /etc/apache2/sistes-available/000-default.conf file: <virtualhost *:80> # servername directive sets request scheme, hostname , port # server uses identify itself. used when creating # redirection urls. in context of virtual hosts, servername # specifies hostname must appear in request's host: header # match virtual host. default virtual host (this file) # value not decisive used last resort host regardless. # however, must set further virtual host explicitly. #servername www.example.com serveradmin webmaster@localhost documentroot /var/www/html <directory /> options followsymlinks allowoverride </directory> <directory /var/www/html> options indexes followsymlink

java - Rolling back transactions after exception is thrown -

when throw exception in service method expected transactional annotation on service rollback save operation, not working. this service: @service @transactional(value = "transactionmanager", rollbackfor = exception.class) public class orderserviceimp implements orderservice { @autowired private orderrepository orderrepository; @override public void dosomestaff(long orderid) { order order = orderrepository.findone(orderid); orderrepository.save(order); throw new nullpointerexception("test transaction exeption"); } } in data.xml have next configs: <tx:annotation-driven transaction-manager="transactionmanager" /> <bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager"> <property name="entitymanagerfactory" ref="entitymanagerfactory" /> </bean>

uitabbarcontroller - How to correctly display a tab controller in swift -

i'm making login screen app , works intented until try present main view after login(which uses tab bar controller). the problem displays first item on tab bar. have press other buttons appear. im using code: //after login... var storyboard: uistoryboard = uistoryboard(name: "main", bundle: nil) var vc: tabbarviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("maincontroller") as! tabbarviewcontroller self.presentviewcontroller(vc, animated: true, completion: nil) my guess need load them @ same time, dont know... this how did recently. loaded tabbarcontroller , login screen together, once user has logged in (or completed first screen experience) can modally dismiss controller. func showloginview() { let storyboard = uistoryboard(name: "main", bundle: nil) let loginviewcontroller: logintableviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("logintvc") as! logintableviewcontroller sel

python - How do I take a number associated with a word and have the word printed that number of times? -

i have text file list of words number , want alter list instead of having number next word, word printed number of times. so example, list: word, 2 for, 3 cat, 1 dog, 2 tiger, 1 i want took this: word word cat dog dog tiger for python program have far: f = raw_input("please enter filename: ") def openfile(f): open(f,'r') a: = a.readlines() b = [x.lower() x in a] return b def fix(b): newlist = [] line in b: split_line = line.split(',') print openfile(f) what want take number , tell program print word number of times , delete number not sure how that. if have suggestions, answers, or need clarification please let me know! thanks if want change file can use fileinput.input inplace=true change file content: import fileinput import sys line in fileinput.input("in.txt",inplace=true): if line.strip(): w,i = line.split(",") sys.stdout.write

How to find the second derivative in R and while using newton's method with numerical derivation -

the log-likelihood of gamma distribution scale parameter 1 can written as: (α−1)s−nlogΓ(α) alpha shape parameter , s=∑logxi sufficient statistic. randomly draw sample of n = 30 shape parameter of alpha = 4.5. using newton_search , make_derivative , find maximum likelihood estimate of alpha. use moment estimator of alpha, i.e., mean of x initial guess. log-likelihood function in r is: x <- rgamma(n=30, shape=4.5) gllik <- function() { s <- sum(log(x)) n <- length(x) function(a) { (a - 1) * s - n * lgamma(a) } } i have created make_derivative function follows: make_derivative <- function(f, h) { (f(x + h) - f(x - h)) / (2*h) } i have created newton_search function incorporates make_derivative function; however, need use newton_search on second derivative of log-likelihood function , i'm not sure how fix following code in order that: newton_search2 <- function(f, h, guess, conv=0.001) { set.seed(2) y0 <- guess

ios - Swift: Streaming video file from pc -

i play video file on local pc (path: " http://192.168.1.5:9000/assets/uploadedfiles/4.mp4 "). iphone , pc both in same network. following code works fine if play videos on iphone. otherwise displays black screen. self.objmovieplayercontroller = mpmovieplayercontroller(contenturl: url!) self.objmovieplayercontroller.moviesourcetype = mpmoviesourcetype.unknown self.objmovieplayercontroller.view.frame = self.videoview.bounds self.objmovieplayercontroller.scalingmode = mpmoviescalingmode.aspectfill self.objmovieplayercontroller.controlstyle = mpmoviecontrolstyle.embedded self.objmovieplayercontroller.contenturl = url! self.objmovieplayercontroller.shouldautoplay = true self.videoview.addsubview(self.objmovieplayercontroller.view) self.objmovieplayercontroller.preparetoplay() self.objmovieplayercontroller.play() i don't want download video file iphone. there way stream video file pc? thanks

javascript - How can I bind data.key --> element.id on existing markup in d3js? -

i have existing <svg> , have defined groups <g> each group has own unique id. <g id="id_1"><text>...</text></g> <g id="id_2"><text>...</text></g> <g id="id_3"><text>...</text></g> <g id="id_4"><text>...</text></g> similarly have data formatted as data = { "id_2" : { "name" : value1, "description" : value2, ... }, "id_4" : { "name" : value1, "description" : value2, ... }, "id_9" : { "name" : value1, "description" : value2, ... } }; for each row. notice not id's match! i not wish replace <g> , instead bind each data row correct <g> tag id's match. default behavior of d3.select('g').data(d3.values(data)) not support bind index. how can this? i have sample code @ jsbin indexed data binding

php - Using flashdata to determine if model was successful in CodeIgniter -

i trying determine if database update performed in model successful, pass status of (successful or not successful) view can display div appropriately. far, it's worked long model update worked, not working when it's not. i'm using flashdata pass data through controller. my model: public function editticket($ticket) { $q = $this->db->where('ticketid', $ticket['ticketid']); $q = $this->db->update('tickets', $ticket); $results = $this->db->affected_rows(); return $results; } my controller: public function editexistingticket() { $this->load->model('tickets'); $date = date("y-m-d h:i:s"); $ticket = array( 'ticketid' => $this->input->post('ticketid'), 'category' => $this->input->post('category'), 'headline' => $this->input->post('headline'), 'description&

unit testing - Mocking zipfile in python -

i'm trying use python mock library mock few methods zipfile module. example source want test: def zipstuff(listofpathtofiles): zipfile(fname, 'w') archive: each in listofpathtofiles: archive.write(each, strippedfname) return archive the "archive" above ignored normal execution, list of files during tests. example unittest code: emptylist=[] def mockwrite(fname): emptylist.append(fname) return mockzip.__enter__ = mock(return_value=emptylist) mockzip.__exit__ = mock(return_value=true) now, want mock archive.write instead of actual write call, replaced mockwrite function can list of files supposed zipped. i've tried: mockzip.write = mock(side_effect=mockwrite) but wasn't being called. debugging shows function calling mockzip. enter ().write. if try: mockzip.__enter__().write = mock(side_effect=mockwrite) python issues error 'list' has no attribute write (which correct). i'm new mock

c# - Alternative to private implicit conversion operators -

i'm trying write simple string enum. i'd use standard enum need spaces in strings. i've tried prevent construction of other instances making constructor private. however, wanted implicit conversion make static declarations easier/neater (last line) public class stringenum { public static stringenum foo = "a foo"; public static stringenum bar = "a bar"; public static stringenum wibble = "a wibble"; public static stringenum crotchet = "a crotchet"; //etc... //implicit cast string public static implicit operator string(stringenum s) { return s.privatestring; } //private construction private string privatestring; private stringenum(string s) { this.privatestring = s; } private static implicit operator stringenum(string s) { return new stringenum(s); } } this implicit operator fails compile "the modifier private not valid item". make public other code can

php - A switch between ascending and descending table rows on a tableheader click -

i've been messing quite time now, can't work. i'm trying make ; a clickable table header, once clicked switches row order ascending descending , when clicked again. the attempts did far didn't loop, , got stuck after 1 click. just add link table header cell contains parameter, e.g. <tr><th> <a href="currentpage.php?order=<?php echo isset($_get['order'])?!$_get['order']:1; ?>"> name </a> </th></tr> what happens here? link added, containing order parameter set opposite of current order value(1/true or 0/false) or 1 default. in php script can decide how order table using order value: $isasc = isset($_get['order'])? (bool) $_get['order']: 1; now can use $isasc boolean: if ($isasc) { // sort data ascending } else { // sort data descending } or in query: $sql = "select * tabe order name ".($isasc?"asc":"desc")

css - Changing color in Jquery -

can use css in jquery change div 's color slowly? oh , 1 more thing, how can add second function <div> . here code. want change color old 1 when mouseout happens. <script> function myfunction() { $(document).ready(function () { $("#square").css({ backgroundcolor: 'blue' }); }); } </script> <div id="square" onmouseover="return myfunction()">focus on me!</div> to make slow, give transition , remove document.ready calling not on load: #square {transition: 1s linear;} cross browser support -webkit-transition: 1s linear; -moz-transition: 1s linear; -o-transition: 1s linear; transition: 1s linear; snippet $(document).ready(function () { $("#square").hover(function () { $(this).css("backgroundcolor", 'blue'); }, function () { $(this).css("backgroundcolor", ''); }); }); #square {width:

jquery - appendTo not working -

good evening, i have following code $( document ).ready(function() { $.get( "php/get_ratings.php") .done(function(data) { $("#newrow").html(''); $("#list_loc").html(''); var results = jquery.parsejson(data); $.each(results, function(i, value) { var newrow = $("<div />", { id : "new"+results[i].id }); var newloc = $("<div />", { id: "loc"+results[i].id, text: results[i].city }); $("#newrow").append(newrow); $("#list_loc").append(newloc); $('#list_loc').appendto('#newrow'); }) }); }); html <div class="container"> <div class="row list"> <div id="

android - New to java - Attempt to invoke virtual method 'void -

i new coding , java , got problem , wasn't able fix it. strange thing error happens on android 5. below error message java.lang.nullpointerexception: attempt invoke virtual method 'void com.nostra13.universalimageloader.core.imageloader.displayimage(java.lang.string, android.widget.imageview, com.nostra13.universalimageloader.core.displayimageoptions)' on null object reference @ com.fragments.activity.storeactivity$1.onmgarrayadaptercreated(storeactivity.java:143) @ com.adapters.mgarrayadapter.getview(mgarrayadapter.java:82) storeactivity.java public void onmgarrayadaptercreated (mgarrayadapter adapter, view v, int position, viewgroup viewgroup, object obj){ // todo auto-generated method stub final store store = arraydata.get(position); photo p = q.getphotobystoreid(store.getstore_id()); mgimageview imgviewphoto = (mgimageview) v.findviewbyid(r.id.imgviewphoto); imgviewphoto.setcornerradius(0.0f); imgviewphoto.setborderwidth(uiconfig.b

iphone - Preserve iOS App name -

we have ios (iphone , ipad) b2b application working specific name. want use same name in ios app or convert b2b application public one. we have been searching in internet , have seen 2 alternatives, have doubts both: 1-delete b2b application. if delete app, able use app name other app in other developer account? will current users' installations of app deleted mobiles automatically once delete app b2b? 2-convert b2b public. by making changes , uploading update itunes connect, can release app normal public, moving b2b?. firstly, if delete app, indeed able use app name again. secondly, current users installations won't delete. have manually delete apps devices, cannot delete them remotely. not 100% sure converting app b2b public, believe if upload itunes connect , select stores you'd sell in, pricing , submit review without problem release sale in select stores. hope helps, julian

php - Read cookie from domainA.com on domainB.com -

i know browsers block cross domain cookies security reasons. i'm wondering if there way around it? have wp website , url shortener, url shortener tracking grabbing wp username cookie, if set. i've moved url shortener new short domain , tracking system has stopped grabbing username cookie. there way can reintroduce functionality? cross domain can allowed header access-control-allow-origin: * . but cannot share cookies through domains. an alternative solution this anwser : you this: centrilize cokies in single domain, let's cookiemaker.com when user makes request example.com redirect him cookimaker.com cookiemaker.com redirects him example.com information need of course, it's not completelly secure, , have create kind of internal protocol between apps that.

C++ (Pop in Array Based Stack) Do we delete the element? -

here code lecture note stack using array implementation. in specification: template <typename t> class stack { public: stack(); bool pop (t& stacktop); //there still other code private: int maxsize; int* arr; int _size; } in implementation: bool stack<t>::pop(t& stacktop){ if (isempty()){ return false; }else{ --_size; stacktop=arr[_size]; return true; } } and example of user program: stack<int> st; int k; st.push(1);st.push(2);st.push(3);//will add element 1 ,2, , 3. st.pop(k);cout<<"pop"<<k<<endl; //will pop last element 3 , print pop 3 i understand in pop implementation , update( reduce one) size of array. don't seem erase element! so, element still there, , reduce size top of array shifted? e.g. maximum size 100 in code push 1, 2 , 3. top on 3. , rest 97 elements still unassigned. pop (which last element 3). when pop, "move" top