Posts

Showing posts from September, 2015

A way to access google streetview from R? -

Image
there nice interface google earth images available via ggmap . example: ggmap::get_map(location = c(lon = -95.3632715, lat = 29.7632836), maptype ="satellite",zoom=20) will return satellite map image google maps/earth. on google maps website if zoom bit more, switches streetview. there similar way r streetview images? there seem api , can't find analogous ggmap interface in r. my googleway package has google map widget (and works with shiny ). you'll need valid google api key use it library(googleway) ## valid api key here #key <- read.dcf("~/documents/.googleapi", fields = "google_map_key") df <- data.frame(lat = -37.817714, lon = 144.967260, info = "flinders street station") google_map(key = key, height = 600, search_box = t) %>% add_markers(data = df, info_window = "info") ## other available methods # add_markers # add_heatmap # ad...

javascript - How to trace all paths of a tree like data structure? -

let's have nested object so: { label: 'parent', eyecolor: 'brown', kids: [ { label: 'kid_0', eyecolor: 'brown', kids: [ { label: 'kid_0_0', eyecolor: 'green', kids: [] }, { label: 'kid_0_1', eyecolor: 'brown', kids: [ { label: 'kid_0_1_0', eyecolor: 'brown', kids: [] } ] } ], }, { label: 'kid_1', eyecolor: 'brown', kids: [ { label: 'kid_1_0', eyecolor: 'brown', kids: [] } ], }, { label: 'kid_2', eyecolor: 'green', kids: [] } ] }; if wanted store unique paths, how recursively? i've tried many attempts, can't seem obtain unique paths (m...

javascript - Event touchstart doesn't work on iPhone -

i have code works, except on iphone. when window loads, function called. when have event click , works fine on desktop, not on mobile. i've tried looking around solutions mobile, , touchstart seems recommended solution. but, though works on emulators, doesn't work on iphone (tested on latest os version). missing something? function addxclassonclick() { var els = document.getelementsbyclassname('item'); array.prototype.foreach.call(els, function(el) { el.addeventlistener('touchstart', function() { el.parentelement.classlist.toggle('x'); }, false); }); } thanks in advance! given document fragment: <div class="x"> <div class="item">item</div> </div> the anonymous event handler function's default scope bound clicked element, , not clicked element's parent, scope classlist.toggle should operate on. (edit: according documentation, foreach passes undefine...

java ee - Trying to generate db tables with spring boot project -

org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaautoconfiguration.class]: invocation of init method failed; nested exception org.hibernate.boot.registry.selector.spi.strategyselectionexception: unable resolve name [org.hibernate.dialect.mysql5dialect] strategy [org.hibernate.dialect.dialect] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1578) ~[spring-beans-4.2.3.release.jar:4.2.3.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:545) ~[spring-beans-4.2.3.release.jar:4.2.3.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482) ~[spring-beans-4.2.3.releas...

java - Spark Framework and relative path -

i'm using spark framework create web app , i've been going through tutorials on site. @ moment, i'm working on templates section, can't seem project recognize css , templates in resources folder. i'm using netbeans , maven manage dependencies. can me figure out how set relative paths/create project folders appropriately in environment? i'm newbie both maven , spark, go easy please. static files: if resources directory looked this: resources └───public ├───css │ style.css ├───html │ hello.html └───templates template.ftl you use staticfiles.location("/public") . make /public root staticfiles directory. you access hello.html this: http://{host}:{port}/html/hello.html if wanted use external location on filesystem, use staticfiles.externallocation(...) , works pretty same way above. note: staticfiles.externallocation(...) can set project's resources directory, means files au...

javascript - Angular 2 Role based navigation on same path -

i've small question regarding angular 2 router using version 3.0.0-rc.1 want navigate different home component based on user role such admincomponent or usercomponent. can please in modifying below routes can achieve desired functionality? {path: 'login', component: logincomponent}, <----this redirects '/' in case user logged in { path: '', component: homecomponent, canactivate: [authguardservice], <-----check if user logged in, else redirect login children: [ { path: '', component: admincomponent <---- want navigate here if user role 'admin' }, { path: '', component: usercomponent <----- want navigate here if user role 'user' } ] } authguardservice.ts import {injectable} "@angular/core"; import {canactivate, router, activatedroutesnapshot, routerstatesnapshot} "@angular/router"; import {authservice} "./auth...

ReactJS Warning: Each child in an array or iterator should have a unique "key" prop -

var divarr = [ '<div>布吉岛啊</div>', '<div>呵呵呵</div>', ]; reactdom.render( <div>{divarr}</div>, document.getelementbyid("example") ); but it's error: warning: each child in array or iterator should have unique "key" prop. check top-level render call using . see [warning-keys][1] more information. and don't know how insert 'key' you need put unique key inside array div check code var divarr = [ '<div key='1'>布吉岛啊</div>', '<div key='2'>呵呵呵</div>', ]; reactdom.render( <div>{divarr}</div>, document.getelementbyid("example") );

javascript - Angular 2 authenticate state -

i've implemented login page using angular 2. after login, jsonwebtoken, userid, userrole, username server. i'm storing info in localstorage can access time , maintain login state if user refreshes page. authservice.ts import {injectable} "@angular/core"; @injectable() export class authservice { redirecturl: string; logout() { localstorage.clear(); } isloggedin() { return localstorage.getitem('token') !== null; } isadmin() { return localstorage.getitem('role') === 'admin'; } isuser() { return localstorage.getitem('role') === 'user'; } } to check login status, i'm checking if token exists in localstorage. localstorage editable adding token in localstorage bypass login page. similarly, if client edit user role in localstorage, client can access admin or user pages. how solve these problems? this more general problem, want know how websites maintain login status? p.s. nodej...

javascript - How to maintain react component state when goback from router? -

i have 2 react components let , b. when shown on page, user changes on page cause states changed inside a. user click button navigate b router.push('/b') . user click back button , navigate page done router.goback() . current url updated states gone. how can maintain state when user go a? i think need enable browserhistory on router intializing : <router history={new browserhistory}> . before that, should require browserhistory 'react-router/lib/browserhistory' i hope helps ! var browserhistory = require('react-router/lib/browserhistory').default; var app = react.createclass({ render: function() { return ( <div>xxx</div> ); } }); react.render(( <router history={browserhistory}> <route path="/" component={app} /> </router> ), document.body); another way can try this, this.context.router.goback() no navigation mixin required! edit: update react v15 , reactrouter v3....

html - Radio button inside label width issue -

i have custom radio buttons , try display multiple radio buttons in 1 line. currently, code works fine issue adding fixed width label in case width:50px; . if text longer... text overlaps next radio button. there way can avoid having fixed widths? function calc() does't seem in situation. i also, tried using min-width instead of width . * { box-sizing: border-box; } input[type="radio"] { display: none; cursor: pointer; } label { cursor: pointer; display: inline-block; width: 50px; position: relative; } .radio span.custom > span { margin-left: 22px; } .radio .custom { background-color: #fff; border: 1px solid #ccc; border-radius: 3px; display: inline-block; height: 20px; left: 0; position: absolute; top: 0; width: 20px; } .radio input:checked + .custom:after { background-color: #0574ac; border-radius: 100%; border: 3px solid #fff; content: ""; display: block; height: ...

laravel - Create wildcard subdomain in xampp localhost -

i trying create wildcard subdomain in xampp local development of laravel project. far able change hosts file , create virtual host domain name. here hosts file 127.0.0.1 localhost 127.0.1.1 lalit-inspiron-3537 127.0.0.1 mysite.local # following lines desirable ipv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02: :2 ip6-allrouters i have enabled virtual hosts in httpd.conf file here httpd-vhosts.conf file # virtual hosts # # required modules: mod_log_config # if want maintain multiple domains/hostnames on # machine can setup virtualhost containers them. configurations # use name-based virtual hosts server doesn't need worry # ip addresses. indicated asterisks in directives below. # # please see documentation @ # <url:http://httpd.apache.org/docs/2.4/vhosts/> # further details before try setup virtual hosts. # # may use command line option '-s' verify virtual host # conf...

How to create and use a 1D layered texture in CUDA -

i new cuda. have figured out how 1d , 2d textures in cuda. however, struggling how use 1d layered texture. output of kernel uses texture zeros, incorrect. however, not sure doing wrong. have serious doubts set texture correctly, checked cuda errors everywhere , couldn't find issues. can show me how correctly set 1d layered texture , use it. here code. in advance: // compile: nvcc backproj.cu -o backproj.out // run: ./backproj.out // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> // includes cuda #include <cuda_runtime.h> #include <cuda_profiler_api.h> #define pi acos(-1) // 1d float textures texture<float, cudatexturetype1dlayered, cudareadmodeelementtype> texref; // 1d interpolation kernel: should similar if used 1d interpolation on matlab __global__ void interp1kernel(float* d_output, float* d_locations, int numlocations, int layer) { unsigned int location_idx = blockidx.x * bl...

fxcop - How to add the custom rules in sonarqube for c# and trigger the same -

how add custom rules created in stylecop or fxcop sonarqube c# , trigger same.? need put custom rule-set dll , xml file.?? little great.. for fxcop it's pretty straightforward: in sonarqube, use template custom fxcop rules (self-documented). for stylecop there a plugin it's deprecated.

php - Symfony3 how to store user roles in database -

symfony version: 3.1.3 database: mysql i have users table , has column roles (longtext-dc2type:array). in controller have created dropdown box form bellow, $user = new users; $form = $this->createformbuilder($user) // other fields ->add('roles', choicetype::class, array( 'attr' => array( 'class' => 'form-control', 'style' => 'margin:5px 0;'), 'choices' => array( 'teacher' => true, 'student' => true, 'parent' => true ), ) ) // other fields ->getform(); and getting user selected role bellow,(within same controller) if( $form->issubmitted() && $form->isvalid() ){ // other codes $role = $form['r...

html - How to stop svg animation with css? -

i want stop animation when animation completed. made 1 box , box made "s" symbol. when box make s want stop animation in s place. <svg viewbox="0 -150 300 600" width='400px' height='100%' id='layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' onload='init(evt)' enable-background="new 0 0 141.4 141.4"> <script type="text/javascript"> var svgdocument = null; var svgroot = null; function init(evt) { svgdocument = evt.target.ownerdocument; svgroot = svgdocument.documentelement; } function pause() { svgroot.pauseanimations(); } function play() { svgroot.unpauseanimations(); } </script> <g id="layer_1_copy"> <animatetransform begin="layer_1.mouseover" id="delayone" dur...

android - Getting only once permission for sdcard window on Lollipop and above version -

hello deleting items sd card. , in lollipop first time ask permission , user grant permission, don't want ask every time permission. irritating , many of guys afraid behavior. how can save permission i.e. next time don't need pass intent again , again intent intent = new intent(intent.action_open_document_tree); thank i give code example. remember u need check permission on android 6.0. onrequestpermission method when u have permission code in grantresult, if not u can ask permission or saying message user not give permission. , method save status permission @targetapi(23) public void checkstoragepermission() { if (build.version.sdk_int < build.version_codes.m) { if (settingsdrawerfragment != null) { settingsdrawerfragment.onpermissiongranted(); } return; } if (this.checkselfpermission(manifest.permission.read_external_storage) != packagemanager .permission_granted) { requestpermissions(ne...

javascript - ng-table not working | inject error -

i'm getting error when using, ng-table. angular.js:12332 error: [$injector:unpr] unknown provider: ngtableparamsprovider <- ngtableparams <- tablecontroller http://errors.angularjs.org/1.4.2/ $injector/unpr?p0=ngtableparamsprovider%20%3c-%20ngtableparams%20%3c-%20tablecontroller the code is, angular.module('ngtabletutorial', ['ngtable']) .controller('tablecontroller', [ '$scope', '$filter', 'ngtableparams', function ($scope, $filter, ngtableparams) { ... what correct way of resolving issue ? remember dependencies case sensitive. ngtableparams in example injected dependency included ngtableparams not ngtableparams

Pass data from parent to child component in vue.js -

i trying pass data parent child component. however, data trying pass keeps printing out blank in child component. code: in profile.js (parent component) <template> <div class="container"> <profile-form :user ="user"></profile-form> </div> </template> <script> import profileform './profileform' module.exports = { data: function () { return { user: '' } }, methods: { getcurrentuser: function () { var self = auth.getcurrentuser(function(person) { self.user = person }) }, } </script> in profileform.js (child component) <template> <div class="container"> <h1>profile form component</h1> </div> </template> <script> module.exports = { created: function () { console.log('user data parent component:') console....

angularjs - "Error: No default engine was specified" - Only sending json -

i keep getting error, , don't understand why. not running res.render anywhere, , have no view engine specified (do not need one), doing routing front end angular. here making simple request logged in user: controller.js angular.module('myapp').controller('admincontroller', ['$scope', '$http', function ($scope, $http) { $http.get('/api/user') .then(function(response){ $scope.user = response.data; }); }]); and on backend, here route returns json: api.js router.get('/api/user', function(req, res) { var session = req.session; var user = db.user.findbyid(session.passport.user, function(err, user){ console.log(user); res.json(user); }); }); in browser console, getting errors saying cannot http://localhost:3000/api/user 500 (internal server error) , , cli saying no default engine specified , no extension provided. why, if returning json, express asking view engine? ...

ruby on rails - How to get all 'specific days' within a date range -

how can let's dates saturday , sunday x year y year , store them array? pseudo code be (year_today..next_year).get_all_dates_for_saturday_and_sunday or perhaps there gems cater already? try this: (date.today..date.today.next_year).select { |date| date.sunday? or date.saturday? } #=> [sat, 03 sep 2016,sun, 04 sep 2016,sat, 10 sep 2016,sun, 11 sep 2016...

python - Error with two same views in different apps in django project -

working on django project. there 2 apps in project 1 custom defined "admin", , "home". using views same in both app eg:- admin app urls.py file is from django.conf.urls import url . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^logout$', views.logout, name='logout'), url(r'^dashboard$', views.dashboard, name='dashboard'), url(r'^profile$', views.profile, name='profile'), url(r'^edit-profile$', views.edit_profile, name='edit-profile'), url(r'^check-password$', views.check_password, name='check-password'), url(r'^testing$', views.testing_database, name='testing'), ] and home's app urls.py file is:- from django.conf.urls import url . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^sport$', views.sport, name='sport'), ...

mysql - Password holding different data (phpMyAdmin Database) -

Image
password varchar(120) above column name , datatype password set. using phpmyadmin database , created user testing purpose usertest username , user123 password. when checked database, instead of holding user123 password, holds 0dcbd056919392554f346a10cc114d27 . compared sql server database, sql server database hold exact data password user entered through registration. even so, still can login using user123 password username usertest . if used 0dcbd056919392554f346a10cc114d27 password, unable login system. i've notice , started wonder, admin, how going know user password 1 used register, if going through database? why on earth need know user's password? awful idea. explicitly don't want know user's passwords, or have means decrypt them. there many reasons why bad idea, 1 of them if user re-uses passwords , database compromised, user's plaintext password has been compromised. what more common hash password; taking user's password, combine...

java - method argument Array list variable's size is resetting back to zero after clear() and assigning new list value -

below code in getting arraylist populating temporary array after first while loop , 2nd time onwards stocks_tbcrawled getting assigned correct value in if block in loop , size resetting zero. please let me know going wrong in logic ? public void doconnectcall(list<string> stocks_tbcrawled){ try{ timeoutrequests = new arraylist<string>(); int retrycount = 0; while(retrycount < 3){ if(retrycount != 0 ){ stocks_tbcrawled.clear(); stocks_tbcrawled = timeoutrequests; timeoutrequests.clear(); } for(int listcounter = 0; listcounter < stocks_tbcrawled.size(); listcounter++ ){ try{ mfcount = 0; doc = jsoup.connect("http:xxx ).timeout(3000).get(); }catch(exception e){ ...

python - unable to scrape text -

i trying title of websites. so, used snippet this sys.stdout = open("test_data.txt", "w") url2 = "https://www.google.com/" headers = { 'user-agent': 'mozilla/5.0 (macintosh; intel mac os x 10_9_3) applewebkit/537.75.14 (khtml, gecko) version/7.0.3 safari/7046a194a'} req = urllib2.request(url2, none, headers) req.add_header('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8') html = urllib2.urlopen(req, timeout=60).read() soup = beautifulsoup(html) # extract title list1 = soup.title.string print list1.encode('utf-8') this works , gives google title , flushes output test_data.txt. but when try run same code web service, doesn't work. empty text file. hitting url run web service on local http://0.0.0.0:8881/get_title from bottle import route, run, request @route('/get_title') def get_title(): sys.stdout = ope...

android - E/NEW_BHD: Battery Power Supply logging Daemon start -

when run app on device above log in print error log know application side have problem or device related error ? e/new_bhd: battery power supply logging daemon start!!!!! yeah noticed on device, think it's universal bug or unnecessary/possibly useful logging within motorola's code.

node.js - import with require that works fine on windows but not on ubuntu -

here file tree : > appointment/ > db/ > db.js > appointment.js and in appointment.js made : require( './../appointment/db/db' ); //init database it works on windows on ubuntu 16.04 have error cannot find module './../appointment/db/db' if have idea. regards , thanks as said alexander ./db/db solution work fine on ubuntu & windows/

sql - unrelated data showing in the result(And,OR condition)? -

Image
this query: select top 10000 [reason_text] ,[ps1] ,[ps2] ,[ps3] ,[ps4] ,[ps5] samsung.[dbo].['newlp'] ( reason_text = 'not' or reason_text = 'in' or reason_text = 'back' ) , ps1 = 'u' , ps2 = 'u' or ps2 = '' , ps3 = 'u' or ps3 = '' , ps4 = 'u' or ps4 = '' , ps5 = 'u' or ps5 = '' so clause should have 3 values , ps1 should have 'u' value , ps2 should have 'u' or null , rest of ps's(ps3,ps4,ps5). the result i'm getting, first 2 ps's correct starting third 'and' ,which ps3 it's condition somehow ignored?!? here result: i need return selected ones(red rectangle around them). part of code wrong. i've tried every way nothing returned result need. tried code condition nothing showed. , ps1 = 'u' , ps2 <> 'p' , ps3 <> 'p' , ps4 <...

ios10 - Privacy policy changed in iOS 10, do we need re-submit our app? -

since ios 10 has changed privacy police i.e. need put privacy description in plist file. there question, needed re-submit our app again after ios 10 offically published? as plist need changed or apps crashed. anyone has idea or info me fingure this? what found in investigation if build app xcode7 don't have issue in new privacy settings, example if trying access camera or photo library not crash. but if build app using xcode8 crashes saying "privacy description access camera / photo library missing". so clear don't need re-submit app privacy update.while submitting next version (probably need use new xcode8) makesure added privavcy policy update.

Form id gets changing while submitting form in Drupal 7 -

for example: form id = "xyz" after submit form id="xyz--2" on validation error page. please me. you using wrong variable grab form id. otherwise it's not possible main form id changed. please print form array in hook_form , if using existing form, use hook_form_alter print form , check form_id there. form id main identity of form can not changed. if talk css id, can changed. please paste form array here. able tell appropriately then. thank you!!

Android resolveContentProvider returns null -

i want following in application. first need login. then, after log in quit application. running @ background. log in records still hold. need choose file file browser. after choosing file press share option. choose application operations on file. after make operations on file record cache. want open file on other appropriate application. can of them there problem while calling geturiforfile method. string mimetype = getmimetype(fileuri);//returns mime type file imagepath = new file(context.getcachedir(), "/"); string fileuristr = fileuri.getlastpathsegment(); file newfile = new file(imagepath, fileuristr); try { newfile.createnewfile(); } catch (ioexception e) { e.printstacktrace(); } uri = fileprovider.geturiforfile(context, context.getpackagename(), newfile); in manifest added fileprovider. <activity android:name=".mainactivity" android:label="@string/app_name"> <provider android:name="an...

c# - Email Validation in .Net mvc4 -

currently using following code email validation validate dsgf@g mail id please me [required(errormessage = "please enter email id")] [display(name = "email-id")] [emailaddress(errormessage = "invalid email address")] public string cust_email { get; set; } emailaddress attribute mark valid dsgf@g because valid email address, there nothing wrong method. consider example username@localhost example. if not suits can use regular expression ti set own rule validation. try use 'regularexpression' attribute instead, like: [regularexpression("^[^@\s]+@[^@\s]+(\.[^@\s]+)+$", errormessage = "invalid email address")] public string cust_email { get; set; } or [regularexpression(@"^([a-za-z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-za-z0-9\-]+\.)+))([a-za-z]{2,4}|[0-9]{1,3})(\]?)$", errormessage = "invalid email address")] public string cust_email { get; set; }

c++ - How to make QGraphicsTextItem single line? -

i have qgraphicstextitem behave lineedit, using settextinteractionflags(qt::texteditorinteraction); however show multiline if user presses enter. want ignore line wraps, how that? afaik qgraphicstextitem doesn't implement functionality. can trick subclassing qgraphicstextitem , filter keyboard events: class mygraphicstextitem : public qgraphicstextitem { // ... protected: virtual void keypressevent(qkeyevent* e) overriden { if(e->key() != qt::key_return) { // let parent implementation handle event qgraphicstextitem::keypressevent(event); } else { // ignore event , stop propagation e->accept(); } } };

ios - Switching the language directly in the application -

Image
have been trying localize app 7 languages, tutorials found display how on single page, not through out app. i @ point localization works when device of language, need have ability change languages via button. edit: below code works fine looking similar solution. notes below: the below groups of code create in app language change, including tab bar names. you must put data in localize.strings main.strings not work this. means need programmatically add "back", "cancel" , navigation titles, menu items. the nsnotificationcenter inside each of "changetoxx" func set notify tabbarviewcontroller (or controller need) language has changed. i import uikit let applanguagekey = "applanguage" let applanguagedefaultvalue = "" var applanguage: string { { if let language = nsuserdefaults.standarduserdefaults().stringforkey(applanguagekey) { return language } else { nsuserdefaults.standarduserdefaults().se...

cordova - Ionic App not running on Android Device -

i created app using pc browser when did android build , deploy on device stays @ blank white screen. so decided host files in /www debug. i error 0 619759 error uncaught typeerror: cannot read property '6' of undefined, http://10.12.1.205:8100/build/js/reflect.js , line: 894 20029 error uncaught reflect-metadata shim required when using class decorators, http://10.12.1.205:8100/build/js/app.bundle.js , line: 36793 any please ionic info cordova cli: 6.3.0 gulp version: cli version 3.9.1 gulp local: local version 3.9.1 ionic framework version: 2.0.0-beta.11 ionic cli version: 2.0.0-beta.37 ionic app lib version: 2.0.0-beta.20 os: windows 7 node version: v4.4.7 device info adv 4.2.2 kernel 3.4.5

c# - Response Redirect Doesn't Work -

i have problem in mvc response redirect. in code seems right, code goes it, right thing page doesn't refresh. function triggered button , function has response redirect code. here code. goes home/index, can see while i'm debugging home view doesn't show. note : first page login view public class logincontroller : controller { // get: login [intranetaction] public actionresult user() { return view(); } public void checkauthentication(userlogininfo logininfo) { bool isauthenticated = new ldapservicemanager().isauthenticated(logininfo); if (isauthenticated) { response.redirect("/home/index"); response.end(); } else { response.redirect("/", false); } } homecontroller index public actionresult index() { if (isdbexists()) { _contactlist = new list<contact>(); ...

javascript - Working with OfflineJS and AngularJS -

i working on angular app want integrate offlinejs functionality. have created general service getting , posting data to/from api,and specific service each module. here code app.service('methodprovider', function ($http) { var self = this; self.get = function (url) { var obj = { url: url, method: 'get', async: true, headers: { 'content-type': 'application/json' } }; return $http(obj); }; self.post = function (url, data) { var obj = { url: url, method: 'post', async: true, data: json.stringify(data), headers: { 'content-type': 'application/json' } }; return $http(obj); }; self.put = function (url, data) { var obj = { url: url, method: 'put', ...

c# - RequireHttps vs deriving from RequireHttpsAttribute -

i'm trying implement https on selected pages of site. using attribute requirehttps works causes problems testing don't have cert installed locally. the solution i'm looking need ignore localhost , ignore 1 test server while working on our second test server have cert in place. some further background on this. aim move site gradually https. it's ecommerce site portions secure , know many reasons moving entire site secure thing. know once move page page b b secure won't go http when move a, that's fine. want move site in stages in case there problems things mismatched content, site maps, seo, google ranking etc. some of various solutions have tried - i've implemented class derived requirehttps attribute follows: public class customrequirehttps : requirehttpsattribute { protected override void handlenonhttpsrequest(authorizationcontext filtercontext) { if (filtercontext.httpcontext.request.url != null && (!string.equals(fi...

java - How to serialize a double-wrapped list? -

i have following class public class someobject { @jsonproperty("otherobjects") private list<integer> otherobjects; } and want serialize following xml <someobject> <otherobjects> <objlist> <objref>123</objref> <objref>456</objref> <objref>789</objref> </objlist> </otherobjects> </someobject> i tried create custom jsonserializer: private static class objectlistserializer extends jsonserializer<list<integer>> { @override public void serialize(final list<integer> integers, final jsongenerator jsongenerator, final serializerprovider serializerprovider) throws ioexception, jsonprocessingexception { jsongenerator.writearrayfieldstart("objlist"); (integer integer : integers) { jsongenerator.writenumberfield("objref", integer); } json...

ruby on rails - Rendering string with erb content on page -

i found many posts problem, it's seems none of them solves problem. got code want render string: <%= button_to "/admin/#{contr_name}/#{obj.id}", method: :delete, class: 'btn btn-danger btn-resource-destroy', data: {toggle: 'tooltip'}, title: 'delete' %> <%= icon('trash-o') %> <span class='sr-only'>delete</span> <% end %> i have tried this: template += "<div class='col-sm-4'>" template += "<%= button_to \"/admin/#{contr_name}/#{obj.id}\", method: :delete, class: 'btn btn-danger btn-resource-destroy', data: {toggle: 'tooltip'}, title: 'delete' %> <%= icon('trash-o') %> <span class='sr-only'>delete</span> <% end %>" template += "</div>" erb.new(template).result(binding) but syntax errors. how can fix this? i suggest use partials instead. first, def...