Posts

Showing posts from September, 2011

javascript - How do I hide the download bar in a chrome extension? -

is there way hide downloads bar appearing @ bottom programatically after download complete in chrome extension? i have tried did not work: chrome.downloads.setshelfenabled(false); there no such feature provided chrome. can hide downloads automatically using following extension: https://chrome.google.com/webstore/detail/always-clear-downloads/cpbmgiffkljiglnpdbljhlenaikojapc/related in case want go through downloads list, there option of using ctrl + j

c++ - Virtual assignment operator not allowing static_cast -

i have following mwe code: #include <algorithm> class base{ public: int basemember; friend void swap(base& in, base& out) { using std::swap; swap(in.basemember, out.basemember); } virtual base& operator=(base obj) { swap(*this, obj); return *this; } base() : basemember(1) { } }; class derived : public base { public: int derivedmember; friend void swap(derived& in, derived& out) { using std::swap; swap(in.derivedmember, out.derivedmember); swap(static_cast<base&>(in), static_cast<base&>(out)); } virtual base& operator=(base obj) { swap(*this, static_cast<derived&>(obj)); return *this; } derived() : base(), derivedmember(2) { } }; int main() { base *b1 = new derived(); base *b2 = new derived(); *b1 = *b2; delete b1; delete b2; } i have 2 base

How to open different man page section in VIM (with K shortcut)? -

often times, there name overloading man page sections. example, tried lookup getopt(...) with shift k , vim opened getopt(1) wanted getopt(3) because i'm writing c-program. is there way specify man page section open in vim? thanks romainl, looked vim , proper way is <section number>k i.e. 3k under getopt open getopt(3).

sharepoint 2013 - Not able to add columns to Document Library from Visual Studio template -

i trying create new document library sharepoint project template visual studio 2015. while doing able create document library template , instance. if deploy solution 1 of site creates list well. strange thing if add column template , deploy creates list not create new custom column. below schema file template. <?xml version="1.0" encoding="utf-8"?> <list xmlns:ows="microsoft sharepoint" title="shareddocuments" direction="$resources:direction;" url="shareddocuments" basetype="1" xmlns="http://schemas.microsoft.com/sharepoint/" enablecontenttypes="true"> <metadata> <contenttypes> <contenttype id="0x0101000dba2955561e4de0a115152637e9f8e2" name="listfieldscontenttype"> <fieldrefs> <fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="title" /> <fieldref id="

javascript - User data using ajax requests not saved after a reload page -

i'm doing form_for reviews section nested under recipes#show page , doing ajax requests. i'm getting ajax post method intended , it's showing on page fine, problem it's not saving page after page reload. here code: reviews_controller.rb class reviewscontroller < applicationcontroller respond_to :html, :js def create @recipe = recipe.find(params[:recipe_id]) @review = @recipe.reviews.new(reviews_params) @review.chef = current_user @new_review = review.new if @review.save flash[:success] = "review saved" else flash[:danger] = "review failed save, please try again" end end private def reviews_params params.require(:review).permit(:body) end end recipes_controller.rb class recipescontroller < applicationcontroller before_action :set_recipe_find, only: [:edit, :update, :show, :like] before_action :require_user

javascript - Offline.js Cross-domain Image gives undefined -

i want web app know if it's online (to avoid google maps functions), use offline.js . i'm trying access image our website, web app not hosted online (it's run locally), access cross-domain. here code in $(document).one('ready', : offline.options = { checks: { image: { url: 'http://www.portalogic.info/images/portalogic.gif' }, active: 'image' } }; var on_line = offline.check(); console.log(on_line); but on_line = undefined . why this? there different way this?

Angularjs ng-repeat dynamic property -

<div (ng-repeat='item in items') > {{item.name}} //works {{item["name"]}} // works </div> how repeat item[property] dynamically without using ".name" or ['name']? to dynamically go through properties, you're going need call object.keys(item) , iterate through them. it's best prune data within controller, minimize finagling you'll need within html. if want try within html-angular structures, define: $scope.returnallkeyvalues = function(obj){ var x = object.keys(obj), arr = []; for(var = 0; i<x.length; i++){ arr.push(obj[x[i]]); } return arr; } what function takes in json object, parses through , collects values every key within it. then, within html, can write this: <h3>fifa mactch summary:</h3> <div ng-app ng-controller="myctrl"> <ul> <li ng-repeat="item in items"> <span ng-init=&q

jar - My Java program won't launch (.exe file) -

i have made gui based project consists of 1 main class, multiple object classes, , resource files (.png , .txt). have extracted project .jar file (via eclipse) , used crease .exe file (via launch4j). however, when run .exe file, not launch. is because not know class run (since there no manifest file)? possible fixes? a manifest (or androidmanifest.xml ) files android systems. while android "looks , feels" java, language. apk files jar, however, how processed , prepared different, since dex ed , bit flipped multiples of 4, can appear "real jar" program, instructions rubish, , have no meaning when executed. a jar file "java archive", , whole concept. supposing executable sourced correct apk project, launch4j should have failed creating *.exe . supposing executable sourced correct jar project, main executted (and if blank, runs completion, , ends). appears doing nothing, executes instructions.

python - JSON encoding and downloading from a URL -

i'm trying json steam inventory. data : def downloadstring(url): req = urllib.request.request( url, data=none, headers={ 'user-agent': 'mozilla/5.0 (macintosh; intel mac os x 10_9_3) applewebkit/537.36 (khtml, gecko) chrome/35.0.1916.47 safari/537.36' } ) f = urllib.request.urlopen(req) return f.read().decode("utf-8") now, problem encoding. steam using symbols "black star" ('\u2605') causes json part crash : def test(string): print(json.loads(string)) test(downloadstring(url)) file "c:\python34\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] unicodeencodeerror: 'charmap' codec can't encode character '\u2605' in position 83559: character maps i don't understand how can else... be... helpful. json can encoded in of utf-8, utf-16, or utf-32. try

sql server - SQL Delete not gettng the results i need. subquery, outer join -

i have requirement meet , can't seem figure out how delete records database entry. i have table gets updated daily structure id name eventnum state 1 1 4 2 1 2 3 1 3 4 1 9 5 b 3 1 due things out of control users allowed input same information, on nightly job when column "state" has entry of 9 delete rows of data have same name , eventnum (so id 1-4 delete). in oracle can subquery in microsoft sql looks can pass 1 column in in statement. ideas? you can either use correlated subquery or join subquery. might able use simple self-join (the last query listed). delete mt mytable mt inner join (select name, eventnum mytable [state] = 9) sq on sq.name = mt.name , sq.eventnum = mt.eventnum or: delete mt1 mytable mt1 exists ( select * mytable mt2 mt2.name = mt1.name , mt2.eventnum = mt1.eventnum

android - Firebase stored file json information -

i have uploaded images/videos on firebase. firebase provide json information uploaded content in paginated format. in friendly-pix sample uploaded images mapped in database , manually fetched url obtained db. i'm looking direct way app doesn't have concept of users right now. need json information uploaded content , show them in app directly.

javascript - Ignore self-signed SSL certificate in fetch -

i'm using fetch in react-native app, , charles proxy debug network requests. in order use charles ssl, need configure fetch accept self-signed certificate generated charles. how tell fetch ignore errors self-signed certificates when using https? i fixed setting ssl certificates in simulator: > ssl proxying > install charles root certificate in ios simulators) in charles , happy! thanks https://stackoverflow.com/a/35047215/82156

sql - Split week based on weightage -

i have weights defined below in table. daynum | day | weight | cumulative weight 1 | mon | 0.3 | 0.3 2 | tue | 0.15 | 0.45 (sum of mon , tues) 3 | wed | 0.1 | 0.55 (sum of mon , tues , wed) 4 | thu | 0.1 | 0.65 5 | fri | 0.15 | 0.8 6 | sat | 0.2 | 1 and have amounts in table defined @ weekly level (mon - sun) below. item | date | amount | 30-may-16 | 10 ---- week in may , june | 6-jun-16 | 20 | 13-jun-16 | 30 , on | 27-jun-16 | 60 ---- week in jun , july now want insert table @ daily level, weeks overlapping between 2 different months (in above example - 30 may 5 jun). can explain how can achieve in oracle. output should below. item | date | amount | 30-may-16 | 4.5 (2 days may mon , tues - calculation 10 * 0.45) | 1-jun-16 | 5.5 (5 days may rest of week - 10 minus 4.5) | 6-jun-16 | 20 , on | 27-jun-16 | 39 (4 days june mon till thurs - calculation 60 * 0.65)

r - How to use the oauth2.0_token function from httr package with facebook API? -

i have collection of facebook functions relies on httr package. the usual procedure 1 has set oauth app specs , facebook endpoints. until worked charm when try token oauth2.0_token function error: waiting authentication in browser... press esc/ctrl + c abort authentication complete. fejl init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, : bad request (http 400). you see code below: facebook_app <- oauth_app("facebook", key = "xxxx", secret = "yyyy") # end point facebook_ep <- oauth_endpoint( authorize = "https://www.facebook.com/dialog/oauth", access = "https://graph.facebook.com/oauth/access_token") # token endpoint , oauth fb.token <- oauth2.0_token(facebook_ep, facebook_app, user_params = facebook_ep) i have been various posts , forums have not had luck in finding solution yet. solved settting: sys.setenv("httr_server_port" = "1410/")

Generate right triangles c++ -

i trying make program generate 3 sides given following input: longest allowed hypotenuse , number of triangles required. sides can integers. program have written hangs on me , not return output. if downvote me explain why. #include <iostream> #include <cmath> #include <cstdlib> int generator(int number, int hypoth){ int a,b,c; while (number>0){ c=rand()%(hypoth-1)+1; (a=1;a<hypoth-2;a++){ (b=1;pow(a,2)+pow(b,2)<=pow(c,2); b++){ if (pow(a,2)+pow(b,2)==pow(c,2)){ std::cout<<"sides: "<<a<<" "<<b<<" "<<c<<std::endl; number--; } } } } return 0; } int main(){ int triangle_number, hypothenuse; std::cout << "how many triangles generate? "; std::cin >> triangle_number; std::cout << "how long max hypothenu

How to process multiple forms with php -

i developing website have ten different pages ten different properties. each page have 2 forms 1 set appointment , 1 else. how process each form? right have processing page each form. total of twenty different processing pages. variables, names, , ids, add 2..3...4..etc. each form. correct way of doing it? <form role="form" id="apptform2" name="apptform2" action="<?php echo htmlspecialchars($_server['php_self']); ?>" method="post"> <div class="form-group cushion"> <label for="apptname2">full name*</label> <input type="text" name="apptname2" class="form-control" id="apptname2" placeholder="last, first"> <?php if (isset($appterrors2['apptnamepgtwo1'])) { echo '<div class = "pink-text"/><p>', $appterrors2['appt

c# - Specify a unique identifier attribute for an object across webapi Models -

in post call webapi trying return created(newobject) thing. there no signature created in apicontroller can take object , rest. it works fine if return like: return created(newobject.blahid.tostring(), newobject); or if return createdatroute("defaultapi", new { controller = controllercontext.controllerdescriptor.controllername, id = newobject.blahid.tostring()}, newobject); i want simplify to: return created(newobject); i need implement method in basecontroller public class basecontroller : apicontroller { protected new creatednegotiatedcontentresult<t> created<t>(t content) { var id = getid(content);//need here return base.created(id, content); } } i don't want worry unique identifier object being called differently in different models e.g. myobjguid, someblahguid etc. want find out , mark "id". say if model public class model_a { public list<model_a> childmodels { get; set

Error At Android STUDIO -

i'm learning program android on android studio . when start application, following message appears on avd " unfortunalety , guitarstorev2 has stopped ." can me ? (sorry if stupid mistake , not have familiarity language , , excuse error portuguese , because brazilian , not speak english fluently ) grateful attention mark tonial public class mainactivity extends appcompatactivity { button btn_iniciaapp; public void inicia () { button btn_inciaapp = (button) findviewbyid(r.id.btn_iniciaapp); } // iniciando tela de produtos public void iniciaprod() { intent activityprod = new intent(this, activityprod.class); startactivity(activityprod); } // evento ao clicar no botão public void inicialistener() { this.btn_iniciaapp.setonclicklistener(new onclicklistener() { public void onclick(view arg0) { mainactivity.this.iniciaprod(); } }); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(s

asp.net mvc - JavaScript in MVC Editor template doesn't render properly -

i'm moving controls view editor. in editor have hiddenfor: @html.hiddenfor(m => m.emaildatavariables) i have javascript tries read (this works in original page, not in view): var myvalue = document.getelementbyid('emaildatavariables').value; the hiddenfor renders out (which breaks above javascript): <input id="emailtemplate_emaildatavariables" name="emailtemplate.emaildatavariables" type="hidden" value="mydata"> should assume control named emailtemplate.emaildatavariables , write javascript this: var myvalue = document.getelementbyid('emailtemplate.emaildatavariables').value; or there better way handle this? you have 2 options. 1) assume id emailtemplate_emaildatavariables , update js accordingly. 2) give unique id know. @html.hiddenfor(m => m.emaildatavariables, new {id = "emaildatavariables"}) source

r - Reactivity while using ggvis/shiny -

i new shiny/ggvis , want create scatter plot allows user select x , y dropdown. have attempted feat may times no avail , appreciate help. please see code below. library(shiny) library(ggvis) library(dplyr) # define user interface shinyui(pagewithsidebar( # add title page headerpanel( h1("test header panel!")), sidebarpanel( uioutput("ggvis_ui"), sliderinput(inputid = "size",label = "area",10, 1000, value = c(10)), selectinput(inputid = "yaxis",label = "y variable", c("wt","drat")), selectinput(inputid = "xaxis",label = " x variable", c("cyl", "am","gear"))), mainpanel( h1("please review chart below showing nothing!"), ggvisoutput("ggvis") ) ) ) server.r # create server.r shinyserver(function(input, output, session) { # reactive e

python - 'ListSerializer' object is not callable -

i trying implement django-rest framework voting application content_type objects. tried using rest-framework-generic-relations serializers.py. seems me error might within serializer.py / views.py, new framework , appreciate help! views.py: class vote_detail(generics.retrieveupdatedestroyapiview): queryset = voteditem.objects.all() serializer_class = voteserializer(queryset, many=true) serializers.py: from rest_framework import serializers .models import voteditem posts.models import post generic_relations.relations import genericrelatedfield class postserializer(serializers.modelserializer): class meta: model = post fields = ('title',) class voteserializer(serializers.modelserializer): """ `voteditem` serializer `genericrelatedfield` mapping possible models respective serializers. """ voted_object = genericrelatedfield({ post: postserializer(), }) clas

google maps - PHP - calculate latitude & longitude which is nearer than 50 km -

i have these data: latitude: 50.223137 longitude: 18.679558 and create special function in php able calculate minimum lat & long , maximum lat & long nearer 50 km. 4 parameters , use these parameters in simple sql query: select * table lat >= [min_lat] , lng >= [min_lng] , lat <= [max_lat] , lng <= [max_lng]; i know, can using 1 sql query: latitude/longitude find nearest latitude/longitude - complex sql or complex calculation have 20.000.000 records in database , still grow up. have search in sql database other things want calculate based on php , search in sql in way: select * table lat >= [min_lat] , lng >= [min_lng] , lat <= [max_lat] , lng <= [max_lng]; because think - faster way. i found function: https://www.geodatasource.com/developers/php , great want create function in other way - want declare argument: lat, lng , distance (for example: 50 km). 4 parameters - min_lat, min_lng, max_lat, max_lng. anybody can me create fu

A few php Phar questions -

a few questions i'm sure answers useful many getting grips relatively new phar. is possible delete or edit file inside phar script, within phar script, when it's running? i've noticed can change name of phar file examplename.phar examplename.php , run in url , still works fine. right? ok do? safe? is better practice put files in same directory , phar it, or ok keep folders , sub folders , phar - or not matter? can obfuscate phar file. or ruin it? obfuscating have done before pharing? hopefully phar expert can answer these. thanks the usual setting of php treat phar files readonly. in fact, have change setting allow local copy of php create these files. doubt can changed, wouldn't bet on it. the general structure of phar initial php script part sets things up, , call __halt_compiler() followed zipped bytes (after transferring control script part inside phar), can whatever possible php script without phar, including changing it's name. note bo

python - Blender scale value not updating -

when run script: import bpy import math s = bpy.context.scene.frame_start e = bpy.context.scene.frame_end values = [] print(s) print(e) in range(s,e): bpy.context.scene.frame_current = print(i) v = (bpy.context.object.scale[1]) bpy.context.object.scale[0] = print('at frame ',str(i), ' value ' ,str(v)) values.extend([bpy.context.object.scale[1]]) it gives me right number of frames, value same, if scale[1] of object baked sound, change between frames. it looks blender doesn't update value , take value of frame during text ran. any way update value during running of code in real time? you looking @ wrong values. you have v = scale[1] set scale[0] = i , print(v) reading scale.y , changing scale.x looking @ scale.y it better use scene.frame_set() change frames via python. another approach getting keyed value use fcurve.evaluate(frame) import bpy s = bpy.context.scene.frame_start e = bpy.context.scene.frame_en

javascript - React Native setting keys on elements -

i'm trying asyncstorage working in react-native, save user inputted data. although i've found through online resources , community, stuff driving me crazy. even react docs seem flawed. code below taken straight asyncstorage page of react docs , pasted new, clean application (i've added final line of code register app, won't work without it). the big block of code below posted reference. believe important bit line: {this.state.messages.map(function(m) { return <text key={m}>{m}</text>; })} i unique key errors, although have key set. 'use strict'; var react = require('react'); var reactnative = require('react-native'); var { appregistry, asyncstorage, pickerios, text, view } = reactnative; var pickeritemios = pickerios.item; var storage_key = '@asyncstorageexample:key'; var colors = ['red', 'orange', 'yellow', 'green', 'blue']; var basicstorageexample = reac

spring boot - Redis-3.0.5 Sentinel on Windows -

trying run 1 master 2 slave 3 sentinel setup on localhost (windows), using redis-3.0.5 64 bit, described here : https://github.com/servicestack/redis-config.git all instances come fine , seems communication till test failover using command : redis-cli -p 6380 debug sleep 30 this commands returns after 30 seconds during master becomes unavailable , java app, using spring-data-redis jedis client, goes connection retry mode. there no log messages on console or log file of redis or sentinel instances. no indcation of of 2 slaves being promoted master. the command "sentinel get-master-addr-by-name mymaster" shows same master ip , port through 30 seconds of sleep , after. am missing ?

Error shown in Python - TypeError : unsupported operand type(s) for ** or pow() :'str' and 'int' -

i started python today.. spent hours on codeacademy , learnt quite bit thought i'd make own program square ages of person , sibling. basic starter. pretty useless wanted see can do. keep getting typeerror mentioned in title. here's code : a=raw_input(''enter age'') b=raw_input(''sibling's age'') square=a**2 + b**2 + 2ab if square <160: print 'really young people' else: print 'square of sum >160' please thanks!! first , foremost, if you're starting, really should learning python 3, not 2. the code posted has many issues. here's line-by-line breakdown, corrections in python 3: a=raw_input(''enter age'') b=raw_input(''sibling's age'') you need use either single quotes ' or double quotes " , not 2 single quotes define strings. try: a = int(input("enter age")) b = int(input("sibling's age")) there no raw_inp

javascript - How to send a base64 image to node js server -

i know how retrieve base64 image canvas using javascript on html page: var url = canvas.todataurl("image/png"); url.replace(/^data:image\/(png|jpg);base64,/, ""); now want send information server , create image. want like: router.post('/createimage', function (req, res) { var base64image = //i need base64 image here var picpath = path.normalize('./public/images/users/pic.png'); fs.writefile(picpath, url, 'base64', function(err) { console.log(err); }); }); how can that?

FBSDKGraphRequest: How to cast Facebook work experience data in Swift to UILabel -

i able retrieve , display name, birthday, email, , picture. i able retrieve work data prints fine. my question how able display specific employer name , position name in label. func showuserdata() { let graphrequest : fbsdkgraphrequest = fbsdkgraphrequest(graphpath: "me", parameters: ["fields" : "id, first_name, birthday, work, email, picture.type(large)"]) graphrequest.startwithcompletionhandler({ (connection, result, error) -> void in if ((error) != nil) { // process error print("error: \(error)") } else { // request firstname let username : nsstring = result.valueforkey("first_name") as! nsstring // request birthdate let userbirthday : nsstring = result.valueforkey("birthday") as! nsstring // request work info let userwork : nsarray = result.valueforkey("work") as! nsarray

debugging - Android app crashing on installing -

my app throwing "unfortunately, app has stopped" on installing upgrade current app. have crashlytics installed seems not have chance initialize before crash. cannot debug app because on custom hardware , tried adding toast messages in oncreate() in launcher activity , in application class don't see of them. not sure how debug here.... please try below steps, 1.add android sdk's adb tools path computer's environment virable "path". ex: path = c:\android\android_sdk\platform-tools 2.and then, try use adb command take dumpstate log adb shell dumpstate > c:\dumpstate_installer_crash.txt the dumpstate log should save in computer "c:\dumpstate_installer_crash.txt" path. then, check , analyse log, may find clues.

Android Fragment Tabs being created twice on orientation change -

i'm java vet, new @ android. anyway, following block of code activity.oncreate() method: allcontactspage = new allcontactspage(); allgroupspage = new allgroupspage(); viewpager viewpager = (viewpager) findviewbyid(r.id.contactstabsviewpager); contactstabspageradapter tabsadapter = new contactstabspageradapter(getsupportfragmentmanager(), allcontactspage, allgroupspage); viewpager.setadapter(tabsadapter); tablayout tablayout = (tablayout) findviewbyid(r.id.contactsactivitytabs); tablayout.setupwithviewpager(viewpager); contactsservice.loadallcontacts(this); the allcontactspage , allgroupspage fragments. add them tablayout using viewpager , fragmentpageadapter (contactstabspageradapter). after this, call loadallcontacts(this) on service. "this" passed callback, when it's done calls activity, updates both fragments data should display (both fragments instance variables). my problem that, on rotation, 2 of each fragment created. 1 version displayed in ui,

postgresql - How to test a function in PSQL? -

i'm following tutorial: http://www.onlamp.com/pub/a/onlamp/2006/05/11/postgresql-plpgsql.html but fails when try command: mattswheels=# try=% select fib(8); error: syntax error @ or near "try" line 1: try=% select fib(8); ^ how can test out newly created function?

php - creating a dropdown of available tables in a DB -

this bit of code below connects db(using config.php ) , creates below dropdown. include "config.php"; // database connection using pdo //$sql="select name,id student"; $sql="select name,id student order name"; /* can add order clause sql statement if names displayed in alphabetical order */ echo "<select name=student value=''>student name</option>"; // list box select command foreach ($dbo->query($sql) $row){//array or records stored in $row echo "<option value=$row[id]>$row[name]</option>"; /* option values added looping through array */ } echo "</select>";// closing of list box this dropdown code created, , can run see in action. <br> <br> list box here <select name=student value=''>student name</option> <option value=1>john deo</option> <option value=2>max ruin</option> <option value=3&

Translating AppleScript if-clause to its JavaScript equivalent -

i don't know if issue lies me or os x . have applescript: tell application "caffeine" if active turn off else turn on end if end tell i translated this javascript caffeine = application("caffeine"); if (caffeine.active) { caffeine.turnoff(); } else { caffeine.turnon(); } however caffeine.turnon(); never executed, no matter how run it. if caffeine active, turned off, otherwise nothing. applescript equivalent runs. caffeine.turnon(); , caffeine.turnoff(); run fine. can't imagine, javascript osa broken, doesn't work. caffeine.active might function, when not called truly: var my_fn = function() {}; if (my_fn) console.log('my_fn truly'); call function: var caffeine = application("caffeine"); if (caffeine.active()) { caffeine.turnoff(); } else { caffeine.turnon(); } a way check it, log value: console.log(caffeine.active); // function() { .... } // or using typeof

How can I use variable on NSIS include / to get another variable -

is there anyway include file mention variable? mean strcpy $1 "bla.nsh" !include $1 ? or maybe getting value of variable called variable such as: strcpy $1 "en" strcpy $2 ${lang_${1}_welcome_message} ? thanks. actually, anders right. think that, when compiler compiling code, need know files need include exe file. about variable, can use defines. again, because when compiling, compiler compile needed (in use) variables / defines, , can't tell him use 1 never been declared.. little different server side languages because here compiling , pack code exe file assembled in computer.

jQuery - If Else statement not working but works if separated into individual if statements -

the code below works if statement , subsequent else if statements not fire. if separate 3 individual if statements works fine. how can make them play nice together? not working if ( headinglength < 1 ) { // show error message $('.compose-wrap .message-heading .help-block').fadein(); } else if ( messagelength < 1 ) { // show error message $('.compose-wrap .message-body .help-block').fadein(); } else if ( formtaglength < 1 ) { // show error message $('.compose-wrap .choose-recipients .help-block').fadein(); } working if ( headinglength < 1 ) { // show error message $('.compose-wrap .message-heading .help-block').fadein(); } if ( messagelength < 1 ) { // show error message $('.compose-wrap .message-body .help-block').fadein(); } if ( formtaglength < 1 ) { // show error message $('.compose-wrap .choose-recipients .help-block').fadein(); }

jquery - How to find if we passed a day when adding minutes to datetime object in javascript -

i having date range june 21 jun 27.i want add 20 minutes start date every 5secs , make service call values. also, second service call need previous end datetime start datetime.for example service call 1, start date jun 21, 5:00 pm end date jun 27, 5:20 pm second service call should have start date jun 21, 5:20 pm end date jun 21 , 5:40 pm how can achieve through javascript , how change date once pass 24 hrs. thanks! //my start date , end date var startdt = newdate(data.startdate); var enddt = newdate(data.enddate); var count = 0; setinterval(function() { if(count == 0){ var sdt= new date(startdt).toisostring(); var edt= new date(startdt.setminutes(startdt.getminutes() + 10)).toisostring(); } else{ var sdt = new date(startdt.setminutes(startdt.getminutes() + )).toisostring(); } //calling apy sdt , edt here; count++; },5000) the javascript setminutes() method automatically go next hour or day when minutes or hour wrap around.

R data.table generate random pairings in data table -

i have following sample data table. id val 1: 1 2: b 3 3: c 2 4: d 1 i make random pairings amongst id columns, not want id paired itself. efficient way data.tables? 1 approach have tried first find random rows in data table follows x = x[sample(nrow(x),1),] but hit block because have run check make sure current index not present in 1 returned. expensive computationally. example possible output result be id val id.pair val.pair 1: 1 b 3 2: b 3 c 2 3: c 2 1 4: d 1 1 thanks in advance you use combn , sample.int this: df <- read.table(text="id val 1 b 3 c 2 d 1", header=true, stringsasfactors=false) library(data.table) dt <- data.table(df) set.seed(42) combis <- combn(dt[,id], 2)[,sample.int(choose(nrow(dt),2), nrow(dt))] setkey(dt, "id") cbind(dt[combis[1,],], dt[combis[2,],]) # id val id val # 1: c 2 d 1 # 2: b 3 d 1 # 3: 1 c 2 # 4: 1 d 1 however, if number of ids

jquery - Rails Javascript issue -

i'm integrating theme wrapbootstrap.com , realized i'm running issue. scripts.js that's included theme conflicting 2 files i'm including in application.js //= require jquery //= require jquery_ujs i know because logout functionality stopped working has route as: delete '/logout' => 'sessions#destroy' view: <%= link_to "log out", "/logout" , :method => "delete" %> i suppose question how can include both scripts.js along rails required classes? if remove scripts.js logout functionality returns , when require again functionality goes away. my solution make get request rather have delete http request in routes.rb files.

osx - Passing a port number to lsof in a shell function -

i wrote alias in bash profile me kill rogue rails server processes don't cleanly close. alias works well. alias kill3000="lsof -i tcp: 3000 -t | xargs kill -9 | echo 'killed processes on port 3000'" i wanted make more general purpose, frameworks work on other ports. tried make similar function, pass port number variable, error. function wrote looks this... function killproc (){ "lsof -i tcp:$1 -t | xargs kill -9 | echo 'killed processes on port $1'" } however, when run "killproc 3000", following error: lsof: unacceptable port specification in: -i tcp: i'm struggling understand problem, appreciate help. maybe double-quotes involved. give try this: function killproc (){ lsof -i tcp:"$1" -t | xargs kill -9 lsof -i tcp:"$1" -t 2>/dev/null >/dev/null || printf "killed processes on port %s\n" "$1" } the message printed if there no more process found l

SSRS open URL in new window Javascript function not working with dynamic URL string -

i using javascript:void(window.open('" & url & "','_blank')) open url in new window. i've used many times , works except when url string built using dynamic parameter values. what works : the url trying open on ssrs action below: ssrsserveraddress/headcount.rdl&pbusinessunit=" & fields!businessunit.value & "&pcalendar=" & **code.urlencode**("[monthly calendar].[monthly calendar].[month].&[" & fields!monthyear.value &"]) the ssrs action (go url) expression works when using above url. uses custom code.urlencode (see description below) , passes calendar parameter correctly. what not work: the problem need url open in new window. here's javascript action using: javascript:void(window.open('"ssrsserveraddress/headcount.rdl&pbusinessunit=" & fields!businessunit.value & "&pcalendar=" & code.urlencode("[monthly calendar].[m

xamarin - HttpClient is caching requests to the same URL -

on xamarin ios. i'm using httpclient json string. problem ignores updates , gives me same json response if query same url. want not cache , query url , give me new response. this sounds trivial, there must simple way this. i'm using forms shared project. i assume setting cache-control header no-cache? client.defaultrequestheaders.cachecontrol.nocache = true; if still doesn't work - maybe server caching response? if comes down it, can defeat adding cachebuster querystring though. append bogus param , pass unique value each time. example, if url http://my.url.com/resource/someid can defeat caching using http://my.url.com/resource/someid?b=1 , increment "b" param each call.

printing - Odoo POS ticket, large size with empty spaces -

i´m using odoo v9. i´m facing problems pos module. @ time of printing ticket every thing shown properly, reason there large empty space, before content of ticket after it, wasting 2/3 of space. i´m using odoo , epson tv88 printer, i´m not using posbox. guest configuration problem, or something. help, in advanced. regards you can remove space reducing size of ticket .xml file ypu define template of receipt else can manage size odoo. located here: settings>>technical>>reports>>paper format also here can create own format also.

atlassian sourcetree - How to amend a specific commit message in Git? -

i trying change commit message in sourcetree cannot find option is. has not been pushed yet. how can amend message older commits in sourcetree or command line? there no feature because how git internally work, sha1 seal each commit. but : do 'amend' if message 1 of last commit. do git rebase -i named rebase interactive , choose 'reword' (or 'r') each commit want rewrite commit message. use git 'notes' join new comment next existing 1 (but handle not straightforward... )

c++ - Normalized Integer to/from Float Conversion -

i need convert normalized integer values , real floating-point values. instance, int16_t, value of 1.0 represented 32767 , -1.0 represented -32768. although it's bit tedious each integer type, both signed , unsigned, it's still easy enough write hand. however, want use standard methods whenever possible rather going off , reinventing wheel, i'm looking standard c or c++ header, boost library, or other small, portable, easily-incorporated source performs these conversions. here's templated solution using std::numeric_limits : #include <cstdint> #include <limits> template <typename t> constexpr double normalize (t value) { return value < 0 ? -static_cast<double>(value) / std::numeric_limits<t>::min() : static_cast<double>(value) / std::numeric_limits<t>::max() ; } int main () { // test cases evaluated @ compile time. static_assert(normalize(int16_t(32767)) == 1, ""); static_asse

angularjs - Can't share Facebook image post with Cordova Facebook plugin -

i've created cordova/angular app pulls facebook feed api. i'm trying add ability share 1 of facebook posts on own timeline. i'm using cordova facebook plugin found here https://github.com/jeduan/cordova-plugin-facebook4 the problem when try share image post "an error occurred. please try again later" in share dialog appears. i'm not sure how setup options share images properly. here's current code share: var options = { method: 'share', href: post.link, caption: post.message }; $cordovafacebook.showdialog(options).then( function (res) { success(res); }, function (error) { console.log(error); fail(error); }); any ideas options should share image?

oracle11g - Functions not present in Teradata -

i want know functions present in oracle 11g missing (or has no replacement) in teradata 14.x? i don't know oracle can little teradata side. in teradata @ functions in td_sysfnlib , syslib databases. find (or not find) of functions looking for. there optional oracle-like functions dba may or may not have installed in teradata. way know sure available look. in teradata query dbc.tablesv tablekind f, or r. decode tablekind is: t data table v view m macro j journal table i join index table p stored procedure g trigger f scalar udf a aggregate udf n hash index table u user-defined data type h instance or constructor method e external stored procedure r table function x authorization there other system views in dbc can query info.

javascript - When making an ajax call I receive "TypeError: e is undefined" -

i trying display contents of website using file_get_contents in php script , ajax on front-end. can display whole page fine if try display amount of images on page, receive "typeerror: e undefined" error. here php: <?php $url= 'https://twitter.com/twitter'; if($url!="") echo file_get_contents($url); ?> here jquery: $.ajax({ url : "twitter.php", datatype: "html", success : function (data) { console.log("loaded"); //$(data).appendto('#images'); $.each(data.items, function(i,item) { $("<img />").attr("src", item.media.m).appendto('#images'); if (i == 5) return false; }); } }); data html string, iterate on (like dom tree) using jq, you'll have call jq constructor (or init method). did when tried append current dom: $(data).appendto('#images'); // \==>$() f

c++ - Porting Linux compatible project from Windows to Linux -

in company i'm working @ develop on windows, visual studio, , cross compile linux using eclipse. our final application runs on linux. i'm trying convince them how easy , fast build on linux instead of using old cross compiler , having sort of weird bugs. of bugs vanish when compile them later versions of gcc on linux. since cross compiler old cannot use c++11 features. one major problem have since our projects developed on windows i'm having hard time formatting headers! example assume have folder named io header file demo.h in it. this #include <io\demo.h> works fine on windows. on linux doesn't because windows not case sensitive , both \ , / work on windows. on linux must this #include <io/demo.h> otherwise error can't find specified header file. have more 20 main project working on , each 1 around 3-4 gb. i've modified 1 of them. took me around 7 hours it. are there tools me make transition faster? our source code 95% c++ ,

Cannot communicate once bufferedwriter is close in java socket programming -

i made server , client java application. should communicate each other through tcp sockets threads. used inputstreamreader , bufferedreader read message, , used outputstreamwriter , bufferedwriter write message. object of bufferedreader called reader, , object of bufferedwriter called writer. after playing around that, realized socket becomes irresponsive if writer closed. i closed writer on server side because never send message, read message client only. not throw exception, stuck called methods relate socket such reader.readline() , socket.setsotimeout(). the problem easy solve since don't close writer. however, curious why socket being unable communicate. the socket becomes irresponsive if writer closed the socket becomes closed if writer closed. i closed writer on server side because never send message, non sequitur. if don't need writer , don't construct it. stuck called methods relate socket such reader.readline() , socket.set

javascript - Assistance grouping nested html table via jquery -

basically have html table 3 layers of expand/collapse functionality. seeking achieve have layers expand/collapse underneath parents instead of right, become downward slope once expanded. here jsfiddle: https://jsfiddle.net/htflmekl/1/ //expand collapse based on parent class column 1 $(document).ready(function() { $('.parent').prepend('-'); $('.parent').on('click', function() { if ($(this).text().indexof('-') != -1) { var str0 = $(this).text().replace(/-/g, '+'); $(this).text(str0); } else { var str = $(this).text().replace(/\+/g, '-'); $(this).text(str); } var $row = $(this).parent(); var rowspan = +$(this).attr('rowspan') || 4; $.merge($row, $row.nextall()).slice(0, rowspan).find('.alliance').toggle(); $.merge($row, $row.nextall()).slice(0, rowspan).find('.race').toggle(); $.merge($row, $row.nextall()).slice(0, rowspan).find('.role