Posts

Showing posts from February, 2010

Make an android activity full screen over a button -

im new on android development , want know how can make android activity fullscreen via icon placed on toolbar. thank you. please click on link example image: click preview example i think previous post may give looking for: fullscreen activity in android? from post mentioned above: you can programatically: public class activityname extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // remove title requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.main); } } or can via androidmanifest.xml file: <activity android:name=".activityname" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar.fullscreen"/> how code should differ: public class activityname extends activity { @overri

java - Weird AlarmManager behaviour -

i have 2 broadcastreceivers , 2 intents, want click button, 5m later start broadcast1 , 10m later start broadcast2, what's happening both start 10m after click, guess is, intents not unique, i'm setting diffrent reqeustcode each of them. button's onclick: bundle bd = new bundle(); bd.putint("mint", i); intent intent1 = new intent(getactivity(), broadcast_1.class); intent1.putextras(bd); pendingintent pendingintent1 = pendingintent.getbroadcast(getactivity().getapplicationcontext(), i, intent1, pendingintent.flag_update_current); alarmmanager alarmmanager1 = (alarmmanager) getactivity().getapplicationcontext().getsystemservice(context.alarm_service); alarmmanager1.setrepeating(alarmmanager.rtc, system.currenttimemillis()+1000*60*5, 1000*60*10, pendingintent1); toast.maketext(getactivity(), "countdown started "+i ,toast.length_short).show(); intent intent2 = new intent(getactivity(), broadcast_1.class); int

ruby - Rails - delete method not working -

i trying delete entry specified in docs keep getting en error stating nomethoderror in tasks#show , entry not deleted. index.html.erb: <%= link_to 'delete', destroy_task_path(task['id']), data: { confirm: 'are sure?' } %> route.rb: delete '/tasks/:id', to: 'tasks#destroy', as: 'destroy_task' resources :tasks root 'home#index' tasks_controller.rb def destroy uri = uri.parse("http://localhost/tasks/public/api/tasks/"+params[:id]) http = net::http.new(uri.host, uri.port) request = net::http::delete.new(uri.path) redirect_to :tasks, notice: 'task destroyed.' end what doing wrong here?! , why redirected show?! you missed in link_to call method: :delete , otherwise call.

machine learning - Conditional Random Field feature functions -

i've been reading papers on crfs , confused feature functions. unary (node) , binary (edge) features f of form f(yc, xc) = 1{yc=y ̃c}fg(xc). where {.} indicator function evaluating 1 if condition enclosed true, , 0 otherwise. fg function of data xc extracts useful attributes (features) data. now seems me create crf features true labels (yc) must known. true training testing phase true class labels unknown (since trying determine value). am missing something? how can correctly implemented? the idea crf assigns score each setting of labels. do, notionally, compute scores possible label assignments , whichever labeling gets biggest score crf predicts/outputs. going make sense if crf gives different scores different label assignments. when think of way it's clear labels must involved in feature functions work. so lets log probability function crf f(x,y). assigns number each combination of data sample x , labeling y. when new data sample predicted label

Django variable to javascript '&' character -

so when trying pass list of country codes javascript, replaces single quotes -> ' &#39; tried replace of regular expression, not work. i'm wondering why not work have single quotes function drawregionsmap() { (item in {{countries}}) { item.replace(/&#39;/g, "'"); } var data = google.visualization.arraytodatatable([ {{countries}} ); in javascript it's this: function drawregionsmap() { (item in [[&#39;country&#39;], [&#39;au&#39;], [&#39;at&#39;], [&#39;be&#39;], [&#39;bo&#39;], ... [&#39;li&#39;], [&#39;mc&#39;], [&#39;id&#39;]]) { item.replace(/&#39;/g, "'"); } var data = google.visualization.arraytodatatable([ [[&#39;country&#39;], [&#39;au&#39;], [&#39;at&#39;], [&#39;be&#39;], [&#39;bo&#39;], [&#39;co&#39;], ... [&#39;id&#39;]] );

node.js - Mongodb $geoNear operator not working correctly -

i'm building nodejs api using mongodb database android app. when android user sends gps position end, api sorts data distance user , replies back. for this, i'm using $geonear stage in aggregation framework. followed instructions, can't data, "undefined". here json data format db. { userid: "", description: "", location: { type: "point", coordinates: [ latitude, longitude ] }, image: "" } and here geonear code. db.posts.createindex({location:"2dsphere"}); db.posts.aggregate([ { $geonear: { near: { type: "point", coordinates: [ parsefloat(geoinfo.latitude) , parsefloat(geoinfo.longitude) ] }, distancefield: "distance", spherical: true } }, { $sort: { distance: 1 } }, { $limit: 20 } ], function(err, docs) { if (err) { callback(err, null); } callback(null, docs); });

javascript - Is it possible to pass VBscript array to highchart series data? -

is possible pass arrays vbscript highchart series? how can pass arrays data 1 , data 2 highchart series? generates array using vbscript , want pass array highchart, seems notgettgin passed highchart here vbscript code , highchart code <script language="javascript" runat="server"> var title = "test"; var data1 = []; var data2 = []; function addtodataseries1(data){ data1.push(data); } function addtodataseries2(data){ data2.push(data); } function testjshello(){ return "hello js"; } //this generates arrays , outputs them perfectly, problem when pass //it highchart nothing seems passed. //if same thing php or data generated random js , passed high chart works. can help? function returndata2elementsasstring(){ var series = ""; for(var x = 0; x < data2.length-1; x++){ series = series + data2[x] + ", " }

java - Get AudioInputStream from FFMPEG output -

i'm trying pipe output ffmpeg audioinputstream in java. have far: process process = new processbuilder("ffmpeg", "-hide_banner", "no-stats", "-y", "-i", "song.wav", "-vn", "-q:a", "5", "-f", "mp3", "pipe:1").start(); audioinputstream stream = audiosystem.getaudioinputstream(process.getinputstream()); i thought inputstream process , create , audioinputstream that, results in following exception: caused by: java.io.eofexception: null @ java.io.datainputstream.readint(datainputstream.java:392) @ com.sun.media.sound.wavefilereader.getfmt(wavefilereader.java:234) @ com.sun.media.sound.wavefilereader.getaudioinputstream(wavefilereader.java:150) @ javax.sound.sampled.audiosystem.getaudioinputstream(audiosystem.java:1113) @ com.darichey.argentumbot.argentumbot.onready(argentumbot.java:68) i'm not sure how can properly.

html - Header not full width resize -

my header fine on full screen - when resize browser, header (and footer) not span full page. know why is? if set min-width number, "960px", solves problem, makes page super long, small browser. .header { background-color: #0d0d0d; border-bottom-style: solid; border-bottom-width: 2px; border-color: #e1e1d0; border-opacity: 0.8; min-width: 100%; } .header img { margin: 20px 10px; } .header ul { padding: 10px 0; float: right; list-style-type: none; } .header li { font-size: 15px; margin: 35px; display: inline-block; text-decoration: none; text-shadow: 5px; } <div class="header"> <div class="container-fluid"> <div class="row"> <div class="col-xs-12"> <img src="http://i.imgur.com/66cegos.png?1" alt="ts logo" style="width:75px;height:75px;"> <ul> <li><a href="default.asp&

asp.net membership - MVC Multiple MembershipProviders - one of them WebSecurity -

i know how can switch between multiple membershipproviders, if of type membership, like: membershipprovider provider; if ( username.text.startswith("g\") provider = membership.providers["globalprovider"]; else provider = membership.providers["standardprovider"]; if ( provider.validateuser( ... but have troubles if 1 of them websecurity provider, vs2012 uses in internet-template, instance of extendedmembershiprovider. use 1 membership/access administration-area of website, whereas rest of site uses third-party custom membershipprovider access of users other areas. so think boils down question: how can switch between instance membership , extendedmembership? i find out current provider using // current provider var provider = membership.provider; // list of providers var providers = membership.providers; you can check whether current provider derived extendedmembershipprovider or not using: extende

reactjs - How to include javascript files when testing React components? -

i'm writing test react component uses selectpicker javascript library. here's mount method: componentdidmount() { const selectcontrol = $(this.refs.selectname); selectcontrol.selectpicker('refresh'); } it works fine since wrap javascript created webpack in rails environment includes selectpicker.js file in assets, test wrote doesn't know included file , throws error: typeerror: selectcontrol.selectpicker not function what best architecture here? should component including javascript file? can include js file in test? any appreciated. what want test exactly? if want test rendering of component without carrying if selectpicker jquery plugin has been applied, can use library enzyme (from airbnb) can shallow rendering without mounting component

linux - Run bash script with defaults to piped commands set within the script -

two questions same thing think... question one : is possible have bash script run default parameters/options? ...in sense if run script: ./somescript.sh it run ./somescript.sh | tee /tmp/build.txt ? question two : would possible prepend script defaults? example, if run script ./somescript.sh it run script -q -c "./somescript.sh" /tmp/build.txt | aha > /tmp/build.html ? any or guidance appreciated. you need wrapper script handles such scenario you. for example, wrapper script can take parameters helps decide. ./wrapper_script.sh --input /tmp/build.txt --ouput /tmp/build.html by default, --input , --output can set values want when empty.

javascript - How to define multiple views with parent child state using UI router? -

is possible define multiple views in child state parent child state relationship using ui-router? i have following code in config $urlrouterprovider.otherwise("/child"); $stateprovider .state('parent', { abstract: true, views: { 'parent': { templateurl: "parent.html", controller: "parentctrl parentctrl" }, } }) .state('parent.child', { url: '/child', views: { 'state1@parent.child': { templateurl: "child.html", controller: "childctrl childctrl" }, } }); i verify parent.html showing up, child.html not if move child.html parent views object like $stateprovider .state('parent', { abstract: true, views: { 'parent': { templateurl: "parent.html", controller: "parentctrl parentctrl" }, 'state1@parent.child': {

Visual C++ 2012 FatalExecutionEngineError -

i'm making program in visual studio 2012 (i'm using 2012 because 2015 didn't seem have visual aspect c++). i've been getting fatalexecutionengineerror in program when close when i'm using 'winmain' entry point instead of 'main'. tried running without code @ , got same error. have suggestion fixing problem? note: os windows 7 ultimate i managed fix it. hadn't included windows.h before , didn't have correct parameters. had it's return type void though apparently requires int.

node.js - Saving time series data in MongoDB and Mongoose -

i using node.js, mongodb , mongoose , trying store real time data. want store data different intervals. example 0.1 hz 30 hz. idea have 2d array minutes , seconds, , every element array again can store many values wants. (30 30 hz) using this approach mongoose scheme looks following: var sometestschema = new schema({ datatype: number, // identifier data: [ { minute: number, values: [ { second: number, values: [ { timestamp: date, value: string, } ] } ], }, ], first of all, not sure if did schema right , how model array indexes. second, how store data using mongoose now? do have hardcode "minutes" , "seconds" array? thanks help!

c# - is string variable and string variable with string.empty same? -

i have many scenarios in application declaring strings string.empty , later dynamically adding values it. in c#, string status and string status = string.empty; same? those lines of code not equivalent. if you've declared string status outside of method, initializes default value of null . if you've declared string status inside method, isn't initialized, , can't use until explicitly give value. whether or not need string status = string.empty; depends on situation, seems decent way of avoiding nullreferenceexception if find code throws.

java - Screen Size auto adjust -

so in process of making game, , want make easy screen sizes can use it. don't know how this, have set default resolution 1600 x 900. if guys know how can make adjustable sizes appreciate :) i have through code don't know have make work, if need more information on problem ask. many thanks, ash package net.captainash123.minitale; import java.applet.*; import java.awt.*; import javax.swing.*; import java.util.*; public class main extends applet implements runnable { private static final long serialversionuid = 1l; public static byte pixelsize = 5; public static int movefromborder = 0; public static double sx = movefromborder, sy = movefromborder; public static double dir = 0; public static int width = 1600; public static int height = 900; public int timer = 0; public byte movingtimer = 0; public static dimension realsize; public static dimension size = new dimension(1600, 900); public static dimension pixel = ne

Generate permutations of JavaScript array -

i have array of n different elements in javascript, know there n! possible ways order these elements. want know what's effective (fastest) algorithm generate possible orderings of array? i have code: var swap = function(array, frstelm, scndelm) { var temp = array[frstelm]; array[frstelm] = array[scndelm]; array[scndelm] = temp; } var permutation = function(array, leftindex, size) { var x; if(leftindex === size) { temp = ""; (var = 0; < array.length; i++) { temp += array[i] + " "; } console.log("---------------> " + temp); } else { for(x = leftindex; x < size; x++) { swap(array, leftindex, x); permutation(array, leftindex + 1, size); swap(array, leftindex, x); } } } arrcities = ["sidney", "melbourne", "queenstown"]; permutation(arrcities, 0, arrcities.length); and works, gu

ruby - finding specific element which exists in multiple places but has same id,class -

how find element if exists in multiple places in page has same id under same class? example: there 2 text fields same id , choose 2nd one. works when write watir/ruby(without using page object) @b.text_fields(:id => 'color').last.set "red" but unsuccessful far make work using page object. thanks in advance as mentioned in comments, best solution update fields have unique ids. however, assuming not possible, can solve problem using :index locator. following page object finds 2nd color field, equivalent watir's @b.text_field(:id => 'color', :index => 1).set : class mypage include pageobject text_field(:color_1, id: 'color', index: 0) text_field(:color_2, id: 'color', index: 1) end which called like: page = mypage.new(browser) page.color_1 = 'red' page.color_2 = 'blue' if trying last field, ie replicate @b.text_fields(:id => 'color').last.set , :index "-1": te

javascript - null dereference in React 15.1 on image load -

i'm running strange error after updating react 15.1 react 0.14: reactdomcomponenttree.js:105 uncaught typeerror: cannot read property '__reactinternalinstance$wzdyscjjtuxtcehaa6ep6tj4i' of null it appears "load" event image buried in page using data url causing event , react walks dom , when hits top element react injected has no parentelement , tries access member on "null" parentelement simplified application (abridged): class app extends react.component { render() { return <div id="rootcomponent"> ... </div>; } } reactdom.render(<app/>, document.getelementbyid('app')); resulting html: <div id="app"> <div id="rootcomponent"> ... </div> </div> the element id "rootelement" has null parentelement causes error. page otherwise seems work perplexing me. stacktrace: getclosestinstancefromnode (reactdomcomponenttre

vb.net - improving MS Project VB/VBA task creation -

at moment have code creates new tasks, it's buggy , inconsistent. public sub create_milestones() proj = globals.thisaddin.application.activeproject dim mytask msproject.task application.screenupdating = false each mytask in application.activeselection.tasks application.selecttaskfield(row:=1, column:="name") application.inserttask() application.settaskfield(field:="duration", value:="0") application.settaskfield(field:="start", value:=mytask.finish) application.settaskfield(field:="name", value:=mytask.name & " - milestone") application.settaskfield(field:="resource names", value:=mytask.resourcenames) application.settaskfield(field:="text3", value:="milestone") application.ganttbarformat(ganttstyle:=3, startshape:=13, starttype:=0, startcolor:=255, middleshape:=0, middlepattern:=0, middlecolor:=255, e

java - How to change encryption algorithm for MapReduce Shuffle -

from our test, looks hadoop shuffle uses des encryption default: ecdhe-rsa-des-cbc3-sha:112,edh-rsa-des-cbc3-sha:112,des-cbc3-sha:112. how set use aes? are these correct ones set? hadoop.security.crypto.cipher.suite=aes/ctr/nopadding dfs.encrypt.data.transfer.cipher.suites=aes/ctr/nopadding for aes use ecdhe-rsa-aes128-sha256 or ecdhe-rsa-aes256-sha384 . see supported ssl / tls ciphersuites section rsa elliptic curve ephemeral diffie hellman (ecdhe-rsa) key exchange .

Oracle to MS-Access SQL: -

i'm trying replicate sql code oracle access automate creation of reports. far have been successful having trouble one: this oracle sql: select distinct o587265.project_number e587273, o587265.project_name e587274, o587265.project_status_code e587275, o587265.project_manager e587276 ( select p.segment1 project_number, p.name project_name, p.project_status_code, ( select a.full_name apps.per_all_people_f a, apps.pa_project_players_v pm a.person_id = pm.person_id , pm.project_id = p.project_id , pm.role = 'project manager' , a.current_employee_flag = 'y' , a.person_type_id = 1 , sysdate between a.effective_start_date , a.effective_end_date , sysdate between pm.start_date_active(+) , nvl(pm.end_date_active, sysdate) ) project_

html - How do I get the menus become fully independent -

i have project http://codepen.io/neuberfran/pen/lzeger but when click in second menu, change first menu how fix issue? <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <link href='https://fonts.googleapis.com/css?family=roboto' rel='stylesheet' type='text/css'> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <link rel="stylesheet" href="css/estilos.css"> <title>whome automatização</title> </head> <body> <div class="wrap"> <div class="info"> <h1>controlando minha janela</h1> </div> <form action="" class="formulario"> <div class="radio"> <h2>lado dir

ios - Error - did not find required record type -

so feel though close cracking first cloudkit practice @ last moment xcode unable find record type: "diningtypes". i have no errors or warnings in xcode. cloudkit dashboard set development. have correct spelling of record type. unsure dilemma is. may stretching here have wrong function of code taken verbatim working tutorial. therefore, missing function or using missed function or other dastardly nuisance? var categories: array<ckrecord> = [] override func viewdidload() { super.viewdidload() func fetchdiningtypes() { let container = ckcontainer.defaultcontainer() let publicdatabase = container.publicclouddatabase let predicate = nspredicate(value: true) let query = ckquery(recordtype: "diningtypes", predicate: predicate) publicdatabase.performquery(query, inzonewithid: nil) { (results, error) -> void in if (error != nil) { print("error" + (erro

javascript - How do i have a default property in ItemView or Layout in Backbone.marionette.js -

how have default property in itemview or layout in backbont.marionette.js. we have default property in model following . backbone.model.extend({ defaults: { contract:"", } }); in above model have defaults have default properties. can have similar in itemview or layout one should able change value defaults specified in itemview or layout you can create defaults specifying them in view classes make. example; var myview = backbone.marionette.composite.extend({ defaults:{ something: "value" } }); now instances of myview have these defaults var view = new myview({ initialize: function(){ var x = this.defaults.something; //x = "value" } );

swift - willSet/didSet called on a container's stored property x when setting a property of x -

i observed behaviour don't quite understand. when executing code in playground: protocol testp { var notes: string { set } } class testc: testp { var notes: string = "" } class testcontainer { var test: testp! = testc() { willset { print("willset") } didset { print("didset") } } } var testcontainer = testcontainer() // triggers willset+didset call on testcontainer's // stored property: testcontainer.test.notes = "x" the willset , didset blocks called though property not being set. on other hand, if change protocol of type class follow protocol testp: class { var notes: string { set } } then result expect (i.e. no call willset/didset ). what reason behaviour? i run on xcode 7.3.

sql - PostgreSQL unable to parse string to date using to_date() -

i have pretty standard date string need parse date type: "2016-06-01t23:34:25+00:00" i'm using 'yyyy-mm-ddthh24:mi:ss' format mask , query try , parse date: select to_date('last_updated_on', 'yyyy-mm-ddthh24:mi:ss') last_updated_on locations limit 1 what happens error: error: invalid value ":2" "mi" sql state: 22007 detail: value must integer. i've looked on in documentation , on trying find out why happening, , i'm totally baffled. i'm using postgresql 9.4 surround t in format string "" . if time part of date needs preserved, use to_timestamp() . select to_date('last_updated_on', 'yyyy-mm-dd"t"hh24:mi:ss') last_updated_on locations limit 1 converting date timestamp select to_timestamp('last_updated_on', 'yyyy-mm-dd"t"hh24:mi:ss') last_updated_on locations limit 1

backend - How do servers talk to clients? -

i'm trying understand how server-client networking works live multiplayer games. suppose i'm building real-time multiplayer game fps. if player a shoots player b , backend server needs tell player b got shot. i know how make player a tell backend server fired shot, send request server , how 1 make backend server tell player b got shot? does player b have checking backend server every 0.1 seconds see if happened, or is there more efficient way? the how -part less important, efficient-way cardinal: let's jump few months forward. game has several million downloads , server part has cope huge herd of keen gamers online 24/7/365. this landscape show core importance of distributed-system design properties , pain low-latency controlled software ( gaming being out of question such case ) put on table. why latency? game design strives create , maintain realistic user-experience. let's take shooting example - if player a achieves destroy

rest - com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDateTime] from String -

i have java8 localdatetime in jax-rs rest apis. webapp deployed in wildfly10. when make post call(which includes localdatetime parameter) following exception; caused by: com.fasterxml.jackson.databind.jsonmappingexception: can not instantiate value of type [simple type, class java.time.localdatetime] string value ('2016-06-02t00:08:25.605z'); no single-string constructor/factory method @ [source: io.undertow.servlet.spec.servletinputstreamimpl@396d1714; line: 2, column: 3] (through reference chain: com.leightonobrien.core.model.base.company["created"]) @ com.fasterxml.jackson.databind.jsonmappingexception.from(jsonmappingexception.java:148) @ com.fasterxml.jackson.databind.deserializationcontext.mappingexception(deserializationcontext.java:843) @ com.fasterxml.jackson.databind.deser.valueinstantiator._createfromstringfallbacks(valueinstantiator.java:277) @ com.fasterxml.jackson.databind.deser.std.stdvalueinstantiator.createfromstring(stdvalueins

php - Codeigniter vhost LAMP configuration troubleshoot -

running lamp on ubuntu 14lts on virtualbox win7 found hiccups. i'm having trouble displaying code igniter project in machine. have followed guides including one: tut 1 , tut 2 i can make current configuration show single html page, called example.com cannot show complete code igniter project, error when running through localhost: not found requested url /alpa_blog/en not found on server. the project i'm working on big bitnami bitslow i'm planning change lamp why wanted try , see little blog on localhost. have not used lamp on apache 2.4+ i'm little confuse how edit files on vhost , tie them config.php inside code igniter. i've tried lot of different combination things no success yet. have files @: /etc/apache2/sites-available/alpa_blog.com.conf /etc/apache2/sites-enabled/alpa_blog.com.conf looking like: <virtualhost *:80> servername alpa_blog.com serveralias www.alpa_blog.com documentroot /var/www/html/alpa_blog.com/applicatio

Validation Error Message not getting displayed for custom validation in Angular 2 -

i have register form user need provide username. when customer enters username, want show validation error message if username exists in db or not. register.html <-- code here--> <div class="form-group"> <label for="username" class="col-sm-3 control-label">username</label> <div class=" col-sm-6"> <input type="text" ngcontrol="username" maxlength="45" class="form-control" [(ngmodel)]="parent.username" placeholder="username" #username="ngform" required data-is-unique/> <validation-message control="username"></validation-message> </div> </div> <--code here--> register.component.ts import {component} 'angular2/core'; import {ngform, formbuilder, validators, form_directives} 'angular2/common'; import {

c++ - How to convert a char array to a byte array on Arduino? -

im working on project , i'm stuck problem how can convert char array byte array? . for example: need convert char[9] "fff2bdf1" byte array byte[4] 0xff,0xf2,0xbd,0xf1. thanks in advance. here little arduino sketch illustrating 1 way this: void setup() { serial.begin(9600); char arr[] = "abcdef98"; byte out[4]; auto getnum = [](char c){ return c > '9' ? c - 'a' + 10 : c - '0'; }; byte *ptr = out; for(char *idx = arr ; *idx ; ++idx, ++ptr ){ *ptr = (getnum( *idx++ ) << 4) + getnum( *idx ); } //check converted byte values. for( byte b : out ) serial.println( b, hex ); } void loop() { } the loop keep converting until hits null character. code used in getnum only deals lower case values. if need parse uppercase values easy change. if need parse both little more code, i'll leave if needed (let me know if cannot work out , need it). this output serial monitor 4 byte values cont

Matlab - Queue data structure -

i working on implementing queue data structures using cell arrays in matlab. trying write functions advance queue one, search queue specific item. @ moment function looks (car types example data). function q = createqueue() q={}; q = enqueue(q,'hilux'); q = enqueue(q,'e-type'); q = enqueue(q,'beetle'); q = enqueue(q,'enzo'); q = enqueue(q,'boxter'); q = dequeue(q) q = searchqueue(q,'boxter') end % adds item end of queue. returns new queue. function q = enqueue(q,item) q{end+1} = item; end function [q item] = dequeue(q) q{1} = {}; q{1} = q{2}; q{2} = q{3}; q{3} = q{4}; q{4} = q{5}; q{5} = {}; end function answer = searchqueue(q, item) = 1:length(q) if q{i} == item answer = fprintf('found @ index %d',i); break else disp('-1') end end end currently, dequeue function leaves empty cell, rather removing ce

css - Rails How to include a scss file in a specific erb view? -

Image
this question has answer here: after gem update: test fail “asset not declared precompiled in production” 3 answers i want include assets/stylesheets/work.scss file in view/work/index.html.erb i've check question how include css or javascript in erb outside layout? and add in layout/application.html.erb <head> ... <%= yield(:header) if content_for? :header%> </head> then, add in index.html.erb <% content_for :header -%> <%= stylesheet_link_tag 'work' %> <% end -%> however, threw error i doing in development mode instead of production , why need precompile ? because including independently, , not including in application.css . default asset pipeline compile applicaiton.css/application.js , included in files. /* * manifest file that'll compiled application.css, include files * listed be

python - Conditionally parsing a string -

i'm working on small script compile csv file. i've come code combine string. site = "{}.{}".format(subdomain, fulldomain) however there situation subdomain may not exist. if case, output ".domain.tld" not correct. i wondering if there condition can add in format instruction above, or simpler check output , remove dot @ beginning if any. thanks how pretty straightforward one-liner? "{}{}{}".format(subdomain, '.' if subdomain else '', fulldomain) and can name each format item like: "{subdomain}{dot}{fulldomain}".format(subdomain=subdomain, dot='.' if subdomain else '', fulldomain=fulldomain) or, can go way: "{}{}".format(subdomain + '.' if subdomain else '', fulldomain)

sdk - Android Studio Navigation Drawer app:headerlayout and app:menu XML attributes? -

i'm new android development please excuse me if ask silly questions when i've created navigation drawer project, activity_main.xml file created: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:opendrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.navigationview android:id="@+id/nav_view" android:layou

row names supplied are of the wrong length in R -

i running r program computes similarity between product descriptions. input program file 1 column, containing list of product descriptions, each on separate row i have file contains list of product titles, each on separate row. using dist function, have computed similarity between product descriptions , stored in dist.mat matrix. next, want join product title similarity have computed. so, read product titles in names , then: dist.mat <- data.frame(dist.mat, row.names=names[,1]) colnames(dist.mat) <- (row.names(dist.mat)) and error: error in data.frame(dist.mat, row.names = names[, 1]) : row names supplied of wrong length not sure on how fix it. read this: invalid 'row.names' length can't fix error using sample$ or as.character i using: lsa_0.73, snowballc_0.5.1, tm_0.5-10 here actual example: product desc file: this glass can used drink whiskey this stainless steel glass this red rose product title file: whiskeyglass glass ros

SMTP -> ERROR: Failed to connect to server: (0) in PHP malier -

following php email code , works fine still today. require_once('_lib/class.phpmailer.php'); include 'func/db_connect.php'; error_reporting(e_all); ini_set('display_errors', 1); function supervisormail(){ global $error; $mail = new phpmailer(); $mail->issmtp(); $mail->smtpdebug = 2; $mail->smtpauth = true; $mail->smtpsecure = 'ssl'; $mail->host = 'smtp.gmail.com'; $mail->port = 465; $mail->username = "*****@gmail.com"; $mail->password = "*****"; $mail->setfrom("****@gmail.com", "employee leave management system"); } but not work without changing of code , makes following error. smtp -> error: failed connect server: (0) smtp error: not connect smtp host. message not sent. mailer error: smtp error: not connect smtp host. i not able find solution. how can fixed this. try work $mail = new phpmailer(); $mail->i

python - Issues upgrading OpenSSL to 1.0.2 on Mac(Yosemite) -

i'm running python 2.7.11 , trying upgrade openssl version 0.9.8 1.0.2 i ran command brew install openssl , things seemed install correctly. however, openssl has not been updated $ openssl version openssl 0.9.8zg 14 july 2015 $ brew install openssl warning: openssl-1.0.2h_1 installed $ brew link --force openssl warning: linked: /usr/local/cellar/openssl/1.0.2h_1 relink: brew unlink openssl && brew link openssl it looks things have been installed i'm not familiar steps take things squared away. edit updated path per this post /usr/local/bin came before /usr/bin , following: $ openssl version openssl 1.0.2h 3 may 2016 however, in python it's running old version $ python -c "import ssl; print ssl.openssl_version" openssl 0.9.8zg 14 july 2015 solved no hacks, none of above worked me. ended taking simpler , uncomplicated approach.... install python 2.7.13 official site, installs default python, upgrad

alarmmanager - Alarm manager not calling exact time in android application. I have to call alarm after every 15 sec -

this question has answer here: repeat alarm manager @ exact interval in api=>19? 1 answer alarmmanager manager = (alarmmanager)mainactivity.this.getsystemservice(context.alarm_service); intent intent = new intent(mainactivity.this, demoreceiver.class); pendingintent pendingintent = pendingintent.getbroadcast(mainactivity.this, 0, intent, pendingintent.flag_cancel_current); manager.setinexactrepeating(alarmmanager.rtc, 0, 20000, pendingintent); i set 20 sec time interval call alarm taking 1-1.10 min call which android version using ? apparently cannot set short intervals in android alarmmanager. here - scheduling alarm every second in android 5.1