Posts

Showing posts from May, 2010

symfony - FOSUserBundle allow access to whole site -

guys! i'am trying configure user system (fosuserbundle) symfony app. going ok until tried allow access whole site , restrict access routes using access control in security configuration file. firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider default_target_path: / logout: true anonymous: true access_control: - { path: ^/$, roles: is_authenticated_anonymously } - { path: ^/profile$, roles: role_user } - { path: ^/admin$, roles: role_admin } i've tried also # - { path: ^/.*, roles: is_authenticated_anonymously } # and when go index page (/), redirects me login page. want have index page visible visitors, not logged in. just can't figure out moment. thank answers. try this: access_control: - { path: ^/profile$, roles: role_user } - { path: ^/admin$, roles: role_admin } - { path: ^/, roles

mysql - How to write a query that joins 3 tables -

i having issues query utilizes 3 different tables. believe using key words not exists , not within not positive on this. post query definition, tables using, , have tried far. in advance! query: find users create jobs utilize proteins. tables: create table protein(pid integer,name varchar(50),primary key(pid)); create table job(uid integer,job_id integer auto_increment,input varchar(500),status varchar(100),start_time time,finish_time time,foreign key(uid) references user(uid) on delete cascade,primary key(job_id)); create table user(uid integer auto_increment,address varchar(40),city varchar(20),state varchar(20),zipcode varchar(10), username varchar(10),email varchar(30),primary key (uid)); create table job_protein(job_id integer, pid integer, primary key(job_id, pid)); what ive tried far... select u.uid, j.jobid, count(j.jobid) job j inner join job_proteins p on j.jobid = p.jobid inner join user u on p.uid = u.uid group j.jobid having count(j.jobid) = (select

java - Anypoint Studio 5.1.1 with empty properties view -

Image
i running new version of anypointstudio win 64bit-5.1.0-201503171252 on windows 8.1 java 8. if click on element in flow, see only: . i check eclipse logfile ( anypointstudio\workspace\.metadata\.log ) , find error: !entry org.eclipse.e4.ui.workbench 4 2 2015-04-09 19:42:58.236 !message problems occurred when invoking code plug-in: org.eclipse.e4.ui.workbench". !stack 0 java.lang.noclassdeffounderror: org/mule/tooling/apikit/common/metadata/resolver/apikitrouterinvokermetadataresolver$1$1 @ org.mule.tooling.apikit.common.metadata.resolver.apikitrouterinvokermetadataresolver$1.call(apikitrouterinvokermetadataresolver.java:65) @ org.mule.tooling.apikit.common.metadata.resolver.apikitrouterinvokermetadataresolver$1.call(apikitrouterinvokermetadataresolver.java:1) @ org.mule.tooling.utils.silentrunner.run(silentrunner.java:16) i try on different workstation same error. search missing class , found file in plugin folder: anypointstudio-for-win-64bit-5.1.0-201503171252\a

android - Must GCMIntentService always be in the base package? -

in manifest, have package com.business.project , base package of app. there have other packages such com.business.project.activities , com.business.project.utils . anyway, have class public class gcmintentservice extends gcmbaseintentservice android push notification. rather not have in base package, when move push notification not work. requirement class exist in base package? you can put in package need, make sure define correct path in manifest follows , <service android:name="com.business.project.<util / activities >.gcmintentservice " />

How does reddit update it's favicon on the fly without running into caching problems? -

this question has answer here: changing website favicon dynamically 12 answers how force favicon refresh 28 answers whenever change favicon on site work on, can take hours/days browser re-request new resource. but when go reddit, if have message notification in favicon, without page load well, think? is simple supplying new favicon different filename? how browser load without doing page load?

cocoa - KVO's add & remove observer methods – counted or idempotent? -

in kvo subscribe receive change notifications potential sender with: [potentialsender addobserver: self forkeypath: nsstringfromselector(@selector(aproperty)) options: 0 context: mykvohandle]; and can unsubscribe with: [potentialsender removeobserver: self forkeypath: nsstringfromselector(@selector(aproperty)) context: mykvohandle]; where kvo handles might created this c idiom . are calls these counted – every add must directly paired , precede remove – pre-arc retain , release ? alternatively, idempotent – number of add calls can stopped single remove , several remove operations without matching add safe? i believe idempotent approach used [acontrol addtarget:action:forcontrolevents:] and [anotificationcentre addobserver:selector:name:object:] . wrong notification centre addobserver calls. not idempotent. however, removes are. rob correcting me on t

java - How to handle array in xml / xsd for generating a POJO class? -

sample xml response rest ws - <userinfodatacontract xmlns="http://schemas.datacontract.org/2004/07/interzoic.sso.shared" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <displayname>test user</displayname> <email>test@test.com</email> <firstname>test</firstname> <issuperuser>false</issuperuser> <lastname>user</lastname> <password>testuser1</password> <portalid>0</portalid> <roles xmlns:a="http://schemas.microsoft.com/2003/10/serialization/arrays"> <a:string>registered users</a:string> </roles> <userid>43</userid> <username>testuser</username> </userinfodatacontract> xsd generated using http://xmlgrid.net/xml2xsd.html <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified" attributefo

Rails display current controller errors -

the problem simple. want display error notifications outside simple_form_for tag every controller in app. i use following code: - if @user.errors.present? .alert-box.alert{ data: { alert: true } } %div= t('simple_form.error_notification.default_message') which ok, 1 controller @user variable. want know if there clever way class instance variable ( @user ) without hardcoding name. in each controller different corresponds current controller name @user userscontroller etc. thanks help. unfortunately can accept 1 answer :) possible solution i end helper method: def errors_present? # returns string "userscontroller" support name-spaced controllers controller_name = controller.class.to_s.split('::').last # extract out "user" portion prefix_name = controller_name.gsub(/controller/i, '').singularize.downcase # there defined instance variable name? i_var = controller.instance_variable_get(:"

normalization - mySql normal form and saving fields -

i need insert database composite informations: name, section, room i want clarify that: 1) these informations unique field , i'll use them togheter; 2) name present section , room sometimes; 3)splitting force me use 3 field instead of 1 i'll set null section and/or room if not present; 4)not splitting force me set field length high contain values so question is: better split data 3 fields , "concat " them time need them or store them unique field? is better save fields number or fields length (and preserve normal form)?

unit testing - Meteor Tinytest packages dependencies -

i test code. compartmentalize code packages. , meteor. i'm trying meteor tinytest meteor test-packages , i'm getting weirdness. example: typeerror: cannot read property 'email' of undefined because of simpleschema.regex.email . code works when it's not tested. also, simpleschema object @ point (checked through console.log ), , simpleschema.regex undefined indeed, not expected. adding api.use('aldeed:simple-schema', ['server']); ontest section of package.js doesn't anything, kind of expected. i'm not sure am fix issue. apparently there's bug: package.js api.use() loads old versions , (mostly) doesn't matter application matters lot when you're testing packages individually. to updated

In R: Is there a comparable function to Unix's "find"? -

i want version of in r. find . ( -type d -name "example_folder_*" ) -prune -print > directory.csv the reason: i receiving directory contains large amount of files , subdirectories. want know folders have format, "example_folder_", located. r has function called list.dirs(arg) return vector of directories under , including arg. don't think there equivalent of -prune. once have directory tree vector though, should easy filter standard r tools.

JSON parse issue for Android -

running code android using eclipse added "bbbbbb" additional value check json object failed or not in case of incorrect values, showing me valid json, don't understand wrong. sample json, want create generic code use json file //json string - start { "alert": [{ "id": "1", "msg": "test 2" }] } bbbbbb /////////////////////////// try { mjson = new jsonobject(json_string); toastmsg("valid json"); } catch (jsonexception e) { toastmsg("invalid json" + e.tostring()); } from documentation of jsontokener.java : this parser lenient. successful parse not indicate input string valid json.

python - Grouping pages in Mezzanine -

i'm new mezzanine, i've got project , running , can generate customized page s using own model. i'd group these pages sections (and maybe subsections) this: section1 subsection1 page1.1.1 page1.1.2 subsection2 page1.2.1 ... section2 subsection1 page2.1.1 page2.1.2 ... and on. how can attach page objects specific section , subsection categories (with index page each?) need create model represent these categories , page_processor generate index or there easier way? in mezzanine, categories of section1 , subsection1 , etc. need pages well. say wanted following structure: movies comedies monty python , holy grail you first create mezannine page (or richtextpage or similar) title "movies", , enter content (even if minimal), such "these movies watch much". page automatically contain links subpages once create them. to create subpage "comedies", go &q

javascript - Do I need to define a module for each separate file? -

new angular, trying figure out how should modularize app. app toolbar toolbar.module.js menu.html index.html search.html sub-system-1 subsystem1.module.js directive-template.html sub-system-2 subsystem2.module.js directive-template.html the toolbar.module.js example has 3 directives (menu, index, search) , each directive has own controller, service. controllers, directive definitions , services defined in toolbar.module.js...kind of confusing when comes maintaining code. is possible come finer grained setup such each directive enclosed in own file along side controller & service? i figure add: menu.directive.js and inside there have like var module = angular('toolbar.menu.directive',[]); module.directives(...);//add menu directive module then inside toolbar.modules have like: var module = angular('toolbar',[toolbar.menu.directive]); is way can achieve defini

Text collaboration system using php mysql and html -

i trying create parent child text collaboration system , parent text can have more 1 child. instance : text 1 can edited , have edit 2 , text 1 can edited again , have edit 3 edit 3 can edited , become edit 4 , on. below script have allows user edit original text input : index.php <?php include 'includes/connection.php'; $query = "select * branches"; $result1 = mysql_query($query) or die(mysql_error()); while($person = mysql_fetch_array($result1)) { //as long there data, output data $id = $person['id']; $query2 = "select * branchesedit (parent_id = '$id' )"; $result2 = mysql_query($query2) or die(mysql_error()); echo "<h3>" . $person['names'] . "</h3>"; echo "<p>" . $person['lyrics'] . "</p>"; echo "<a href=\"modify.php?id=" . $person[

gnu parallel - How do I denote that arguments are related? -

i have following arguments chr1 chr2 chr3 , + - , 2 3 . for every chr want have + , 2 once , - , 3 once, this: parallel --whatflags-to-use?? echo {} {} {} ::: + - ::: 2 3 ::: chr1 chr2 chr3 + 2 chr1 + 2 chr2 + 2 chr3 - 3 chr1 - 3 chr2 - 3 chr3 the closest have gotten this: parallel --xapply echo {} {} {} ::: + - ::: 2 3 ::: chr1 chr2 chr3 + 2 chr1 + 2 chr3 - 3 chr2 how do this? not see how in brilliant tutorial, perhaps not possible... parallel echo {} ::: '+ 2' '- 3' ::: chr1 chr2 chr3 if need arguments split, bit harder: want 1 argument depend on another: parallel echo strand='{=1 $_=$_==2?"+":"-"=}' read={1} chrom={2} ::: 2 3 ::: chr1 chr2 chr3 alternatively: parallel --xapply echo str={1} read={2} chrom={3} ::: + - ::: 2 3 ::: chr{1,1,2,2,3,3} parallel --colsep ' ' echo str={1} read={2} chrom={3} ::: '+ 2' '- 3' ::: chr{1..3}

xml - How to dynamically create a SOAP request using PHP -

i trying create soap request api below in case need add other tags under <ticketid>int</ticketid> <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <getserviceticket xmlns="http://connectwise.com"> <credentials> <companyid>string</companyid> <integratorloginid>string</integratorloginid> <integratorpassword>string</integratorpassword> </credentials> <ticketid>int</ticketid> </getserviceticket> </soap:body> </soap:envelope> what correct way in php write code not using old , simple fashion string concatenation technique. i thought using sim

browser - How do I save a webpage using C++? Windows or Linux System -

i need know how save webpage using c++ on windows and/or linux. step 1) current code opens webpage: shellexecute(null, "open", websiteurl, null, null, sw_shownormal); step 2) step save webpage opened .txt your here. step 3) attempt @ closing webpage after saving .txt; however, not work currently. shellexecute(null, "close", websiteurl, null, null, sw_shownormal); this windows version. it's unicode result ascii. #include "windows.h" #include "winhttp.h" #include <iostream> #include <string> #include <fstream> #pragma comment(lib, "winhttp.lib") bool readwebpage(std::string &source, bool secure, const wchar_t *url, const wchar_t *verb) { source = "error"; bool bresults = false; hinternet hsession = null; hinternet hconnect = null; hinternet hrequest = null; hsession = winhttpopen(l"example", winhttp_access_type_default_proxy, winhttp_no_pr

elasticsearch - how to transfer elastic data from one server to another -

how move elasticsearch data 1 server another? i have server running elasticsearch 1.4.2 on 1 local node multiple indices. copy data server b running elasticsearch same version. lucene_version same on both servers.but when copy files server b data not migrated shows mappings of node. tried same procedure on local computer , worked perfectly. missing on server end? this can achieved multiple ways. easier , safest way create replica on new node. replica can created starting new node on new server assigning same cluster name. (if have changed other network configurations might need change also). if have initialized index no replica before can change number of replica online using update settings api your cluster in yellow state until datas in sync.normal operations won't affected. once cluster state in green can shut down server not wish have. @ stage cluster stage go yellow again. can use update setting change replica count 0 / add other nodes bring cluster state in g

git - How To Switch Repo Type in VSO -

we using tfvc our repository in visual studio online , wondering if there easy way switch repo types (we changing git)? understand can create new project, means have move of our backlog items on new project. there easier way this? you can't. recourse @ moment create new team project , migrate it.

html - navigation bar doesn't appear correctly, through php echo -

i'm sitting here in front of problem, unknown me. when use normal html-code works. when use php-echo, navigation bar doesn't normally. the bar supposed (here normal html code): http://i.gyazo.com/1e5c02f7e20dff5ec55800f259ff2c8f.png and php-echo looks this: http://i.gyazo.com/693dd2a2ac7a333905e2aa90cc8cc147.png and that's code snip html: <div class="navibar"> <ul id="mainnavi"> <li><a href='index.php'>index</a></li> <li><a href='index.php'>index</a></li> <li><a href='index.php'>index</a></li> </ul> </div> and here php-echos: <div class="navibar"> <ul id="mainnavi"> <?php echo "<li><a href='index.php'>index</a></li>"; echo "<li>

ios - Xcode 6.3: Could not load NIB in bundle -

when compiled using xcode 6.3 (ios 8.3 sdk), nib filenames end ~ipad or ~iphone in circumstances. example, viewcontroller~ipad.xib becomes viewcontroller~ipad~ipad.nib . causing crash because app doesn't expect compiled nib files have double suffix. to fix this, uncheck “use size classes” in affected documents in interface builder. this appears bug in version of ibtool included xcode 6.3 (and ios 8.3 sdk). it's happening in following circumstances: you have device-specific input file *~(iphone|ipad).xib size classes enabled. your deployment target older ios 8.0. i able reproduce problem on command line: xcrun --sdk iphonesimulator8.3 ibtool --minimum-deployment-target 7.0 --compile viewcontroller~ipad.nib viewcontroller~ipad.xib if you're seeing same behavior, please duplicate this radar . appears fixed in latest xcode 6.4 beta.

android - System.ArgumentException: Value does not fall within the expected range C# when subscribing to event in a different class -

i'm developing android c# application using xamarin. has simple structure: mainactivity launches , creates instances of classes guihandler , connection. each class raises different events: in connection.cs: public eventhandler<connectioneventargs> connectionmade; protected virtual void onconnectionmade() { if (connectionmade != null) { connectionmade (this, new connectioneventargs ()); } } public eventhandler<connectioneventargs> connectionfailed; protected virtual void onconnectionfailed() { if (connectionfailed != null) { connectionfailed (this, new connectioneventargs ()); } } public eventhandler<connectioneventargs> lostconnection; protected virtual void onlostconnection() { if (lostconnection != null) { lostconnection (this, new connectioneventargs ()); } } public eventhandler<connectioneventargs> receiveddata;

java - Button background with image, text and colour in android -

Image
i want create button background color, icon , text in android. don't know how add image. xml is: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="12dp" android:orientation="vertical" > <tablelayout android:id="@+id/tablelayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" > <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button" android:text="boton" /> </table

javascript - How should I use moment-timezone with webpack? -

in using webpack build project, typically require modules in commonjs npm modules. need moment-timezone in project, in building package must build data moment-timezone, can quite lot. additionally build failing following error: error in ./~/moment-timezone/data/packed/latest.json module parse failed: /site/node_modules/moment-timezone/data/packed/latest.json line 2: unexpected token : may need appropriate loader handle file type. | { | "version": "2015a", | "zones": [ | "africa/abidjan|lmt gmt|g.8 0|01|-2ldxh.q", @ ./~/moment-timezone/index.js 4:15-51 at point not concerned build failing, size of build if succeeds. though, failing build need addressed @ point. i appreciate pointers on how handle this, if of have encountered same issue using webpack (or browserify too, probably). you can fix adding json loader webpack configuration. $npm install json-loader and add loaders in webpack.config.js. don't forget a

asp.net mvc - Is it possible to set a unique constraint using Entity Framework Code First? -

i want enforce unique constraint in table & using entity framework code-first. is possible add unique constraint using ef 6 believe in earlier versions not possible. it appears unique constraint feature scheduled release version 6 got pushed 6.1. with ef 6.1, can define constraint using index attribute shown below: [index("ix_firstandsecond", 1, isunique = true)] public int firstcolumn { get; set; } [index("ix_firstandsecond", 2, isunique = true)] public int secondcolumn { get; set; } or you can use fluent api shown here in msdn

Line spacing with Latex -

hallo using latex thesis writing. , have facing problem blank line space.. wondering if don't make space in code, saw many spacing while seeing in pdf generated same code.. example, need this this thesis , finished soon. topic of thesis interesting. and this, thesis , finished soon. topic of thesis interesting. so please give me idea spaces problem, in code should make changes?? latex forces straight right margin completed lines, space words out achieve that. can tell hyphenate words instead inserting \- hyphenation locations in word want break, e.g. this thesis , finished soon. topic of the\-sis inter\-es\-ting. . can tell little sloppier sloppypar environment: \begin{sloppypar}this thesis , finished soon. topic of thesis interesting.\end{sloppypar}

html - Remove line from top of table -

i have searched site , others cannot solve issue html or css. line appears above table here . here code: <table border="0" width="840" cellspacing="0" cellpadding="1"><colgroup> <col style="width: 70%;" /> <col style="width: 30%;" /> </colgroup> <tbody><tr><td> <h1 style="text-align: center;"><span style="font-family: calibri,geneva,sans-serif;"><strong><span style="font-size: 28px;">learn paddle. make friends. have fun.</span></strong></span></h1> </td> <td>test</td> </tr> </tbody> </table> please help for reason, <td> s have borders. able remove them css using inspector. change <td style="border: 0;"> (or make class).

python - SQLAlchemy: How can I create a hybrid property for the disjunction of columns? -

i have user class stores "first_name" column , "alias" column describe person's name , nickname. want able query class find users either first_name or alias, wrote class this: from sqlalchemy import column, integer, string, create_engine, orm sqlalchemy.ext.declarative import declarative_base sqlalchemy.ext.hybrid import hybrid_property engine = create_engine('sqlite:///:memory:') base = declarative_base() session = orm.sessionmaker(engine) class user(base): __tablename__ = 'user' id = column(integer, primary_key=true) first_name = column(string(64)) alias = column(string(64), nullable=true) @hybrid_property def name(self): return self.alias or self.first_name def __repr__(self): return 'user("{}" a.k.a. "{}")'.format(self.first_name, self.alias) if __name__ == "__main__": base.metadata.create_all(engine) this works. i'm able search users fir

ios - Keyboard Extensions Xcode 6.3? -

everything working when debugging keyboard on xcode 6.2 running ios 8.2. after updating xcode 6.3 , ios 8.3, seem having difficulty getting debugger work. has experience similar problems? i've tried cleaning build, uninstalling/installing app, nothing seems work. what happens build , run, , when switch between keyboards mine never pops up, instead jumps default one. upon ending task, , doing again works perfectly, not when i'm attempting debug. some of information answer bit outdated, useful me. still convinced extension debugging on devices 90% broken xcode 6.3.2 , ios 8.3. i've been debugging simulator, though, , i'll device process attach correctly within xcode, more not quits on me.

variables - is it accepted to name a php varible like $_xxx? -

i'm building site , included settings file named "settings.php", think it's cool register global var name: $_settings array of site settings (db_name, db_pass....etc) so: <?php $_settings = array(); $_settings['db_hostname']= 'localhost'; $_settings['db_name'] = 'db_test'; $_settings['db_username'] = 'db_user'; $_settings['db_password'] = 'p422w0rd'; ?> and access settings on sub pages... accessing $_settings... this code works fine, i'm curious acceptable among php programmers community name own variables $_ ? or code considered bad design? thanks you can it, wouldn't recommend it, since superglobal variables have pattern/prefix e.g. $_server , $_session , $_get maybe bit confusing. but according manual . technical can it: a valid variable name starts letter or underscore , followed number of letters, numbers, or underscores . regular e

r - splitting a vector with strings -

i have vector, filled strings of length 2: vec <-c( "00", "10", "00", "01", "11", "11", "10", "00",...) i want split strings of vector length 1: result <- "0", "0", "1", "0", "0", "0", "0",...) the last step merge vector entries strings of length 8: qpsk <- "00100001", "11111000",...) i know there function strsplit , function paste, don't know how use in case. there efficient way this? thanks try strsplit(paste(vec, collapse=''), '(?<=.{8})', perl=true)[[1]] #[1] "00100001" "11111000" "0100" data vec <-c( "00", "10", "00", "01", "11", "11", "10", "00", "01", "00")

microcontroller - PIC184550: Program seems to terminate at call function -

i'm writing program blink red, yellow, , green leds off , on match function of traffic light. however, when run in debugger , step through (i using mplab x ide), seems stop after calling function 'loop1'. value reflected in portd value should hold after completion of loop1, rather after completion of loop6. ideas? list p=18f4550, r=dec #include <p18f4550.inc> config lvp=off config wdt=off config mclre=off config fosc = intoscio_ec org 0x00 cblock 0 delay1:1 delay2:1 counter:1 endc start: clrf trisd clrf portd clrf counter clrf delay1 clrf delay2 movlw 0x00 primaryloop: call loop1 call loop2 call loop3 call loop4 call loop5 call loop6 goto primaryloop loop1: movlw b'00010010' movwf portd movlw 0x01 movwf counter call delaymain return loop2: movlw b'01000010' movwf portd movlw 0x05 movwf c

Running Atlassian Stash & JIRA on same server -

i trying run jira , stash on same server. when start 1 of them, can access fine. however, once start second one, can no longer access either of them. i have checked logs did not see anything. when run: lsof -np | grep ipv i see both jira & stash listening on respective ports. is there tomcat config need change? your best bet raise issue , send logs through @ support.atlassian.com

requirejs - Uncaught Error: Script error for: isotope/js/layout-mode -

i need use (this standalone package)isotope.pkgd.js packery-mode layoutmode project. im using require.js wiring js stuff in amd. below html code: <div class="container"> <div class="section"> <header class="section-header"> <div class="pull-left"> <h3><span class="fa fa-image"></span>photos</h3> </div> </header> <div class="padded_content"> <div id="region-gallery" class="gallery js-isotope"> @foreach (iphotoscomponentmediaimage image in model.images) { ++count; if (w60h40nums.contains(count)) {

Why do I get bash integer expression error from [ ${guess[0]} -eq num ]? -

i trying prompt user guess value between 0-9. getting error integer expression expected. don't understand why can explain going wrong? num=8 echo "enter value between 0-9" read -a guess if [ ${guess[0]} -eq num ] ; echo "you guesses right number" elif [ ${guess[0]} -gt num ] ; echo "you guessed high" elif [ ${guess[0]} -lt num ] ; echo "you guess low" fi to make minimum number of changes necessary code run correctly: #!/bin/sh num=8 echo "enter value between 0-9" read guess if [ "$guess" -eq "$num" ] ; echo "you guesses right number" elif [ "$guess" -gt "$num" ] ; echo "you guessed high" elif [ "$guess" -lt "$num" ] ; echo "you guess low" fi notes: since you're reading single value, no compelling reason use array -- easy take out -a argument read ; doing makes code compatible posix sh, ,

linux - where is .bash_profile in cloudera? -

i unable locate .bash_profile in cloudera machine. can tell me command use find file ? i have tried find -name ".bash_profile" and nothing happen don't understand why. new cloudera , linux command .bash_profile might not exist default it's matter of creating it. read useful information .bash_profile & .profile here: https://superuser.com/questions/278433/whats-the-difference-between-profile-and-bash-profile-and-when-do-you-config

java - Display JSON file in browser with Mule -

i using json file show schema , have give config: <flow name="api-schema" doc:name="api-schema"> <http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8080" path="schema" doc:name="http"/> <logger level="info" doc:name="logger"/> <http:static-resource-handler resourcebase="${app.home}/src/main/resources/" defaultfile="schema" doc:name="http static resource handler"/> </flow> but when running it, asking download file. have tried in chrome , safari both. how can instruct mule display content on browser , don't download? the way browser determines resource looking @ content-type header. can set header creating outbound property name "content-type" , value "application/json" so: <set-property propertyname="content-type" value="application/json

android - Espresso freezing on view with looping animation -

i have view in element animated following in infinite loop: <translate android:fromxdelta="0%" android:toxdelta="100%" android:duration="10000" android:repeatcount="-1" android:repeatmode="reverse"/> when espresso opens activity, it's able perform operations freezes. suppose espresso waiting ui thread become idle never happens in case. is way me test view implement mechanism disable animations? have class handle animations, mocked tests. or build time conditionals. edit: have yet create sample project attempt recreate issue, here further details in meantime: 1) using jake wharton's activityrule have activity automatically launched ( https://gist.github.com/jakewharton/1c2f2cadab2ddd97f9fb ). 2) test: onview(withid(r.id.btn_yes)).perform(click()); 3) here complete stack trace. note appnotidleexception : running tests test running started android.support.test.espresso.performexcepti

java - Problems with Interfaces and FactoryPattern -

i have created factory pattern create objects, each of objects different , want them implement different methods, current setup have declare methods in interface , in subsequent object classes, how can around this? this example of structure food class public class food extends myobjects implements myactiveobject, { public food(string name, coordinates coordinates, int size, color color) { super(name, coordinates, size, color); } } herbivore class public class herbivore extends entity implements myactiveobject { public herbivore(string name,coordinates coordinates, int size, color color){ super(name, coordinates, size, color); } } interface public interface myactiveobject extends entityinterface { public coordinates getcoordinates(); etc... } factory class public class myactiveobjectfactory { public myactiveobject createobject(string objecttype, int objectcount, int x, int y, int scale){ if(objecttype == null){ return null;

ios - EXC_BAD_ACCESS on NSClassFromString when class doesn't exist -

nsclassfromstring supposed return nil when can't find class, i'm getting exc_bad_access crash on this: classname = "foo" var fooclass = nsclassfromstring(classname) how can safely check non-existence of class in swift & objective-c? this code working under swift: var classname = "foo" var fooclass = nsclassfromstring(classname) and 1 objective-c: nsstring* classname = @"foo"; id fooclass = nsclassfromstring(classname); your code seems correct did try upgrade xcode in order have latest version of swift?

symfony - Sonata Admin sonata_type_collection not remove child entity -

i have news entity "one many" association image entity: class noticia { function __construct() { $this->images = new arraycollection(); } /** * @orm\onetomany(targetentity="imagemnoticia", mappedby="noticia", cascade={"all"}, orphanremoval=true) */ private $images; public function removeimage(imagemnoticia $imagem) { if ($this->images->contains($imagem) { $this->images->removeelement($imagem); } $imagem->setnoticia(null); return $this; } } and admin class: class noticiaadmin extends admin { protected function configureformfields(formmapper $formmapper) { $formmapper ->add('images', 'sonata_type_collection', array( 'by_reference' => false, 'required' => false, ), array(

multithreading - JavaFX: How to make an looping thread without freezing application? -

how go making thread within javafx? i've looked around , no answers clear/want need, basicly same java's thread runnable, not conpatible javafx unless it's background task. the basic start application class have: public class main extends application { private stage stage; private anchorpane rootlayout; @override public void start(stage stage) { this.stage = stage; this.stage.settitle("main"); setlayout(); } private void setlayout() { try { fxmlloader loader = new fxmlloader(); loader.setlocation(main.class.getresource("view/view.fxml")); rootlayout = (anchorpane) loader.load(); scene scene = new scene(rootlayout); stage.setscene(scene); stage.show(); } catch (ioexception e) { e.printstacktrace(); } } public static void main(string[] args) { launch(args); } } i need

php - WordPress custom meta boxes not saving for pages -

for reason when save page, meta box information isn't saving. works fine posts though. had working on localhost, after putting online seems have somehow broken it. function framework_add_meta_box() { $screens = array( 'post', 'page' ); foreach( $screens $screen ) { add_meta_box( 'framework_pagebgimage', __( 'background options', 'framework' ), 'framework_bg_image', $screen, 'normal', 'high' ); } } add_action( 'add_meta_boxes', 'framework_add_meta_box' ); function framework_bg_image( $post ) { global $post; // add nonce field can check later. wp_nonce_field( 'framework_meta_box', 'framework_meta_box_nonce' ); $style = get_post_meta( $post->id, 'bgimage_style', true ); if( !$style ) { $style = 'background'; } /* featured imag

c# - Can't fully correct encoding issue from website -

this question has answer here: how can transform string utf-8 in c#? 7 answers i'm developing web scraper soccer site. there issue when pulling in names various countries (which, obviously, have various characters). i've worked out method correct of it, it's not catching turkish or else. here have far: private string formatme(string sf) { string mystring = encoding.utf8.getstring(encoding.utf8.getbytes(sf)) .replace("é", "é") .replace("á", "á") .replace("í", "í") .replace("ó", "ó"); return mystring; }//end format here's an example of site pull from . is there anyway can fix encoding site in 1 fell swoop? i have found answer! assuming text coming in utf8. this question helped lot!

javascript - How to swap a div's image source with another image on hover using jQuery -

i'm having issues changing attributes using jquery here's code: https://jsfiddle.net/mepygo30/ js: $("#but1").hover(function() { $(this).attr('src', 'css/img1.jpg'); }, function() { $(this).attr('src', 'css/img2.jpg'); }); html: <body> <div id = "but1" class = "button"><img src ="css/img1.jpg"/></div> </body in actual code created class each individual button , put attributes in there , separated each button different id. i want able change background image of each of buttons such "but1" img2 when mouse hovers on , when mouse leaves changes img1. thanks edit: sop jquery code: <script type="text/javascript"> $(document).ready( $("#but1").hover(function() { $(this).attr('src', 'css/facebook.png'); }, function() { $(this).attr('src', '

syntax highlighting - Match everythin between tag as comment -

i highlight every thing between !& explanation &! as comment. i know comment match with - name: comment.line.exclamation-mark.fortran match: (?i)\!.*$ in fortran.yaml-tmlanguage . don't see how extend case above. since comments multiline, need split regex 2 expressions, 1 called begin , 1 called end. allows parse multiple lines. i dont use yaml, code c tmlanguage should started (comment style /* comment */ ): <dict> <key>begin</key> <string>\s*/\*</string> <key>captures</key> <dict> <key>0</key> <dict> <key>name</key> <string>punctuation.definition.comment.c</string> </dict> </dict> <key>end</key> <string>\*/</string> <key>name</key> <string>comment.block.c</string> </dict> so use \s\!\& begin-tag , \&\! end-tag.

c++11 - C++ void reverse function -

we converting base 10 number in different base(b). having trouble void reverse function not reverse order of numbers. string converttobaseb(int num, int b){ int digit; stringstream answer; string x=""; while(num>0){ digit=num%b; num/=b; answer<<digit; } return answer.str();} void reverse(int x[],int size){//reversing for(int k=0; k<size/2; k++){ int temp=x[k]; x[k]=x[size-k-1]; x[size-k-1]=temp;} } your reverse function works fine. doesn't looks c++ me... in c++ have vector , do: std::vector<int> arr; //... fill arr std::swap_ranges(&arr[0], &arr[arr.size()/2], arr.rbegin()); if want stick loop, @ least use std::swap this void reverse(int x[],int size) { for(int k=0; k<size/2; k++) std::swap(x[k], x[size-k-1]); }

c# - Using file storage share on another server -

there server iis site asp.net, twisted in domain. there file of share not in domain, authorization login , password. a task: share should used save user files there, keeping them there , see again through asp.net. already tried , did not work: networkcredential thenetworkcredential = new networkcredential(@"username", "password"); credentialcache thenetcache = new credentialcache(); thenetcache.add(new uri(@"\\computer"), "basic", thenetworkcredential); string[] thefolders = directory.getdirectories(@"\\computer\share"); while working on test machine. apparently uses special port blocked on work server. how provide user name , password when connecting network share - connects network drive, , work not entirely correct.

terminal - Opening sublime text 3 from a tmux session opens an empty file? -

whenever try open file terminal using sublime, example: subl ~/.zshrc , works fine when try same thing inside of tmux session empty blank file. i saw many people asking related questions , blaming sublime, figured out it's not sublimes fault! it's relation between sublime , tmux. how can fix this? requires sort of permission or what? this because tmux not have root access system. it opens sublime doesn't show system files content. you need give permission first.