Posts

Showing posts from May, 2011

javascript - React toggle button issue -

i'm trying switch https://github.com/pgrimard/react-toggle-switch working in react project. working expected (it toggles , calls togglefeature function), i'm struggling understand how link each switch perform different action. grab sort of identifiable attribute in onclick event determine action carry out, i'm bit stuck on how in case. heres current code (made bare-bones possible) class featureitem extends react.component { constructor(props) { super(props); this.state = {on: props.flag}; } _togglefeature(e) { console.log(e); // undefined console.log("assd"); // called on toggle } render () { <div classname="example-usage"> <p>switch state: {this.state.on ? 'on' : 'off'}</p> <switch classname= {this.props.description} onclick={this._togglefeature.bind(this)} on={this.state.on}/> </div> ) } }; does 1 have idea i'm doing wrong

javascript - Client Side Twitter Feed -

making informational website, , looking have twitter feed, showing latest tweets account made. understand twitter api supports application authentication , still not require backend protect api keys? is there way achieve live feed code exclusively on client? (that say, no backend) avoid scraping or other hack solutions, if possible. have seen embedded timeline twitter, method don't require api. can embed client side.

python 3.x - How do i make the program exit by entering 0 -

# abc inc., gross pay calculator! # enter employee's name or 0 quit : nathan # enter hours worked : 35 # enter employee's pay rate : 10.00 # employee name : nathan # gross pay: 350.0 # enter next employee's name or 0 quit : toby # enter hours worked : 45 # enter employee's pay rate : 10 # employee name : toby # gross pay : 475.0 # (overtime pay : 75.0 ) # enter next employee's name or 0 quit : 0 # exiting program... how make input 0 print "exiting program" exit? print('abc inc., gross pay calculator!') name = input("enter employee's name or 0 quit:") hours = float(input("enter hours worked:")) payrate = float(input("enter employee's pay rate:")) print("employee name:", name) grosspay = hours * payrate print("gross pay:", grosspay) if hours > 40: print("(overtime pay:", (hours - 40) * payrate * 1.5) while name!=0: name = input("enter next employee's name or 0

r - aggregate data.frame with list column -

there 1 column contains vectors in each row of data.frame. aggregate , combine vectors. however, seems cannot this kind of data. how combine vectors? "error: invalid type (list) variable 'dv'" #problem: aggregate data.frame list-column #reproducible code set.seed(1) some_list <- replicate(40, sample(c(1:8), size=sample(1:6, 1), replace=true)) exdf <- expand.grid(id=c(1:10), content=c(1:4)) exdf$dv <- some_list #this throws error aggregate( formula=dv~id, data=exdf, fun=c ) you can use dplyr summarize unlist , list : library(dplyr) df1 <- exdf %>% group_by(id) %>% summarise(dv = list(unlist(dv))) df1 # source: local data frame [10 x 2] # id dv # <int> <list> #1 1 <int [13]> #2 2 <int [15]> #3 3 <int [13]> #4 4 <int [15]> #5 5 <int [13]> #6 6 <int [15]> #7 7 <int [13]> #8 8 <int [15]> #9 9 <int [13]&g

ruby - How to rewrite file content with inline Guard (gem), avoiding infinite loop -

how can avoid infinite loop kind of code? (rubocop's auto-correct re-write files, although system command think) require 'guard/compat/plugin' module ::guard class rubyhtmlsyntaxfixer < plugin def run_on_modifications(paths) paths.each |path| text = file.read(path) text.gsub!('replace text', 'with cool') file.open(path, 'w') {|file| file.puts text } end end end end guard 'ruby_html_syntax_fixer' watch(%r{app/views/.+\.(erb|haml|slim)}) end

assembly - Did I translate the very short C code correctly into assembler? -

i'm learning assembly x86 , have made little task myself. the c code: if (a == 4711) { = + 2 } else { = - 2 } assembler code ( eax register, cmp compare, jne jump if not equal , jmp jump if equal): mov eax, cmp eax, 4711 jmp equal equal: add eax, 2 jne unequal unequal: sub eax, 2 i think little more efficient be: mov eax, cmp eax, 4711 jne unequal add eax, 2 unequal: sub eax, 2 edit: mov eax, cmp eax, 4711 jne unequal equal: add eax, 2 jmp continue unequal: sub eax, 2 continue: ... did translate correctly? let's first code: mov eax, cmp eax, 4711 jmp equal equal: add eax, 2 jne unequal unequal: sub eax, 2 let's pretend first instruction load eax "a" (it in tasm/masm, rather stick explicit , accurate [a] , it's easier read source , works in nasm). second ins

Get all stored procedures where table is being used in SQL Server -

i need query or code in sql server stored procedures in table being used in server (need stored procedures in databases on server). select * sys.procedures object_definition(object_id) '%[dbo].[batch]%. above query give in current database need query databases in server. thanks. sandeep execute master.sys.sp_msforeachdb "use [?]; select * sys.procedures object_definition(object_id) '%[dbo].[batch]%'" just consider permutations of code references batch object (dbo.batch, [dbo].[batch], dbo.[batch], etc)

Explanation of PDU size in Bluetooth Low Energy 4.2 -

in bluetooth low energy 4.0 , 4.1, max pdu of ota packet 39 bytes (47 bytes preamble, access address , crc) , increased 257 bytes in version 4.2. reason of short packet stability of radio, long packets heat silicon , circuitry added keep frequency stable.so, in ble 4.1, longest possible packet 376 microseconds avoid heating effect. data rate 1mhz, 376 microseconds 376 bits = 47 bytes size of pdu explained. in version 4.2, longest packet 2120 bits, 2.12ms , read 3ms packets in bluetooth classic long enough cause problems. question is: why , how did sig succeed increase pdu in version 4.2 know semiconductor companies state hardware same versions. did lead new pdu length? in 4.[01], 39 bytes maximum ll pdu size reached advertisement packets (2 bytes of header, 6 bytes of device address, 31 bytes of ad). data packets, max pdu size 33 bytes (2 header + 4 l2cap + 23 att + 4 mic). note data channel header counts pdu size without header, makes data channel payload size go 31 byt

c# - How can I reduce the variables used in this code? -

i trying reduce amount of variables used in code below. ideally keep reusing string variable latestripme without creating latestripmeversion string[] variable. need create array in order skip(1) , first() ? can reach final value of latestripme more efficiently? private void ripmegetlatestversion_process() { //get .json file , save in latestripme string latestripme = clientripme.downloadstring("http://www.rarchives.com/ripme.json"); //create array saved string, , skip first line latestripmeversion = latestripme.split(environment.newline.tochararray()).skip(1).toarray(); //put array in string, , select first line latestripme = latestripmeversion.first(); //the characters need removed char[] latestripmetrim = { ' ', ' ', '"', 'l', 'a', 't', 'e', 's', 't', 'v', 'e', 'r', 's', 'i', 'o', 'n', '"

ios - overlaying text on image using swift -

Image
i trying overlay text on image using swift , looking @ code here: (src: how add text image in ios swift ) this places text right in center. have been changing values in var rect = cgrectmake(10,150, inimage.size.width, inimage.size.height) but unable text show in lower left corner. can , show missing here ? i adding modified image using line: modimage = self.texttoimage("000", inimage: uiimage(named:"thisimage.png")!, atpoint: cgpointmake(10, 400)) below function... func texttoimage(drawtext: nsstring, inimage: uiimage, atpoint: cgpoint) -> uiimage{ // setup font specific variables var textcolor = uicolor.whitecolor() var textfont = uifont(name: "helvetica bold", size: 12)! // setup image context using passed image let scale = uiscreen.mainscreen().scale uigraphicsbeginimagecontextwithoptions(inimage.size, false, scale) // setup font attributes later used dictate how text should drawn let text

http - 301 status code after PostForm -

i trying write program login ahrefs.com , parse data. @ first sending request ahrefs.com cookies , html parse needed token: client := &http.client{} jar := &myjar{} jar.jar = make(map[string] []*http.cookie) client.jar = jar resp, _ := client.get("https://ahrefs.com") root, _ := html.parse(resp.body) element, _ := getelementbyname("_token", root) token := "" _, := range element.attr { if a.key == "value" { token = a.val } } then sending post request using postform ahrefs.com/user/login/ . fill fields correct data (tested via browser). when submit form in browser has field return_to value of main page of site, should redirect ahrefs.com/dashboard/metrics/ (the page want parse data). program's behavior different. after postform got 301 status code: resp, _ = client.postform( "https://ahrefs.com/user/login/", url.values{

How to create R functions with private variables? -

how create set of r functions access same private variable? let's want create readsetting(key) , writesetting(key,value) functions both operate on same hidden list settings . if try so... local( { settings <- list() readsetting <<- function ( key ) settings[[key]] writesetting <<- function ( key, value ) settings[[key]] = value } ) ...then readsetting , writesetting not visible outside of local call. if want them visible there, have first assign readsetting <- writesetting <- null outside local call. there must better way, because code isn't dry if have in 2 different ways variables public. (the context of work i'm developing r package, , code in auxiliary file loaded main file via source .) this question related how limit scope of variables used in script? answers there not solve problem. you can simulate somthing using r6class package , following rough code: privates <- r6class("privates",

python - How to serialize related models in Django Rest API? -

i have tried solutions. still cannot resolve it. here codes. models.py class car(models.model): car_name = models.charfield(max_length=250) car_description = models.charfield(max_length=250) def __str__(self): return self.car_name + ' - ' + str(self.pk) class owners(models.model): car = models.foreignkey(car, on_delete=models.cascade, default=0) owner_name = models.charfield(max_length=250) owner_desc = models.charfield(max_length=250) def get_absolute_url(self): return reverse('appname:index') def __str__(self): return self.owner_name + ' - ' + self.owner_desc serializers.py class ownersserializer(serializers.modelserializer): class meta: model = owners fields = '__all__' class carserializer(serializers.modelserializer): owners = ownersserializer(many=true, read_only=true) class meta: model = car fields = '__all__' vi

C++ Beginner. Adding a function and calling it fails -

can me , let me know why failing? getting error shown below: #include "stdafx.h" #include <string> #include <iostream> using namespace std; #include <conio.h> int main() { int a; string abc = ""; cout << "enter name\n"; cin >> abc; cout << "enter age\n"; cin >> a; cout << "hello " << abc << ", nice meet you.\n"; startpause(); return 0; } void startpause() { cout << "\npress key continue..." << endl; _getch(); } severity code description project file line suppression state error c3861 'startpause': identifier not found greetingsconsoleapp \bpm-fs103\users...\greetingsconsoleapp.cpp 20 the compiler processes compilation unit, .cpp file in case, sequentially top bottom. your startpause function has been neither declared nor defined time compiler finds c

ruby on rails - Multiple subdomains keep redirecting to root path -

i have 1 rails app running on digital ocean unicorn, nginx on ubuntu , i'm trying handle bunch of subdomains such app1.example.com, app2.example.com, etc. in routes i'm doing this: constraints(subdomain) match '/', to: 'pages#landing', via: [:get, :post] end which helping me catch subdomain prefixes , show corresponding landing page controller. locally works great nginx seems redirecting root path of app no matter what. here nginx config: upstream app_server { server unix:/var/run/unicorn.sock fail_timeout=0; } server { listen 80; server_name example.com *.example.com; return 301 https://$server_name$request_uri; } #when wildcard above didn't work, #i tried hardcoding below still nothing server { listen 80; server_name app1.example.com; return 301 https://$server_name$request_uri; } server { root /home/rails/example/public; index index.htm index.html; listen 443 ssl spdy; listen [::]:443 ssl spdy; ... ssl_protoc

python - Default instance for Django model -

my questionis: there anyway create default instance class language? : class language(models. default_instance = language(name="unknown") name = models.charfield(max_length=100) so class student can use this: class student(models.model): name = models.charfield(max_length=50) language = models.foreignkey(language, default = language.default_instance.pk ) thank you! you set overriding save method: #your model class student(models.model): name = models.charfield(max_length=50) language = models.foreignkey(language) # override save def save(self,**args,**kwargs): if self.language none: default_language = language.objects.get(pk=1) #set default self.language = default_language super(student,self).save(self,*args,**kwargs) # 'real' save see here overriding save method.

python - How can I get all media from my own Instagram api? -

i want number of likes each photo or video got. can media count or last 20 of them? if api access reviewed , approved instagram able more 20 photos using pagination. check documentation here: https://www.instagram.com/developer/sandbox/

compiler errors - c++ "Hello World" program will not compile -

this question has answer here: what undefined reference/unresolved external symbol error , how fix it? 27 answers undefined reference 'std::cout' 2 answers i have searched why c++ "hello world" program not compile wasn't able find works. wrote c++ hello world program using visual studio code , after save , try compile in command prompt using gcc helloworld.cpp -o helloworld.exe it gives following: gcc helloworld.cpp -o helloworld.exe c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x21): undefined reference `std::cout' c:\users\pgnic\appdata\local\temp\ccruakvt.o:helloworld.cpp:(.text+0x26): undefined reference `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char

laravel - Correct way to avoid `Undefined index` error (NOT NOTICE!!) with php 7 -

this question has answer here: how avoid undefined index 3 answers i not talking this: how avoid undefined index i talking crash, fatal error. not "notice". edit if caused notice, result crash. question is: how configure laravel, not crash on notices? i run laravel 5.3 , php 7. my error: errorexception in uploadcontroller.php line 149: undefined index: my code: if (!plumconstants::$plum_us_states[$state]) { $state = ''; } referencing constants class: class plumconstants { public static $plum_us_states = array( 'al' => 'alabama', 'ak' => 'alaska', 'az' => 'arizona', 'ar' => 'arkansas', 'ca' => 'california', // ... ); } well, that's bit funny no? becau

In c++, how can I grab the next few characters from a string? -

my goal grab specific part of large number , concatenate part number, continue. since integers go high, have string of number. not know number be, can't input in myself. can use substr first part, stuck shortly after. an example "435509590420924949" i want take first 5 characters out, convert integer, own calculation them, concatenate them rest of string. take 43550 out, formula 49, add 49 5 in row after original string "95904" new answer "4995904". this code first part made up, string temp; int number; temp = data.substr(0, 5); number = atoi(temp.c_str()); this grabs first first characters in strings, converts integers can calculate it, don't know how grab next 5 of long string. you can length of string, like: std::size_t startindex = 0; std::size_t blocklength = 5; std::size_t length = data.length(); while(startindex < length) { std::string temp = data.substr(startindex, blocklength); // temp startindex

Java Calendar is corrupted by setting HOUR_OF_DAY -

question: consider bug in java.util.calendar ? a calendar object in local (pdt) time zone instantiated , assigned 0 (epoch start) date. value maintained, expected after setting 0 calendar's millisecond, second, , minute. however, once hour of day set zero, time becomes non-zero. acquires value -57600000ms = -16 hours. may timezone bug, value -16 hours not correspond local -7 hours (pdt) offset, in effect @ time of execution. without daylight savings, time offset pst (-8 hours) , not correspond -16 hours. if setting hour should affect time zone offsets, expect setting minute should because: ( https://en.wikipedia.org/wiki/time_zone ) several places "use half-hour deviations standard time, , some" ... "use quarter-hour deviations." the code: date epochstart = new date(0l); system.out.println("epochstart=" + epochstart.gettime()); calendar calendar = calendar.getinstance(); calendar.settime(epochstart); system.out.println("epochsta

javascript - How to reduce a data graph but keeping the extremes -

Image
i have database has got month full of datasets in 10min intervals. (so dataset every 10min) now want show data on 3 graphs: last 24 hours, last 7 days , last 30 days. the data looks this: { "data" : 278, "date" : isodate("2016-08-31t01:51:05.315z") } { "data" : 627, "date" : isodate("2016-08-31t01:51:06.361z") } { "data" : 146, "date" : isodate("2016-08-31t01:51:07.938z") } // etc for 24h graph output data last 24h, that's easy. for other graphs thin data: const data = {}; //data database let newdata = []; const interval = 7; //for 7 days interval 7, 30 days it's 30 for( let = 0; < data.length; += interval ) { newdata.push( data[ ] ); }; this works fine extreme events data 0 or differs other values average, can lost depending on time search data. not thinning out data result in large sum of data points sent on pipe , have processed on front end. i'd avoid th

Python datetime difference between .localize and tzinfo -

why these 2 lines produce different results? >>> import pytz >>> datetime ipmort datetime >>> local_tz = pytz.timezone("america/los_angeles") >>> d1 = local_tz.localize(datetime(2015, 8, 1, 0, 0, 0, 0)) # line 1 >>> d2 = datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) # line 2 >>> d1 == d2 false what's reason difference, , should use localize datetime? when create d2=datetime(2015, 8, 1, 0, 0, 0, 0, local_tz) in way. not handle daylight savings time correctly. but, local_tz.localize() does. d1 datetime.datetime(2015, 8, 1, 0, 0, tzinfo=<dsttzinfo 'america/los_angeles' pdt-1 day, 17:00:00 dst>) d2 is datetime.datetime(2015, 8, 1, 0, 0, tzinfo=<dsttzinfo 'america/los_angeles' pst-1 day, 16:00:00 std>) you can see not representing same time. d2 way it's fine if gonna work utc. because utc not have daylight savings time trans

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum

What table holds the category selections for the time_card table in ServiceNow -

i'm using odbc connector query time card data time_card table in servicenow, , there 2 columns i'm wondering about: category , dv_category - 2 fields pulled somewhere, , not know where. there table holds these values, or static on ui , passed through? the 'category' field string(40) choice list local field. so, it's not reference field, drop down. choice list can modified i'm not finding 'dv_category' field on time_card table , i'm on helsinki patch 3. can clarify? editing add actual answer question : 'i believe table you're looking called 'sys_choice''

High Level Function Confusion with Lambda/LINQ expressions in C# -

unsure how describe question title might wrong. am reading on code examples , confused on following return function: func<func<int , bool>, func<int , int>, func<int , int>> loop = null ; loop = (c , f ) => n => c(n) ? loop(c , f ) ( f (n)): n; func<int , int> w = loop(n => n < 10 , n => n + 2); var r = w(2); var s = w(3); console . writeline ("{0} {1}" , r , s ); i understand function returning loop when c(n) evaluates true, don't understand how loop(c,f) (f(n)) evaluates - both being passed loop? have tried running dumps in linqpad , don't how bit running. any appreciated, understand dumb question! one way try understand start small: have basic loop 1-10 +1 increment. func<int,int> basicloop = null; basicloop = n => n < 10 ? basicloop(n+1) : n; that's pretty simple - basicloop function based on parameter n returns n (for n >= 10) or calls incremented parameter. basicloop(

linux - Count number of files in a remote directory using SFTP -

this question has answer here: sftp: return number of files in remote directory? 3 answers i writing script in bash , need count how many files starting ddd in remote directory using sftp. after download each file, them can compare how many files had in remote directory , how many files downloaded. check if match , such. i doing this: echo ls -l | sftp "user@$123.45.67.8:/home/user/datafolder/ddd*" | wc -l the 1 above works, when run downloads files local folder, not want. how can count number of files , not download them. want download them in part of code. as said in comments best way using ssh. outputs wanted ssh user@123.45.67.8 ls /home/user/datafolder/ddd* | wc -l

Initializing and Constructing Arrays of Objects in C++ -

this question has answer here: how use arrays in c++? 5 answers when declaring array of objects, objects constructed @ initialization, or have constructed after initialization? here example of trying explain: lets have class: class object{ public: int x = 4; }; and array: object objects[8]; if access of variables within objects, have construct objects first, or done in array? if did this: cout << objects[4].x; would print out 4? in c++11 code valid, performs in-class initialization, , indeed, cout << objects[4].x; print out 4 . in previous c++ versions (c++98/03), code invalid, , you'd need default constructor initialize variable x , like class object{ public: int x; object(int x = 4): x(x){} }

java - Using For-loops to get integers from user, then printing the even numbers -

this have far: import java.util.scanner; public class evenarray {//begin class public static void main(string[]args) {//begin main method java.util.scanner input = new java.util.scanner(system.in); system.out.println(); system.out.println("please enter number of intergers want put array."); int numbers = input.nextint(); int[] arrayint = new int[numbers]; int = 0; system.out.println("please enter numbers enter array."); (i =1; < arrayint.length; i++){ arrayint[i] = input.nextint(); } int evennumber = 0; ( = 0; < arrayint.length; i++){ if(arrayint[i] % 2 == 0){ evennumber++; system.out.println("the numbers " + evennumber); } } } } it compiles fine, prints: dhh005@cs:~$ java evenarray please enter number of intergers want put array. 6 please enter numbers enter array. 10 -7 3 42 -20 numbers 1 numbers 2 numbers 3 numbers 4 i cant figure out why isn't showing actual number

Automatically save files in eclipse when closing tab -

in eclipse (cdt) when close modified file's tab in code editor, i'm prompted whether or not want save file. unlike when run project, i'm not given option autosave file when closing tab in prompt comes up. haven't been able find 1 yet, there setting in eclipse preferences disable these prompts , automatically save modified files when close tabs (not every x time)? you can use auto save feature in eclipse neon. see answer @ other answers question eclipse save automatically

node.js - Is it possible to run node server in Express with only git-tracked files? -

i run express app files tracked in git. example, here current status of git ( git status ): on branch master untracked files: (use "git add <file>..." include in committed) blogs/test_announcement.md public/css/bootstrap-theme.min.css public/css/bootstrap.min.css routes/twitter.js nothing added commit untracked files present (use "git add" track) however, when tried run server (i use nodemon ), seems there no way ignore untracked files. makes blog test_announcement displayed on website. ultimately, i'm going push local files managed under git remote paas there wouldn't problem on production. however, pretty stressful see untracked files in development phase. so there possible way ignore files locally? my suggestion add files separate git branch , checkout different branch when want test without them. example, keep master branch clean have private local-drafts branch not-to-be-published files.

scalacheck - Type mismatch error in a scala for comprehension -

i writing generators following adts. idea generate blocks random data. having compiler error type mismatch: expected: seq[field], actual:gen[field] in blockgen method. doing wrong? edit the error fields on last line of method i.e. yield block(id, fields) . def blockgen(b: block): gen[block] = { id <- b.blockid fields <- b.fields.map(f => fieldgen(f)) } yield block(id, fields) adt trait data {} trait field extends data { val name: string val value: string } case class stringfield(name: string, value: string) extends field case class numberfield(name: string, value: string) extends field case class block(blockid: field, fields: seq[field]) extends data generators def blockgen(b: block): gen[block] = { id <- b.blockid fields <- b.fields.map(f => fieldgen(f)) } yield block(id, fields) def fieldgen(fieldtype: field): gen[field] = { { f <- fieldtype match { case _: numberfield => numgen case

Scale an image ,keeping aspect ratio without being cropped-android app -

i take photo gallery , display on activity in image view . it's fine except when photo displayed. want photo displayed in exact same size image view keeping aspect ratio , not cropped. tried in xml(centercrop,fitxy...)this i'm trying,but not working. showphotoactivity.class: imageview showphoto = (imageview) findviewbyid(r.id.image); bundle extras = getintent().getextras(); uri uri = uri.parse(extras.getstring("imagepath")); if (showphoto != null) { showphoto.setadjustviewbounds(true); showphoto.setimageuri(uri); } file.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ga.photoeditor.showphotoactivity" android:background="#93212121"> <com.example.ga.photoeditor.scal

javascript - Ember action or this.get works only once -

i have index controller. import ember 'ember'; export default ember.controller.extend({ actions: { reload() { console.log('click on button reload'); this.get('doreload'); } }, doreload: ember.computed(function() { console.log('do reload method'); // ajax action here. }), }); and button in template. <button type="button" class="btn btn-secondary btn-sm" {{action 'reload'}}>reload</button> when click on button first time, console.log() contain 2 line of messages correctly. click on button reload reload method but when click on button second time or more, console.log() contain contain 1 line. doesn't call doreload again. click on button reload how make this.get work every time click on action button? computed properties cached until dependent properties changed. if want execute function not inside a

ios - how to go back in MFsidemenu? -

this question exact duplicate of: how add backbutton facility mfslidemenu? 1 answer i want on mfslidemenu there no functionality go in mfslidemenu i have tried result: [self.navigationcontroller poptoviewcontroller:viewcontroller animated:yes]; and this nsuinteger ownindex = [self.navigationcontroller.viewcontrollers indexofobject:self]; [self.navigationcontroller poptoviewcontroller: [self.navigationcontroller.viewcontrollers objectatindex:ownindex - 2] animated:yes]; please check link homeview *home = [[homeview alloc]initwithnibname:@"homeview" bundle:nil]; nsarray *controllers = [nsarray arraywithobject:home]; self.navigationcontroller.viewcontrollers = controllers;

python - Number guessing game: How can I accept input that says "guess =" before the number? -

import random guess = input("what guess?") answer = random.randint(0,100) while guess != answer: try: guess = float(guess) if guess > answer: print ("your guess high!") elif guess < answer: print ("your guess low!") elif guess == answer: print ("congratulations!") break guess = input("what guess?") continue except valueerror: print ("bad input. try again!") guess = input("what guess?") so code works except when enter example: guess = 30, seems input invalid...how can make accepts correct guess? new python here :) thanks. i copied , pasted code python 3.5, and....apart needing indent after while statement worked fine. are inputting number: 30 ...or "guess = 30"? because cause problem since it's not number. need input number. :) if want accept "guess =

c# - Structured types is empty -

i passing 2 data tables (structured types) @tblparent , @tblchild input parameter stored procedure, paramlist.add(dbsqlmanager.createparameter("@tblparent", parameterdirection.input, alertsdatadt)); paramlist.add(dbsqlmanager.createparameter("@tblchild", parameterdirection.input, alertspointdatadt)); @tblparent has minimum 1 record @tblchild may have no records while passing @tblchild no records, getting below obvious error, "there not enough fields in structured type. structured types must have @ least 1 field." question is, there way handle no records in @tblchild??

html - Build responsive button with image, text and a link using css -

Image
i tried several things out of luck. need build button containing image , text on button background image. also, clicking anywhere inside button should redirect page, example, google.com. how button should the challenge having when button text changes or when screen size changes, alignment of image , text gets messed up. want wrap button text if large. how wrap button text , still align correctly? also, want button width same have build multiple buttons of same size varied texts , images. thank much. quicker solution appreciated anxious see doing wrong. here code have far: jsfiddle <a href="https://www.google.com" style="color: white !important; background-color: #7fff00;padding: 25px;width: 50px;"> <span style="margin-bottom: 5%;"> <img src="http://placehold.it/30x30" height:100%; style="display: inline-block;" width="30" height="30" /> <span style="display:

ios - UIView as popup landscape autolayout issue -

i have created simple popup issue when m trying landscape popup not working note : using autolayout here's code mpop = [[mpopup alloc] init]; mpop.frame = cgrectmake(((self.view.frame.size.width) - mpop.frame.size.width) / 2, ((self.view.frame.size.height) - mpop.frame.size.height) / 2, mpop.frame.size.width, mpop.frame.size.height); uiview *newview = [[uiview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; mpop.overlay = newview; uivisualeffect *blureffect; blureffect = [uiblureffect effectwithstyle:uiblureffectstyledark]; uivisualeffectview *visualeffectview; visualeffectview = [[uivisualeffectview alloc] initwitheffect:blur

mongodb - Can't find documents by criteria containing string objectId value -

i have collection list such: {username: 'somename', friendid: '57d725d6b8b144044602bf74' <-- reference objectid doc } when query docs in collection criteria {friendid : '57d725d6b8b144044602bf74'} no results . other field query works fine. i tried convert value objectid('57d725d6b8b144044602bf74') though value string, still no go. why failing search type of string ? you trying achieve 'self-join' in mongodb , seems rely on _id field generated mongodb. i suggest supply custom _id fields document. eg: {_id:"alex", name:"alex", friendid:""} {_id"john", name"john", friendid:"alex"} and can execute queries ease on friendid field. give shot , see if make sense requirement.

How can an iptables 443 redirection on my host interfere with outbound HTTPS requests from my Docker container? -

i diagnosed complex issue involving docker , iptables . i have ubuntu host following iptables settings: $ sudo iptables -l -t nat [...] chain xyz (1 references) target prot opt source destination redirect tcp -- anywhere anywhere tcp dpt:https /* xyz */ redir ports 8443 the rule in place redirect inbound traffic port 443 8443. meant redirect traffic java-based application has nothing docker containers, runs on same machine, , has self-signed ssl certificate. when run docker container on same machine docker's default network settings, , issue wget https request within container, docker (or os) seems redirect outbound connection port 8443 on ubuntu host, and, therefore, local java-based application which, in turn, accepts connection (most of times) , returns invalid (self-signed) certificate details. result, applications inside container end talking local java application on host, instead of real servers on internet

docker - Configure Nginx for routing -

i using nginx docker image on port 80 in vm (address x.y.z.w ). when try http://x.y.z.w in browser, showing me nginx index file. now configuring (basically proxy passing) 2 docker images running on same vm on ports 8081 , 8082. want: when type http://x.y.z.w/a should go http://x.y.z.w:8081 when type http://x.y.z.w/b should go http://x.y.z.w:8082 for this, changed portion in conf file: location /a { rewrite ^/a(.*) /$1 break; proxy_pass http://x.y.z.w:8081 ; } location /b { rewrite ^/b(.*) /$1 break; proxy_pass http://x.y.z.w:8082 ; } it working expected. images in same machine (have same ip), want use localhost instead of x.y.z.w . not working localhost . basically, don't want use hardcoded ip (x.y.z.w) in links, ip can change in future. is there way, nginx can know variable ip on running , may use ip. or how can work localhost modification? you can't use localhost address docker container, since r

MySQL Left join with Like condition like this -

select user_ip affi left join cc on affi.user_ip on "%cc.auth_ip%" now ip field in cc table looks : 11.11.11.11:2312 , on affi table looks 11.11.11.11 this. any ideas? :) in advance try this select user_ip affi left join cc on affi.user_ip concat(cc.auth_ip,'%') you try use substr

ssl - youtube-v3-api security certificate renewal -

we required add certificate https://www.googleapis.com/youtube/v3/videos our trusted certificates on our servers complying security policies. we noticed certificate expires on 24th of november,2016. can support team mailing list can contact new certificate in advance there no outage functionality. thanks i think missing basic concept of tls: role of certificate issuer. you don't lock specific certificate site , hope provide new certificate front if old certificate expires , can change clients accept new certificate. not scale. instead trust issuer (ca - certificate agency) issue certificate specific site. check certificate got trust chain locally trusted certificate fine , subject of certificate matches site access. same ca certificate (or @ least public key inside) used many years issue new certificates, contrary leaf certificates valid 1..3 years or few month reduce risk of compromise. in summary: don't expect tell front when issue new certificate beca

java - what is best option for creating log message buffer -

i working on web application needs deployed cloud. there cloud service can store log messages applications securely. exposed cloud using rest api can take max 25 log messages in json format. using log4j(open other too) log in file. now, need transition our application move file based logging using cloud rest api. i considering expensive make rest api call every log message , slow down application. in context, considering writing custom appender can write buffer. buffer can in-memory or persistent buffer read , emptied periodically separate thread or process sending 25 messages in bunch cloud rest api. option 1: using in-memory buffer custom appender write message in memory list , keep filling it. there woudl daemon thread keep removing 25 messages @ time buffer , write cloud using rest api. there downside approach in event of application/server/node crashing.. lose critical log message can lead diagnostic of why crash occurred.i not sure if right way of thinking. option 2

Wrapping ui-select with angularjs custom directive -

yes, there couple of similar questions on so, none seem address issue (or work recent versions of angular 1.5.8 , angular ui-select 1.4.x). the problem i'm having bi-directional data binding. when try bind model ui-select, if without directive wrapped ui-select, works. when use wrapped ui-select, updated in 1 direction, until modify model within directive. index.html <div class="form-group"> <label class="control-label" for="test">test</label> <ui-select id="test" multiple="" ng-model="vm.selectedinstrument.gradelevels" theme="bootstrap" close-on-select="false" append-to-body="true" style="min-width: 250px"> <ui-select-match placeholder="this test">{{$item.name}}</ui-select-match> <ui-select-choices repeat="opt in vm.gradelevellist | filter:$select.search"> <div ng-bind-html=&qu