Posts

Showing posts from April, 2013

android - Scroll layout containing listview -

Image
i have listview contains 600 elements, right above have 2 spinners use filter list. possible make when start scrolling down listview, first scroll entire page hide 2 spinners before start scrolling actual listview. (the red box framelayout) i've sketched out current layout along desired effect. start seeing 2 spinners, single list item use header listview, , listview itself. when start scrolling, want first spinners dissapear under toolbar, , start items scroll. is possible? if not, alternatives display list filtering controls while not occupying of screen? edit: i've started experimenting nestedscrollview, , sorta works. here layout: <android.support.v4.widget.nestedscrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp"> <linearlayout android:layout_width="match_parent&q

google apps script - Get ID folder before importing data -

i have followed code how automatically import data uploaded csv or xls file google sheets , not explain how find folder id file has been uploaded to. i need provide spreadsheet template multiple users facilitate identification of folder, since have no way of knowing sure each user save csv file. wish avoid mistakes identifying destination folder. how can obtain id of folder user importing data?

homebrew - Is there a way I can find what HOMEBREW_CC/XX was set to when I installed a package -

some of i'm doing compiler dependent. possible check if, example, boost formula installed gcc-4.9 or clang compiler? what i'm looking might this: $ echo homebrew_cc $ brew install boost $ <comand> built clang $ brew uninstall --force boost $ export homebrew_cc = gcc-4.9 ; export homebrew_cxx = g++-4.9 $ brew install boost $ <command> built gcc-4.9 the compiler listed in receipt $ cat /usr/local/cellar/boost/1.58.0/install_receipt.json {"used_options":["--c++11","--with-mpi","--without-single"],"unused_options":["--universal","--with-icu4c","--without-static"],"built_as_bottle":false,"poured_from_bottle":false,"time":1437512231,"head":"1d7b6215cbe7d690e961f1a72f497a58c95f6de4","stdlib":"libstdcxx","compiler":"gcc-5","source":{"path":"/usr/local/

node.js - NodeJS, is console.error synchronous like console.log? -

i noticed while debugging app, console.error not seem execute synchronous while console.log does. wanted try winston see if had same behavior , indeed did. missing here? shouldn't logging synchronous? ran myself. seems there node.js bug causing this: https://github.com/nodejs/node/issues/7743

html - link tag media attribute - projection, tv not valid -

according w3.org validator : <link rel="stylesheet" href="css/style.css" media="screen, projection, tv" /> does not seem valid anymore. due "projection" value. i don't remember exactly, way opera in fullscreen included. opera load file media="screen" too. questions: why invalid now? is there way give css "fullscreen / projection" devices? should media attribute omitted, basic layout styling? maintainer of w3c html checker here. 3 weeks ago implemented , pushed production w3c html checker change emits these new errors; change: https://github.com/validator/validator/commit/66c739a49afd050226a91f2b7f49662e0dcc9a09 i made change in order bring html checker in conformance current css media queries spec. noted in earlier comment: mq4 deprecates css2.1 media types except all , print , screen , speech , citing use of media feature detection instead, saying: in addition, foll

reactjs - Jest fails to load moment -

i have simple react component utilizes moment library: import react 'react'; import moment 'moment'; let { component } = react; export class simpleapp extends component { constructor (props) { super(props); var currentdate = this.props.data[this.props.current].date; this.state = { currentdate: currentdate, currentfromatted: moment(currentdate).format('dddd, mmmm yyyy') }; } render() { return ( <div classname="simple">{this.state.currentdate}</div> ); } } module.exports = simpleapp; and have test test component: import react 'react/addons'; import simpleapp '../js/components/pages/simple.react'; var testutils = react.addons.testutils; jest.dontmock('../js/components/pages/simple.react'); jest.dontmock('moment'); describe('simpleapp', () => { it('should not anything', ()

php - How to get number of queued jobs in IronMQ using Laravel 5.1? -

Image
implementing queues & jobs in laravel 5.1 in project using ironmq , can send jobs ironmq queue see in image bellow : what want current number of messages in queue (number in red box) in handle function in job, find job code bellow : class getwords extends job implements selfhandling, shouldqueue{ use interactswithqueue, serializesmodels; /** * create new job instance. */ public function __construct(url $url) { } /** * execute job. */ public function handle() { //getting name of queue dd($this->job->getname()); //return 'words' $currentnumbermsgsinqueue = ?????; //i can't find how //condition if($currentnumbermsgsinqueue == 10){ //do } } } question : how number of queued jobs (messages) in ironmq queue using laravel ? after days of searching found answer, there's no method/function in laravel 5.1 can give number of queued

laravel - Including Sub-Views in Blade -

i'm trying include 2 sub-views ( 'login' , 'register' ) in 'home' view this: @extends('master') @section('content') @include('auth.login') <hr> @include('auth.register') @endsection and 'login' , 'register' views: //register.blade.php @extends('master') @section('content') {!! form::open() !!} <div class="form-group"> {!! form::label('email', 'email address') !!} {!! form::email('email', null, ['class' => 'form-control', 'placeholder' => 'email address', 'required' => true]) !!} </div> <div class="form-group"> {!! form::label('password', 'password') !!} {!! form::password('password', ['class' => 'form-control'

C# Convert string to array -

so i'm working umbraco , using tag datatype. i'm trying take tags added given node , putting them array of strings when grab value seems come out this: "[\"tag1\",\"tag2\"]" how can convert string of array regular array? have gotten far string of individual characters the array format have provided example looks part of json object. you use json.net library parse array token of json object. var array = jarray.parse(tagstring).values<string>(); a complete example available here .

performance - Show images or video or text in ListView in Android -

i trying understand best in case have listview , set text content on textview. there can photo type or video, still have textview in row. should best, have "just in case" imageview , videoview , show them when it's case? thinking of performance well. being custom adapter, least of logic faster render. this row xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" android:orientation="vertical" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/activity_horizontal_margin" > <com.pubble.moderator.utils.circleimageview android:id="@+id

php - How to get a contact list from a gmail account within Yii framework 2.0 -

i have created google app. want contact list gmail account yii 2.0 website. saw 2 interesting classes yii 2.0 provides: yii\authclient\clients\googleoauth yii\authclient\clients\googleopenid can use above classes contact list gmail account? if yes, how implement it, because in yii 2.0 docs there not sample code using these classes. if no, 1 know tutorial approach goal? working yii framework 2.0

html - How can I avoid that JQuery reloads in Rails when clicking an option from a menu -

i have menu , has hover property. when click on selected option retains background color (example: red ). i notice when clicking option reloads again whole code , that's why background colour stays seconds until whole page reloads. code: css code: #menu { float:right; height: 100%; /*background-color: green;*/ } #menu-icon { display: none; height: 40px; width:100px; line-height: 40px; border-radius: 0 8px 0 0; margin:0; background: #fabb00; background: url("../images/menu_icon.png") center; text-align: center; color: #003d72; font-weight: 600; font-size: 1em; } #menu ul { margin: 0; padding: 0; } #menu ul li { display: inline-block; height: 60px; width:150px; line-height: 60px; margin: 0 10px 0 0; background: #eee; border-radius: 0 16px 0 16px; text-align: center; } #menu ul li.last { margin:0; } #menu ul li:hover{ background-color:#fabb00; } /*

asp.net mvc 5 - c# mvc 5 display model text from list based on id -

i have model: public class model { public string id { get; set } public list<selectlistitem> items { get; set; } } now in view have: @foreach (var item in model) { @html.displayfor(modelitem => item.items.where(t=>t.value == item.id).select(t=>t.text)) } basically items property have this: value = 1 text = "somethnig" value = 2 text = "somethnig else" value = 3 text = "somethnig else in here" the id property hold value of item, can 1, 2, 3 , forth . how can display in view text of item rather value? if want acces items lists, try this. @foreach (selectlistitem item in model.items) { @html.displayfor(item.text) } now if var item object of model datattype try this. @foreach (var item in model) { @html.displayfor(modelitem => item.items.where(t=>t.value == item.id)[0].text) } note: if there not object in list complies expression t.value == item.id there not going object in index

onclick - javascript click function not working on multiple buttons -

here javascript code. problem last create function working not other.for example here have 4 create() function last 1 working properly. if have 3 3rd 1 work fine not others........please suggest wrong code....please i'm new javasript. please check code in codepen here window.onload=function() { var number_operation_table=document.getelementbyid('number_operation_table'); create('lt','<'); create('gteq','>='); create('lteq','<='); create('gt','>'); function create(prefix,operator) { number_operation_table.innerhtml+="<tr><td><input type='text' name='"+prefix+"_val1' id='"+prefix+"_val1'/>"+operator+"<input name='"+prefix+"_val2' type='text' id='"+prefix+"_val2'/></td> <td><button id='check_"+prefix+"'>check</button&g

java - How to call a servlet from a HTML form -

Image
this question has answer here: how call servlet class html form 2 answers i have problems connecting html form servlet in web application. here's html file: <form method="post" class="/login" action="/login"> <fieldset class="textbox"> <label class="textbox_field"> <span>username or email</span> <input id="username" name="username" value="" type="text" autocomplete="on" placeholder="username"> </label> <label class="textbox_field"> <span>password</span> <input id="password" name="pass

jquery - How to most efficiently check for certain "breakpoints" upon browser re-size? -

i'm playing responsive design have 2 breakpoints defined: mobile > max-width 320px tablet portrait > max-width 767px on desktop have lot of animation + advanced functionality going on javascript. on mobile , tablet im looking simplify , disable both js + "re-building" dom elements. im wondering efficient way determine breakpoints (in terms of width) be? im thinking lot performance here. i know can check window width upon re-size like: $( window ).resize(function() { if ($(window).width() > 320 && $(window).width() < 400) { //mobile } if ($(window).width() > 401 && $(window).width() < 768) { //tablet } if ($(window).width() > 769) { //desktop } }); but seems "expensive" operation? any suggestions lightweight libraries can used welcome! i ran problem , have not found perfect solution. however, there workaround seems less resource hungry. using timeout inside resize() function

python - Django doesn't recognise keyword blank on child of forms.Form -

i'm trying create form receive empty strings in of values. form not backed model object. i've defined thus: class searchform(forms.form): device = fields.charfield(blank=true) min_release_date = fields.charfield(blank=true) price_range = fields.charfield(blank=true) has_in_app_purchases = fields.charfield(blank=true) except when try run test: def test_valid_no_data(self): webanalytics.web.search import any_price, default_dates, has_iap_ids form_data = { 'price_range': any_price[0], 'min_release_date': default_dates[0], 'has_in_app_purchases': has_iap_ids[0] } search = searchform(form_data) self.asserttrue(search.is_valid()) i following exception: error: failure: typeerror (__init__() got unexpected keyword argument 'blank') ---------------------------------------------------------------------- traceback (most recent call last): file "/usr/local/lib/python2.7/dist-pac

haskell - User management in snap -

i've begun first snap application, , there not quite understand. how supposed manage users? there appears authuser type dealing user authentication. question more additional user data. such collecting name, location, etc. i have found snap-auth module on github outlining creation of user type has authuser embedded inside. concern is quite old , may not current best practise in area. the way deal additional user data put in separate table keyed key authuser type.

embedded - What is the difference between BSP and distribution layers in Yocto -

can please explain briefly bsp , distribution layers , difference between them? actually i'm not looking yocto project manual references glad explanation understand it, in words. well, despite ask for, manual has definition: machine , policy configuration the bsp layer providing machine configuration (describing hw machine have) , provide necessary low level support, kernel , bootloader, external drivers, , possibly other applications support , enablement. the bsp layer must not modify in recipe, unless machine(s) supported layer selected. the distribution (policy) layer responsible configuration of distribution wide features , selections. examples package format, c library, init system, etc. should decide whether build enable x11, wifi, bluetooth, etc, support in other recipes. done adding distro_features variable, different recipes later on should check in order decide whether or not build different configurations. as mentioned, check manual more detailed i

How to make a graphic image responsive in css -

Image
i having difficulty getting graphic behave in responsive design. the graphic in question main image below menu bar @ http://bit.ly/1wapylp html there no width attribute on graphic. <div class="gc-responsive-div"> <img class="aligncenter size-full wp-image-28 gc-responsive-img" src="/wp-content/uploads/sites/8/2014/12/g_home.png" alt="gotham communications buttons graphic" /> </div> css (added last settings in cascade) i trying force image max-width of 100%: div.gc-responsive-div, img.gc-responsive-img { max-width: 100% !important; } my expectation i want main image adjust viewport's size shrinking in responsive fashion width-wise & height-wise versus remaining @ graphic's natural height , width overflowing outside viewpoint. when view home page in large screen monitor, main graphic (natural width=663px , natural height=616px) appears designed. yet when @ home page on iphone main graphic appea

eclipse - In Android How to Restart App On Click Application "onGoing" Notification. if App is open or not -

in android how restart app on click application "ongoing" notification. if app open or not. like when click on ongoing notification "connected media device" you can define actions want happen when interacting notification adding pendingintent . in following example pendingintent created launch (current) activity. intent added notification in content section. once notification shown, when click content section, intent fired , app gets started or brought top. private static final int notification_id = 1; ... notificationmanager nm = (notificationmanager) getsystemservice(notification_service); notificationcompat.builder nb = new notificationcompat.builder(this); pendingintent pendingintent = pendingintent.getactivity(this, 0, new intent(this, mainactivity.class) .setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top), 0); nb.setsmallicon(r.drawable.abc_ic_ab_back_mtrl_am_alpha) .setcatego

java - Eclipse add XText editor to perspective -

i have own perspective want add xtext generated editor @ special location. currently, opens @ editor area (hard coded eclipse org.eclipse.ui.editorss ). however, xtext editor should open @ special location , not @ editor area. achieve behavior either adding view direct or adding placeholder id of view. generated xtext editor not view , cannot added using view mechanisms. i prefer way plugin.xml's perspectiveextensions extension. how can add xtext editor @ own location perspective? in eclipse 3.x compatibility mode rcp editors shown in editor area, there no way change this.

javascript - In React.js, how would I set up a simple global event system to communicate between components? -

after toying react bit, think it, there couple of things i'm struggling figure out how do. 1 of basic communication between components not in parent-child relationship. as understand tutorial, communication done via parent-child relationship using states , props, , seems simple enough. when there no parent-child relationship, docs recommend setting global event system , leave me figure out. not sure meant this. let's take problem i'm working on example. have <searchbar /> component in navbar of page , use populate search results in <resultstab /> component elsewhere on page. trying relate these via common parent isn't practical. how update resultstab searchbar's results? i'm sure via jquery , forget react, proper react way this? facebook have released pattern called flux - https://github.com/facebook/flux . can verbose in simple applications, works well. as these things, community moving very fast , making lot of changes. r

devops - need to get two different config files with diffferent set of variables using same template and playbook Ansible -

i want deploy code in 2 systems.... group_vars/all has different variables, eg. --- # group variable webservers username: abc hosts have windows group , 2 machine ips.. [webservers] 10.0.1.2 [databases] 10.0.1.3 role/tasks/playbook have play execute on both machines... --- - hosts: roles: - base current: its taking var folder , substituting in jinja2 template , running tasks based on template info. need: i in situation 1 user variable username should different 2 machines..... want run same playbook , same template username=abc on 1 machine , username=xyz on machine.. is possible? beside group_vars there host_vars , can define individual variables per host. host dependent should stored there , username appears fit there. for hosts other 2 can fall variables defined in group_vars or set default value in template: {{ username | default("axelfoley")}}

vba - Date Stamp on data entry -

i trying date stamp field when field has had valid data entered. below have: private sub purchaser_afterupdate() if purchaser.value <> "" date_alloc.value = now() end if end sub however not work. there no error message; doesn't enter date. when purchaser.value null, condition purchaser.value <> "" not true, nothing assigned date_alloc.value . change if condition true whenever purchaser.value null or contains empty string ( "" ). private sub purchaser_afterupdate() 'if purchaser.value <> "" if len(me.purchaser.value & vbnullstring) > 0 me.date_alloc.value = now() end if end sub

tabs - Bash Autocomplete Predicts Command -

when press tab autocomplete, bash predicts available command if there multiple commands available. for example, if in directory file named foobarbaz.txt , foobarbing.txt , write: $ foo pressing tab result in $ foobarbaz.txt rather desired $ foobar

hadoop - how can I do lock in hbase now? -

rowlock function not allow anymore. htable.lockrow() not provided in library how can implement lock in hbase? is there method me that? client-side rowlocks not supported now: https://issues.apache.org/jira/browse/hbase-7315

javascript - js searching for pattern doesnt work -

i used pattern make sure if there running same char 3 occurrence in php code , working when tried in javascript didn't work idea? if (!(/(.)\\1{2}/.test(string))) { console.log('there no running 3 chars occur in string'); } else{ console.log('there 3 running same char occur in string'); } the console give me "here no running 3 chars occur in string" although string "iii" any idea? you have escaped \ in pattern. trying match letter followed 2 \ characters. try updating pattern /(.)\1{2}/ . if (!(/(.)\1{2}/.test(string))){ console.log('there no running 3 chars occur in string'); } else { console.log('there 3 running same char occur in string'); }

javascript - Browserify bundle size with Ampersand / React -

i i've seen far ampersand js & react. but i've ran deployment issue. when run test package ampersand (quick start guide) app bundle size 455 kb uncompressed / around 30kb compressed. great. https://ampersandjs.com/learn/quick-start-guide when run browserify (same package) it's 955kb uncompressed , 255 compressed (i compress minifyify). problem browserify (uncompressed twice big), it's recommended , love too. browserify client/app.js -o ./bundle.js browserify client/app.js -p [minifyify --no-map --uglify [ --compress ] ] > bundle.js so wrong way approach it... can me on this? same react ... official mi.js twice smaller have when require react update 1: after research got feeling same modules being loaded twice. i.e. diff. versions etc. did npm dedupe - didn't :( no issue - found out had gzip disabled on local machine. awesome tool though: https://github.com/hughsk/disc

javascript - Quadratic Bezier Curve with inner Triangle -

Image
recently building javascript module add convenience functions draw quadratic bezier curve. function have source point, target point , control point , create svg path this: <path id="active" d="m"+sourcepoint+" q "+controlpoint+" "+ targetpoint+" " fill="orange" fill-opacity="0.8" stroke="steelblue" stroke-width="2px" cursor="move"> the point have mention is, control point change dynamically, when change have figure this: i downloaded image this link. this regular way draw quadratic curve outer triangle "imagine triangle p0,p1,p2 points".i don't know if there ways calculate b point on curve? my goal draw quadratic curve inner triangle p1 on curve this: is there way draw kind of quadratic curve or calculate b point on first picture? formula find coordinates of point b @ needed value t on quadratic bezier curve (apply formula each coordin

networking - Desktop Computer - Detecting type of internet connection -

is there way detect if computer connected via cable or mobile network internet? i tried analyze trace-route output realized need large , up-to-date database detect type of network data packages take. have 2 different types of network maybe different attributes detect? you can use networklistmanager apis find if network connected internet. example below both , checks see if network free. can remove cost related code: hresult getfreeinternetinterface(_out_ guid* pinterfaceguid) { bool fcoinitialized = false; hresult hr = coinitializeex(null, coinit_multithreaded); if (succeeded(hr)) { fcoinitialized = true; ccomptr<inetworklistmanager> pnetworklistmanager; hr = pnetworklistmanager.cocreateinstance(__uuidof(networklistmanager)); if (succeeded(hr)) { ccomptr<ienumnetworkconnections> pnetworkconnections; hr = pnetworklistmanager->getnetworkconnections(&pnetworkconnections)

Why is A* search algorithm better than A? -

i trying understand why, theoretically, a* search algorithm considered better a search algorithm . in both algorithms, nodes expanded according function f(n) . in a : f(n) = g(n) + h(n) in a* : f(n) = g(n) + h*(n) (the * means function estimate ). a* supposed reduce amount of paths have generated , compared. question is: how using h*(n) instead of h(n) reduce amount of paths? thanks :) because don't know exact value of h(n) . calculate you'll have complete search node goal, , doing each node expensive. consider cities connected roads. how know travel distance reach goal city given city is? can't without searching. instead, can, example, use direct distance estimate of actual travel distance, simple , fast calculation if have coordinates of both cities.

php - update user score from other tables -

i have few tables each have own scores each user. create trigger add scores each user , put them in field called score in users table. tables (they have same fields few different ones) : table 1 : {id, user_id, score} table 2 : {id, user_id, score} table 3 : {id, user_id, score} users : {id, name, overall_score} // overall _score has value , want add score fields other tables one. to achieve lets first write select query , sum of scores per user 3 given tables , how done select u.*, y.total users u left join ( select user_id,sum(score) total from( select user_id, score table_1 union select user_id, score table_2 union select user_id, score table_3 )x group x.user_id )y on y.user_id = u.id here demo http://www.sqlfiddle.com/#!9/6f936/1 now lets convert select update command , as update users u left join ( select user_id,sum(score) total from( select user_id, score table_1 union select user_id, score table_2 union

Python Unicode Encode Error when writting to csv (changing exact data) -

pe¥a, humberto j., 86, of miami, florida passed away tuesday, july 7, 2015 @ home after long illness. survived loving wife sharon, children, cristy , jorge, stepson carson, 7 grandchildren , predeceased son, humberto. survived angelita barcena , brother antonio pe¤a. missed all, beloved dachshund, barna. visitation 7:00-10:00 pm july 9, 2015 @ caballero-rivero westchester. funeral mass held @ st. kevin's catholic church, friday july 10, 2015 @ 10:30 am. internment follow. in lieu of flowers, family suggests donations in name jos‚ mart¡ foundation. i want insert para csv file // notice = above para //content.text = a_name try: a_writter.writerows([[content.text, url, notice]]) except unicodeencodeerror: try: notice = unidecode(notice.encode('utf-8')) a_writter.writerows([[content.text, url, notice]]) except unicodeencodeerror: content_text_encoded = unidecode(conte

rust - Implementing the From trait for a ParseIntError -

when using try! macro, uses trait transform error desired error. i transform errors own type. goes great e.g. io::error, can't work error type core. use std::io; pub struct parsererror { pub message: string, } impl from<io::error> parsererror { fn from(e: io::error) -> parsererror { parsererror{message: format!("generic io error: {}", e.description())} } } this works doing try! on io. parsing: fn parse_string(s: &str) -> result<u64, parsererror> { let = try!(s.parse::<u64>()); return ok(i); } my error says: error: trait core::convert::from<parser::parsererror> not implemented type `core::num::parseinterror i tried implement from: impl from<core::num::parseinterror> parsererror { fn from(_: core::num::parseinterror) -> parsererror { parsererror{message: "invalid data type".to_string()} } } but can't core imported. how this? the modules core

xna - Monogame - How to properly cap FPS in Monogame? -

i wanted cap fps of game @ 30fps conditionally if being built windows phone, don't need running @ 60fps on , heard many better have capped on mobile device because of battery draining. i used same snippet of code used xna windows phone 7: //framerate 30fps default windowsphone. targetelapsedtime = timespan.fromticks(333333); but... doing job capping fps, affecting else too, causing stuttering , sound issues. because of this, suppose i'm doing wrong. anything me great, not able find on internet regarding issue (most people wanted quite opposite :d ) to fix sound issues multi-threading , running sound system on separate, uncapped thread. game code, code updates assets, method should work, differently. // in game1 class variable definitions private const float timetonextupdate = 1.0f / 30.0f; private float timesincelastupdate; //in game1 update method public override void update(gametime gametime) { timesincelastupdate += (float)gametime.elapsedgametime

matlab - Find the optimum combination -

Image
i trying optimise this: function [ lps, lce ] = runproject( nw, np, nb) calls other functions have written before. idea find optimum combination of nw , np , nb , keep lps=0 , while lce minimum. nw , np , nb should positive integers. lce positive. function [ lps, lce ] = runproject( nw, np, nb) % % detailed explanation goes here [pg, pw, pp] = pgener(); [pb, lps] = bat( pg ); [lce] = constr(pw, pp, nb) end however, tried gamultiobj solver global optimization toolbox of matlab2015 (trial version) different approach pareto front, got error: "optimization running. error running optimization. not enough input arguments." you should write objective function following example: function scores = rastriginsfcn(pop) %rastriginsfcn compute "rastrigin" function. % pop = max(-5.12,min(5.12,pop)); scores = 10.0 * size(pop,2) + sum(pop .^2 - 10.0 * cos(2 * pi .* pop),2); as can see, function accepts inputs single vector pop . with su

Write CSV file with two columns in R loop (append) -

i have other complex script working fine, except giving trouble in writing csv file. let's here example want k , j here present in 20 rows, k being in 1 column , j being in second. for (i in 1:20) { k = i+2; j = i+20; m= data.frame(k,j) write.csv(m,file="dummy.csv",append=true) print(m) } the problem is, it writing final value of m csv, when append set true and question here is, do need make 'm' dataframe, matrix or vector? (consider k , j particular changing text strings, trying wite in csv extracting corpus) the following output of csv file: "","k","j" "1",22,40 you can't use append = true write.csv . idea should hard mess write.csv , don't want to. you can use write.table , giving solution: for (i in 1:20) { k = i+2; j = i+20; m = data.frame(k,j) write.table(m, file="dummy.csv", append=true, col.names = false,

javascript - Angular unit test to check if CSS class has been added to DOM element -

i have ng-repeat produces number of dom elements: <div "class_{{$index}}" ng-click="checktype(type, $index);"ng-repeat="item in items">{{item}}</div> when clicking between first 2 elements want toggle active class between them, i'm doing following, know addclass , removeclass not proper angular way of doing things, working ok me @ moment. $scope.checktype = function(m, n){ if(m == 'type one'){ $('.class_0').addclass('be_active'); $('.class_1').removeclass('be_active'); } if(m == 'type two'){ $('.class_1').addclass('be_active'); $('.class_0').removeclass('be_active'); } } my question is, can write angular unit test check if classes have been added / removed?

multithreading - Java: Socket closing after try-catch blocks -

i attempting client/server type chat box (using gui's). won't details of multi-threading used in program since believe not part of problem (i hope not) , amount of code post. anyways, both client , server create socket, , other stream classes within try block, , reason sockets close after catch blocks. ps not call socket.close() method anywhere end if early server, ran constructor of 1 of class. breaks down into, main has server stuff on different thread, (like previous post) fix gui can load , run server stuff without 1 waiting on other. anyways, without detail, here code public chatappprotocol(socket sock) { super("chatappserver"); // has clas var of socket this.sock = sock; try ( printwriter output = new printwriter(this.sock.getoutputstream(), true); bufferedreader input = new bufferedreader(new inputstreamreader(this.sock.getinputstream())) ; ) { // first stream

python: alias for relative import -

is possible import module of same package alias using relative import? say have following package structure: lib/ foobar/ __init__.py foo.py bar.py and in foo.py, i'd use bar.py, i'd use "bar.my_function", instead of from .bar import my_function , i've tried import .bar bar , import .bar , both of don't work (invalid syntax exception). i've tried both pythhon2.7 , python3.4 (the latter being target version). however, work, , i'm using now, import foobar.bar bar , i.e. absolute import instead of relative. it's ok solution, given don't expect package name change (and if does, there's not change in code), nice if accomplish using relative import! summary: #import .bar bar # why not?!? #import .bar # shot in dark import foobar.bar bar # current solution you need use from . import bar the documentation states concerning this [...] can write explicit relative imports from module impo

c++ - Comparing two data files -

i have 2 data files, in there data points same values, need produce , output in i'll have common data points. here's code: #include<iostream> #include<cmath> #include<fstream> using namespace std; int main() { long double p_1,pd_1, age, mag, p_2, pd_2, dm_2, tsc_2, s_2, d_2, lum_2; double data1[1659]; double data2[1688]; std::ifstream fin ("sort.txt",std::ifstream::in); std::ifstream gin ("sort1.txt", std::ifstream::in); for(int i=0; i<1659; i++) { fin>> p_1 >> pd_1 >> age >> mag; data1[i]= p_1; } for(int i=0; i<1688; i++) { gin>> p_2 >> pd_2 >> dm_2 >> tsc_2 >> s_2 >> d_2 >> lum_2; data2[i]= p_2; } for(int i=0; i<1659; i++) { if(data1[i]==data2[i]) cout<<p_2<<"\t"<<pd_2<<"\t"<<dm_2<<"\t"<<tsc_2<<"\t"<<s_2<<"\t"&

c# - Compare generated xps document against a nominal xps, ignoring random resource GUID's -

Image
in wpf application i'm generating xps report based on flowdocument. i've tested viewmodel part of generation unit tests, i'd add acceptance test (using specflow, http://www.specflow.org/ ) compares newly created report against nominal report in order avoid unwanted changes in future. unfortunately, unzipped content of generated xps differs in guid's of embedded resources (e.g font) each time report re-generated. guess comparing fixed pages in /documents/1/pages enough, nevertheless fonts referenced guid in there. is there way how can compare xps files ignoring guid part? can give me hint right direction?

python - TemplateDoesNotExist at / base.html -

Image
friends. try repeat doing example of project in book: "learning django web development" jaiswal, sanjeev. running server such exception: templatedoesnotexist @ /base.html templatedoesnotexist @ / base.html request method: request url: http://127.0.0.1:8000/ django version: 1.8.3 exception type: templatedoesnotexist exception value: base.html exception location: c:\python34\lib\site-packages\django\template\loader.py in get_template, line 46 python executable: c:\python34\python.exe python version: 3.4.3 python path: ['c:\\dj\\mytweets', 'c:\\windows\\system32\\python34.zip', 'c:\\python34\\dlls', 'c:\\python34\\lib', 'c:\\python34', 'c:\\python34\\lib\\site-packages'] server time: tue, 14 jul 2015 14:01:27 +0300 template-loader postmortem django tried loading these templates, in order: using loader django.template.loaders.filesystem.loader: using loader django.template.loade

php - Laravel intermediate data type on query builder -

i have date inside query in laravel. query builder doesn't read date string. cant put variable inside query can't use date->format nor explode string.. here code.. if(isset($input['time']) && $input['time'] != '') { //useless, laravel cant read $wew = explode('/', $input['time']); $time = $wew[0]."-".$wew[1]."-".$wew[2]; $actlist = db::table('activity') ->join('activity_details', function($join) { $join->on('activity.id','=','activity_details.activity_id') ->where('activity_details.time','>=', (date(str_replace('-','-',input::get('time')).' 00:00:00',time())) ) ->where('activity_details.time','<=', (date(str_replace('/','-',input::get('time')).' 23:59:59',time())) ); }) ->orderby(

design - Communication between Java web applications -

i have multiple java web applications deployed on same server (wildfly). they should use single websocket implementation send messages (object, not plain text) user. edit: webapp1-3 applications business logic. purpose of webapp4 update primefaces panel in browser based on messages generated other webapps. sorry missleading illustration. webapp1 webapp2 --> ??? --> webapp4 (websocket-server) --> js/browser webapp3 which best way/pattern/implementation make webapp4 available other applications? (rmi, jms, websocket, webservice, ....?) my advice, general way of exposing services, expose rest services since simpler soap web service , allow interoperability (if in future php or ruby webapp needs consume services it's easier rest interface 1 base on rmi or jms). content of rest service may vary, suggest @ xml or json way of transmitting information on http rest services.

c# - CRM Dynamics 2015 Plugin Cast Error, Specified Cast Is not valid -

below snippet of code plugin, added wcf service consumed(code) well. plugin code below if (context.inputparameters.contains("target") && context.inputparameters["target"] entity) { entity phonecallentity = (entity)context.inputparameters["target"]; if (phonecallentity.logicalname != "phonecall") return; if (context.messagename == "create") { try { int numbertocall = phonecallentity.attributes.contains("phonenumber") ? (int)phonecallentity.attributes["phonenumber"] : 0; int receivecallon = phonecallentity.attributes.contains("new_destination") ? (int)phonecallentity.attributes["new_destination"] : 0; string apikey = phonecallentity.attributes.contains("new_apikey") ? phonecallentity.attributes["new

python: when making a list of lists do i have to contain them in square brackets? -

so whats difference between: x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] and x = [[1,1,1], [1,1,1], [1,1,1], [1,1,1]] do square brackets around second option anything? x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] will create tuple lists x = [[1,1,1], [1,1,1], [1,1,1], [1,1,1]] will create lists of list i.e.) x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] x ([1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]) type(x) <type 'tuple'> "a","b" ('a', 'b')

How to set the Keyusage value to new openssl X509 certificate in c program? -

unable set keyusage ( key encipherment, digital signature, crl_sign, non_repudiation e.t.c ) new x509 certificate in openssl. help me how solve this...? by adding below functionality can key usages, basic constraints our created certificate.... int add_ext ( x509 *cert, int nid, char *value ); // local variable definition int nid = 0; // add algorithms internal table openssl_add_all_algorithms( ); openssl_add_all_ciphers ( ); openssl_add_all_digests ( ); // ca certificate must include basicconstraints value // ca field set true. add_ext ( xcert, nid_basic_constraints, "critical,ca:true" ); // key usage multi valued extension consisting of list of names // of permitted key usages. add_ext ( xcert, nid_key_usage, "digitalsignature, nonrepudiation" ); // extensions consists of list of usages indicating purposes // certificate public key can used for.. add_ext ( xcert, nid_ext_key_usage, "critical,codesigning,1.2.3.4" ); // adds

php - Multitple Image upload can not save descriptions into database. How to fix this? -

i trying create multiple image upload description on each image. have used jquery coe allows me add fields on demand. however, though images uploaded , saved db, in description column array[0] instead of actual description.. how can fix this? this html <form action="upload.php" method="post" enctype="multipart/form-data"> <div class="input_fields_wrap"> <button class="add_field_button">add more fields</button> <div><input type="file" name="file_array[]"><input type="text" name="description[]" placeholder="write description"></div> </div> <input type="submit" value="upload files"> </form> and here upload.php if(isset($_files['file_array'])){ $name_array = $_files['file_array']['name']; $tmp_name_array = $_files['file_array']['tmp_name&#