Posts

Showing posts from January, 2011

javascript - CSS/JS won't work if I include the header -

here index.html file <!doctype html> <html> <head> <meta charset=utf-8> <title>title</title> <meta name=viewport content="width=device-width, initial-scale=1"> <meta http-equiv=x-ua-compatible content="ie=edge"> <link href=assets/css/elegant-icons.min.css rel=stylesheet type=text/css media="all"/> <link href=assets/css/bootstrap.css rel=stylesheet type=text/css media="all"/> <link href=assets/css/theme.css rel=stylesheet type=text/css media="all"/> <link rel=stylesheet type=text/css href="assets/css/style.css"/> </head> <body> <div id="inc"></div> <div class=main-container> <section class="no-pad coming-soon fullscreen-element"> </section> </div> <script src=assets/js/jquery.min.js></script> <sc...

php increment a number in static constructor -

i need increment number in constructor of class, without calling static functions. code follows: class addup { static public $num; function __construct($num) { echo 'my number is==>' . $num; static::$num++; } } $inc = new addup();//instantiated object echo '<br>'; echo $inc::$num;//should 2, still 1, should $inc = new addup() or $inc->addup() implemented in class? echo '<br>'; echo $inc::$num;//should 3, still 1 echo '<br>'; echo $inc::$num;//should 4, still 1 any ideas welcome, thank you upd made following refactoring: $inc = new increment();//my number is==>2 echo '<br>'; $inc = new increment();//my number is==>3 echo '<br>'; $inc = new increment();//my number is==>4 echo '<br>'; $inc = new increment();//my number is==>5 is way without calls functions in class? a static property means value of static property same across multiple instantia...

Add a new field to array elements in a foreach PHP - Laravel -

i have variable: $families = array( array( 'expand' => '', 'family_id' => 'aaer', 'active' => true, 'description' => 'wall art', 'group_id' => 5 ), array( 'expand' => '', 'family_id' => 'eerr', 'active' => true, 'description' => 'personalised mugs', 'group_id' => 4 ), ); and want add $families items field called 'href', this: $families = array( array( 'href' => 'http://mipage/wall-art/aaer', 'expand' => '', 'family_id' => 'aaer', 'active' => true, 'description' => 'wall art', 'group_id' => 5 ), array( ...

java - Handling broken pipe exception in @ControllerAdvice does not work as well -

good day. know "broken pipe" not critical exception , mean client did not wait response server. , know there many similar question can not find answer on s.o. i want keep logs clear found solution . and tried write like: @controlleradvice public class controlleradvisor { private static final logger logger = logmanager.getlogger(); @responsebody @exceptionhandler(ioexception.class) @responsestatus(httpstatus.service_unavailable) public object brokenpipehandle(ioexception e, httpservletrequest req) { if (stringutils.containsignorecase(exceptionutils.getrootcausemessage(e), "broken pipe")) return null; return new errordto(e.getmessage()); } } but broken pipe exception still happened , have in logs: java.io.ioexception: broken pipe @ sun.nio.ch.filedispatcherimpl.write0(native method) ~[na:1.8.0_91] @ sun.nio.ch.socketdispatcher.write(socketdispatcher.java:47) ~[na:1.8.0_91] @ sun.nio.ch.i...

javascript - initiate a number of vertices/triangles for vertex shader to use -

Image
i've been playing around vertexshaderart.com , i'd use learned on separate website. while have used shaders before, effects achieved on site depend on having access vertices/lines/triangles. while passing vertices easy enough (at least three.js, though kind of overkill simple shaders, in cases in need shader materials too), creating triangles seems bit more complex. i can't figure out source, how triangles created there, when switch mode here? i'd replicate behavior have no idea how approach it. create number of triangles through 3 many individual objects performance takes hit rapidly. triangles created here separate entities or part of 1 geometry? vertexshaderart.com more of puzzle, toy, art box, creative coding experiment example of webgl. same true of shadertoy.com. example like this beautiful runs @ 20fps in it's tiny window , 1fps fullscreen on 2014 macbook pro , yet mbp can play beautiful games huge worlds rendered fullscreen @ 60fps . in ...

ios - How to use variable that have value outside the code block -

what im trying print (output : western australia) self.statename = state["provincestatename"] to detailaddressarr = ["\(userdata!["addressline1"] as! string)", "\(userdata!["addressline2"] as! string)", "\(userdata!["city"] as! string)", "\(userdata!["postalcode"] as! string)", self.statename, "\(userdata!["countrycode"] as! string)"] but when run, return nothing. here code class myprofileviewcontroller: baseviewcontroller, uitableviewdelegate, uitableviewdatasource,fbsdkloginbuttondelegate, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var profiletableview: uitableview! @iboutlet weak var profileimg: uiimageview! @iboutlet weak var bigidlbl: uilabel! @iboutlet weak var usernamelbl: uilabel! let personalarr = ["salutation", "given name", "family name", "date of birth...

web applications - How to secure a spring webapp using a LDAP server -

i have webapp created using spring , maven. means not have web.xml. need know how secure web app using spring security. need connect ldap server , cross check credentials against it. complete beginner in scenario. please help. guidelines or tutorials welcome. the best starting point excellent reference documentation . there's getting started guide here . if have specific problems or questions details in documentation or guide, feel free ask again :)

javascript - Alert not showing value of td element's id on click. -

i want id of td element on it's click. javascript code - $('#example').on('click', '.alertshow', function () { var id=$(this).closest('td').attr("id"); alert(id); } and html <table border="1" id="example"> <tr> <td class="alertshow" id="2_0"> </td><td class="alertshow" id="2_1"> </td><td class="alertshow" id="2_2"></td> <td class="alertshow" id="2_3"></td> <tr> <tr> <td class="alertshow" id="3_0"> </td><td class="alertshow" id="3_1"> </td><td class="alertshow" id="3_2"></td> <td class="alertshow" id="3_3"></td> <tr> </table> try ...

c# - Asp.Net MVC routing not accepting & in the route -

i have default asp.net route follows: routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); nothing special in it. and have super simple default action in home controller: public actionresult index(string id) { viewbag.message = "modify template jump-start asp.net mvc application."; return view(); } i can type url: http://localhost:12143/home/index/hanselandcratel and works fine when type in http://localhost:12143/home/index/hansel&cratel it doesn't i understand & has encoded when type in: http://localhost:12143/home/index/hansel%26cratel it still doesn't work error: a potentially dangerous request.path value detected client (&). i aware of setting in web.config: <httpruntime targetf...

mysql - Updating two tables with an inner join -

i have 2 tables 1 question , other answer . question table has fields question_id, question, type, answer_id. answer table has fields answer_id, question_id, comment, rating, doctor_id now want update answer belongs question doctor_id. tried write query : update question q set q.question = 'dmvvnnv',a.comment = 'covonfvk',a.rating = 5 inner join answer on q.answer_id = a.answer_id a.doctor_id = 8 but giving me syntax error : 1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near 'inner join answer on q.answer_id = a.answer_id a.doctor_id = 8' @ line 1 for mysql update join syntax different, set part should come after join use following query update entries: update question q inner join answer on a.answer_id = q.answer_id set q.question = 'dmvvnnv' ,a.comment = 'covonfvk' ,a.rating = 5 a.doctor_id = 8

osx - NSPressGestureRecognizer called before minimumPressDuration -

i need nsbutton respond regular clicks, long presses. adding nspressgesturerecognizer so: override func viewdidload() { super.viewdidload() let gr = nspressgesturerecognizer() gr.minimumpressduration = 1 gr.action = #selector(handlelongpress) button.addgesturerecognizer(gr) } func handlelongpress(gr: nspressgesturerecognizer) { if gr.state == .began { swift.print("long press") } } unfortunately, handlelongpress randomly fires @ short single clicks, or double clicks. happens if set minimumpressduration higher values. i have tried playing shouldberequiredtofailbygesturerecognizer not solving problem. is there missing code? i have solved handling multiple gesture recognizers: the class must implement nsgesturerecognizerdelegate var singleclick:nsclickgesturerecognizer? var longclick:nspressgesturerecognizer? override func viewdidload() { super.viewdidload() longclick = nspressgesturerecognizer() ...

java - Which command should i use to execute particular class without main in cmd while runnable jar file is created for whole project -

i have created classes under package without main method , maintain 1 util class main method in different package run.. executing classes of junit.. have created runnable jar file whole project , i want execute particular class without main method in cmd of jar file.

java - Oracle SQL Developer, how DATE is stored? -

this question has answer here: how can set custom date time format in oracle sql developer? 8 answers i'm using oracle database java application. in db have created table column of type date , application populated table dates precision seconds. now application able retrieve date precision seconds , works fine. i'm using oracle sql developer keep eye on in database, , here comes problem, when inside table table view in column date can see date in format of 16/09/07 without time of hours/minutes/seconds. also if run script: select saved_date my_table; it returns dates in format of 16/09/07 without time of hours/minutes/seconds. how can inspect oracle sql developer precise time stored in column? see ixora . on contrary other databases , java, oracle's date datatype contains hours, minutes , seconds. byte 1: century + 100 ...

javascript - Chartjs - how to make line position to vertical center and how to display dotted sharp in the backround? -

Image
i ask how configure chart using chartjs library result similar on image below in right way? tried find option in documentation http://www.chartjs.org/docs/#line-chart-chart-options , without luck. many advice. chart.js version 2+ use borderdash property in scales.x|yaxes.gridlines configuration object. http://www.chartjs.org/docs/#grid-line-configuration example : http://codepen.io/anon/pen/wzazda?editors=0010#0 var options = { scales: { xaxes: [{ gridlines: { display: true, linewidth: 1, borderdash: [1, 2], color: "black" } }], yaxes: [{ gridlines: { display: true, linewidth: 1, borderdash: [1, 2], color: "black" } ...

c# - Different version of a nuget package is being installed and referenced during build to the project references and packages -

on our build server have solution projects reference version 3.6 of rabbit client tools nuget package. when build solution on build server seems downloading version 4.0.2 of rabbit client tools. though there no reference dll either in code, or easynetq library i'm using alongside far can tell. i've tried: clearing nuget cache on server cleaning checkout directories changing rabbit client nuget version checked assembly binding versions in app.config. all correct before build occurs. as aside, don't know if make difference, assembly redirects in app , web configs apps being switched 4, though local code 3.6.5. also, seem build fine through visual studio 2015 i'm assuming must can left behind on server somewhere nuget. packages.config: <packages> <package id="easynetq" version="0.62.1.445" targetframework="net452" /> <package id="easynetq.management.client" version="0.51.1.105" targ...

c++ - Eigen and SVD to find Best Fitting Plane given a Set of Points -

given set of n points in 3d space, trying find best fitting plane using svd , eigen. my algorithm is: center data points around (0,0,0). form 3xn matrix of point coordinates. calculate svd of matrix. set smallest singular vector corresponding least singular value normal of plane. set distance origin plane normal∙centroid. i can't figure out how use eigen's svd module find smallest singular vector corresponding least singular value of point coordinates matrix. so far have code (steps 1, 2 , 5 of algorithm): eigen::matrix<float, 3, 1> mean = points.rowwise().mean(); const eigen::matrix3xf points_centered = points.colwise() - mean; int setting = eigen::computethinu | eigen::computethinv; eigen::jacobisvd<eigen::matrix3xf> svd = points_centered.jacobisvd(setting); eigen::vector3d normal = **???** double d = normal.dot(mean); denoting u = svd.matrixu() , vectors u.col(0) , u.col(1) defines base of plane , u.col(2) normal plane. u.col...

angularjs - Using Angular to post data to Moodle API -

according answers previous questions posting data server api angular , need post data plain-text string instead of json . however, thinking there built-in function within moodle library deals json posted it, in case should able send json. correct? and if is correct, should url-encode json string? this function far, inside controller. myapp.controller('mydatactrl', function ($scope, $http) { url = concaturl + 'local_webservice_ws_get_mydata'; // updateurl = concaturl + 'local_webservice_ws_set_mydata'; // set $http.get(url).then(function (response) { $scope.mydata = response.data; }); $scope.sendmypost = function () { // writing server $http.post(updateurl, $scope.mydata).then(function (response) { // success $scope.server_response = [ { 'message':'your settings have been updated' } ]; }, function (response) { // error $scope.server_response ...

php - Laravel : One is to Many Relationship, get foreign key value -

i'm working on productcategories , products relationship one many . wonder why i'm having error call undefined method stdclass::products() here's model products <?php namespace app; use illuminate\database\eloquent\model; class product extends model { public $table = "products"; public $fillable = ['productcategory_id', 'name', 'description', 'price', 'pic', 'availability', 'featured', ]; public function productcategory() { return $this->belongsto('app\productcategory'); } } and here's model product category <?php namespace app; use illuminate\database\eloquent\model; class productcategory extends model { public $table = "productcategories"; public $fillable = ['name', 'descri...

DocumentDB SQL Query works in Query Explorer but not in C# code -

i want value of variable(inputassetid) stored in document string.wrote query.it works fine in queryexplorer. this.client = new documentclient(new uri(endpointuri), primarykey); iqueryable<asset> id = this.client.createdocumentquery<asset>( urifactory.createdocumentcollectionuri(databasename,collectionname), "select c.inputassetid c c.blobnamedb='bigbuckbunny.mp4' "); console.writeline( id.string()); instead of value stored in variable,what got in console given below {"query":"select c.inputassetid c c.blobnamedb='bigbuckbunny.mp4' "} can please give me solution? the issue aren't ever executing query you've created. correct code along lines: this.client = new documentclient(new uri(endpointuri), primarykey); var query = this.client.createdocumentquery<asset>( ... linq or sql query... .asdocumentquery(); var result = await query.executenextasync...

Apple Wallet Animation for Android -

i in search of apple wallet kind of animation android. can please me out of this. link 1 : https://github.com/3lvis/cardstack link 2 : https://android-arsenal.com/details/1/3096 these points looking out in animation module first screen cardstack once click on card , should opened detailed card screen pop effect in ios next card can viewed there swiping view right or left when card dragged below should again come stack if dragged up/right/left should dragged position

Is there any way I can execute a PHP script from MySQL? -

i want invoke , execute php script mysql procedure. possible? create procedure simpleproc (out param1 int) begin call php script here end// [edit] in fact trying raise event when condition met — instance when table field value matches current time. then, want capture event , send email. it's possible, see mysql faq explanation of how can triggers call external application through udf? but it's bad design on part if have resort this

r - How to reload a shiny application -

i've developed shiny application (using shinydashboard) , i'd save "session" (by session mean values of input , data load user). want save in .rdata file , able restart app, load .rdata file , data , input defined user , hence output... is there way such thing shiny ? thanks i tried save r environment in .rdata file using save.image but did not work out. worked though using save , load functions store , restore .rda files. as naming use timestamp maybe differentiate between users. edit (example) okay, in app there 2 selectinput elements: first , , second . if of these change, values of these inputs assigned 2 variables: first_var , second_var saved test.rda file. if file exists variables loaded session. so basically, if run app first, whenever change inputs, saved .rda file. if exit , rerun app, variables loaded, , set selected value of inputs. library(shiny) if(file.exists("test.rda")) load("test.rda") ui <- fl...

Wordpress Options-Page to own Database Table -

i'm learning programming plugin wordpress. had create option page input fields. work , input datas saved in wordpress database table wp_options. i had create own database table wordpress , want save informations these input field in own table. does know how must prepare copy of options.php own informations saved in own table? since values saved in wp_options table, believe have valid connection wp database on page. save own table, use wordpress database class reference $wpdb: $wpdb->insert( 'table', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) ); where 'table' custom table, 'column1' column , 'value1' form value. view full detail of wordpress database class reference via https://codex.wordpress.org/class_reference/

Dynamic links using PHP and MySQL in a loop -

i'm learning php , mysql self-project , apparently got stuck. site trying make includes submitting forms , reviewing them. i've managed create loop in order display forms have been submitted , not yet processed (therefore, prone review), , each form has own link redirects data said form includes. $query = mysqli_query ( $conn, "select * members username = '$myrealusername' limit 1" ); $result = $query->fetch_assoc (); $id = $result ['id']; echo 'welcome ' . $id . '. <br>'; $quer = mysqli_query ( $conn, "select count(*) total carforms aboveid='$id' , processed='0'" ); $data = $quer->fetch_assoc (); $total = $data ['total']; $quer = mysqli_query ( $conn, "select fullname currentname, formid currentform carforms aboveid='$id' , processed='0'" ); ($x=1; $x<=$total; $x++) { $data = $quer->fetch_assoc (); $f...

asp.net mvc - Searching & sorting with AJAX pagination in MVC4 -

i developing mvc4 application searching, paging , sorting. works fine normal view. converting same application using ajax & partial view. how can pass search & sort parameter through paging control residing on partial view. now, able load filtered data in partial view moving next page, lost search parameters , loads records ignoring search filters. my paging control in _partialview.cshtml @html.pagedlistpager(model, page => url.action("ajaxmethod", new { page, searchbyusername = request.querystring["searchbyusername"], searchbyreadername = request.querystring["searchbyreadername"], searchbyreadertype = request.querystring["searchbyreadertype"], searchbyuploaddate = request.querystring[...

python - Is it possible to skip breakpoints in pdb / ipdb? -

is there way tell pdb or ipdb skip future break-points , finish execution if weren't there? maybe can try clear. from help: '(pdb) clear cl(ear) filename:lineno cl(ear) [bpnumber [bpnumber...]] space separated list of breakpoint numbers, clear breakpoints. without argument, clear breaks (but first ask confirmation). filename:lineno argument, clear breaks @ line in file. note argument different previous versions of debugger (in python distributions 1.5.1 , before) linenumber used instead of either filename:lineno or breakpoint numbers. there topic discuss of question: how exit pdb , allow program continue?

wso2esb - WSO2 ESB REST API Chaining issue -

i facing issues when doing service chaining wso2 esb. below xml file. following use case. need call service 1, response, validation check on , call service 2. through below code able call service 1. service 2 request, have hard coded request in payload. issue coming when setting header parameters. header properties not getting set due call service 2 not going. testing purpose have kept both urls same. please let me know following: 1. how set http header values. 2. there way persist initial input request , use in second service call. although synapse configs not there i'll answer question. you can 2 ways. 1 using header mediator. can reffer this doc. example code below, <header name="accept" value="image/jpeg" scope="transport"/> the second approach using property mediator, can set header value , set scope transport. header property added. what need assign original request content property, can use later. there many ways...

html - Bootstrap dropdown menu - display second bootstrap navbar -

i have bootstrap 3 navbar out of box dropdown-menu functionality is there way have second navbar displayed/transitioned on dropdown-toggle of button? have nicely formatted <nav class="navbar navbar-default"> <div class="container"> with our sub-menu items displayed. similar how www.bbc.co.uk site works when click "more" button - second centralised navbar displayed rather dropdown-menu (and hidden when button pressed again) bootstrap provides different built-in components can use according needs. it has collapse component can used open , close block when click on specific element. you can use component inside .navbar , inside .collapse body of component can use more .dropdown items if want. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></scr...

javascript - How to Decrypt RSA encrypted string from JSEncrypt using C# BouncyCastle -

i know there few posts regarding this, none of them solve issue cut chase. i have encrypted string using jsencrypt (javascript) following code: var rsa = new jsencrypt(); rsa.setpublickey(pubkey); var encrypted = rsa.encrypt($(this).text()); the public key stored in var so: var pubkey = "-----begin public key-----\ migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqckskehcz6ztvnxkghbckfeenkf\ 38j1hegww9uazlg5a7m/1aahkqkvkuofox+zsyh4cjr/mevmrea2ucpjkljxk14m\ 74nzswyupxaikpfwxe7qvn1/0tiqahvheismqielil+ghiyac32e/wuyjhgfjbwl\ ej/hbdtkt6o/qajwkwidaqab\ -----end public key-----"; i use generated cipher text , send c# needs decrypt it. using bouncy castle , have written code such: public string decrypt(string ciphertext) { var bytestodecrypt = convert.frombase64string(ciphertext); asymmetriccipherkeypair keypair; using (var reader = file.opentext(appdomain.currentdomain.basedirectory + @"/scripts/private.pem")) { keypair = (a...

javascript - Creating a dynamic bar chart in Planet Press Connect and need to add labels -

i working in planet press connect. have created dynamic bar chart , need add labels data. can me. beginner in java script not sure do. below code have. creates need except labels. if (results.length) { // data-chartdata attribute holds key value pairs of data var chartdata = []; function addvaluetoseries(labelfield, valuefield) { var temp = {}; temp['value_label'] = record.fields[labelfield]; // number of series dynamic, add value each series (var = 0; < record.tables['age'].length; i++) { temp['values_' + (i+1)] = record.tables['age'][i].fields[valuefield]; } chartdata.push(temp); } addvaluetoseries('pls_age2', 'pls_ageavg'); results.attr('data-chartdata', json.stringify(chartdata)); // connect series values var series = []; (var = 0; < record.tables['age'].length; i++) { series[i] = { 'title' : record.tables['age'][i].fields['pls_ageavg'], ...

visual studio code - How to config vscode to work with Typescript 2 RC? -

i want work typescript 2 rc (actually v2.0.2) in vscode. how can configure editor work that? note: want use npm based type declarations. vs code ships recent stable version of typescript. if want use newer version of typescript, can define typescript.tsdk setting ( file > preferences > user/workspace settings ) pointing directory containing typescript tsserver.js file. to install latest typescript version, run: npm install typescript@next tip: specific typescript version, specify @version. example typescript 2.0, use npm install typescript@2.0.0. you can find installation location using npm list typescript , tsserver.js under lib folder. for example: { "typescript.tsdk": "node_modules/typescript/lib" } the directory path can absolute or relative workspace directory. using relative path, can share workspace setting team. refer blog post more details on how install nightly builds of typescript. after setting typescript.ts...

CouchDB will not install as a service on Azure Windows VM -

i have installed couchdb on azure windows vm (classic) without problems using installer setup-couchdb-1.6.1_r16b02.exe downloaded http://couchdb.apache.org/ today have uninstalled existing couchdb installation , service intention of installing again scratch. unfortunately, whenever run installer fails create windows service. more info: i running installer , command tool administrator i have removed existing services using sc command , editing registry (tried both methods) i have tried creating service after installing couchdb using installer running command: erlsrv.exe add "apache couchdb" -workdir "%couch%\bin" -onfail restart_always -args "-sasl errlog_type error -s couch +a 4 +w w" -comment "apache couchdb 1.6.1" this seems create service (which can see in windows services) attempt start service results in error: windows not start apache couchdb service on local computer. error 1067: process terminated unexpe...

ios - How to add custom view to JSQMessagesViewController cell so that it includes one view with some buttons and text view? -

Image
i using https://github.com/jessesquires/jsqmessagesviewcontroller/issues/1820 library chat application. using libary able send images , video, app needs send 1 view button , text. when user sends text appear others text , button , when clicks button 1 push notification generated. not able figure out how can achieve this. here screen shot how want custom view be. has text user has typed , has 2 button accept , reject. i suggest create own custom view this. can use jsqincomingcollectionviewcell.xib or jsqoutgoingcollectionviewcell.xib template self. copy them example project , paste them own rename files else cellwithconfimationbuttons in chatviewcontroller i.e. ever called view subclass of 'jsqmessagesviewcontroller'. add these 2 lines self.collectionview.registernib(uinib(nibname: "cellwithconfimationbuttons", bundle: nil), forcellwithreuseidentifier: "incomingcell") self.collectionview.registernib(uinib(nibname: "cellwit...

Gulp path wildcard for second part of a folder name? -

with gulp can see wildcards in path 'src/**/*' . how can set wildcard second part of folder name? if have these folders: src/match-1 src/match-2 src/dont-match how can match first two? tried doesnt match anything: 'src/match-**/*' check @you's comment answer. here's why works: in **/* doesn't mean "wildcard!" it's saying in directory or subdirectory ( ** ) match file name ( * ) (more strictly speaking, "in directory or non-symlinked subdirectory, add on number or characters") that's why want src/match-* - * suspect thought **/* did. to familiarize globbing, read through @isaacs' glob primer , write tests globtester

Ruby on rails -Devise - Require password to delete account -

currently users need enter password in order change email address or password, can delete account without entering it. not sure how require this. so far have: users controller: def destroy @user = user.find(current_user.id) @user.destroy_with_password(user_params) if @user.destroy redirect_to root_url, notice: "user deleted." else redirect_to users_url flash[:notice] = "couldn't delete" end end def user_params params.require(:user).permit(:username, :email, :password, :password_confirmation, :current_password, :avatar, etc....etc.... ) end a form: <%= simple_form_for(@user, :method => :delete) |f| %> <%= f.input :current_password, autocomplete: "off" %> <%= f.button :submit %> <% end %> here user deletes if no password inputted. delete request being processed correct controller action ;...

asp.net mvc - Migrating Web Form to MVC - VIewModel from stored procedures -

i have been tasked migrating asp>net web form website asp>net mvc project. reason 2 fold. site needs updating means of learning mvc. the web forms application has sql backend , uses stored procedures extensively. therefore not using code first mvc model, creating model existing tables. my question is, should using stored procedure have been created web form project create viewmodel files or advisable import tables , create new viewmodels manually required? i believe there tool called automapper reduces time manually create viewmodels creating more work necessary when stored procedures have been created?

Drawing a two colored checker board with nested for loops where each square being their own object (Java) -

i attempting draw checkerboard pattern in java using nested loops, having trouble doing 2 different colors. know question has been asked before, hasn't been asked 2 different colors on board not using background color. plan on using individual squares array hold checker positions, need each individual square made. better drop ice of nested loop create each square, or should stick shortcut? , if stick it, how nested loop formatted (one each color)? when creating checker tiles, pass in int x coordinate, , y coordinate such as: import java.awt.color; import java.awt.graphics; public class checkertile { public static final int width = 100; //width of each tile public static final int height = 100; //height of each tile, same width square public static int currentid = 0; //variable reference unique id each tile private int id; //current id of tile private int x; //x coordinate ...

scala - Mapping over HList raises AbstractMethodError -

i trying shapeless example in repl , getting runtime error: scala> import shapeless._ import shapeless._ scala> import shapeless.poly._ import shapeless.poly._ scala> object choose extends (set ~> option) { | def apply[t](set: set[t]) = set.headoption | } defined object choose scala> val sets = set(1) :: set(0) :: hnil sets: shapeless.::[scala.collection.immutable.set[int],shapeless.::[scala.collection.immutable.set[int],shapeless.hnil]] = set(1) :: set(0) :: hnil scala> sets map choose java.lang.abstractmethoderror: choose$.caseuniv()lshapeless/polydefns$case; ... 42 elided do know why doesn't work , how fix ?

asp.net - Umbraco temporary page -

Image
i building umbraco 7.4.3 site, , ended situation. have node structure inside umbraco this. so, have student , teacher node under home. the student node show detail student. now want have page can edit student, "i want separate page (not popup) linking page can edit student", /edit-student/?id=2. but in order end in structure this, see screenshot see? have node editstudent have page can edit student, can call page /student/editstudent/?id=2 but don't want have node "editstudent", feel making node structure dirty. i want solution that can still have url /student/editstudent/?id=2 don't want see node "editstudent" under student or somewhere else inside umbraco. is possible happen? virtual url (but not aspx) pages. found answer posted @ our.umbraco.org forum. just create template , ill name "edit", can access url: /student/edit/, , of course can add parameters. if there no other node name "edit"...

javascript - Prevent window scroll below fold until button click -

i have situation need page not scrollable past point (i have hero set 100vh , user should not able scroll @ all) , upon click of button scroll prevention disabled , user automatically smooth scrolled down anchor link directly below (basically scroll down 100vh or full window height). need smooth scrolling animation instead of quick jump. i've tried playing around variations of following code no luck. far buggy , jumps around , when reload page body overflow set hidden window position not @ top of screen still see of below fold content still cant scroll. function() { function smoothscroll(){ windowheight = $('window').height(); $('html, body').stop.animate({scrolltop: windowheight}, slow); } $('.bottom-nav').on('click', '.fold-trigger', function(event) { $('.home').css('overflow', 'visible'); settimeout(smoothscroll(), 1000); }); }; fiddle here: https://jsfiddle.net/njpatten/yxkvnymu/1/ ...

ruby on rails - How to extract only year from created_at column -

querying database created_at value gives following output: >> kevin.created_at => sun, 21 aug 2016 07:46:26 utc +00:00 how can extract year information? tried treat kevin.created_at string , see if want with: >> kevin.created_at.split[3].to_i however message: nomethoderror: undefined method `split' sun, 21 aug 2016 07:46:26 utc +00:00:time therefore tried with: >> kevin.created_at.to_a => [26, 46, 7, 21, 8, 2016, 0, 234, false, "utc"] so may have solution with: >> kevin.created_at.to_a[5] => 2016 is there better or more elegant solution query postgresql information? you can use .year function ruby time class as: kevin.created_at.year

sql server - Why does SSMS drop and recreate a table when attempting to Alter a column from varchar(8000) to varchar(MAX)? -

when attempting alter column in table varchar(8000) varchar(max), ssms generates script drops constraints on table, creates new table, inserts data old table new, drops foreign keys old table, drops old table, renames new table, recreates foreign keys on new table. safer running 'alter table tablea alter column columna varchar(max)'? when want run ssms generated script vs 'alter table tablea alter column columna varchar(max)' script? they not functionally same. varchar(8000) has maximum of 8,000 characters. varchar(max) can technically store 2^31 - 1 (2,147,483,647) characters. https://technet.microsoft.com/en-us/library/ms176089(v=sql.110).aspx

oracle - Finding the group of 3 minutes for each ID in Hive SQL -

i having data such , id time 1 9/6/2016 00:01:00 1 9/6/2016 00:01:30 1 9/6/2016 00:02:00 1 9/6/2016 00:04:30 1 9/6/2016 00:05:30 1 9/6/2016 01:05:30 1 9/6/2016 05:05:30 1 9/6/2016 05:06:30 2 9/6/2016 01:55:00 2 9/6/2016 01:56:29 2 9/6/2016 01:57:31 2 9/6/2016 03:55:00 2 9/6/2016 04:13:00 2 9/6/2016 04:15:21 for each id, want set new variable called flag 1 , check first value of time. first value of time, want check entries within 3 minutes first entry , set every thing 1. once time entries above 3 minutes, want set flag variable 2 , again check entries within 3 minutes time , needs go on each id. want find 3 minutes groups each id, can form sets each id. the output want is, id time flag 1 9/6/2016 00:01:00 1 1 9/6/2016 00:01:30 1 1 9/6/2016 00:02:00 1 1 9/6/2016 00:04:30 2 1 9/6/2016 00:05:30 2 1 9/6/2016 01:05:30 2 1 9/6/2016 05:05:30 2 1 9/6/2016 05:06:30 2 2 9/6/2016 01:55:00 1 2 9/6/2016 01...