Posts

Showing posts from August, 2012

c++ - Counting number of bits: How does this line work ? n=n&(n-1); -

this question has answer here: n & (n-1) expression do? [duplicate] 4 answers i need explanation how specific line works. know function counts number of 1's bits, how line clears rightmost 1 bit? int f(int n) { int c; (c = 0; n != 0; ++c) n = n & (n - 1); return c; } can explain me briefly or give "proof"? any unsigned integer 'n' have following last k digits: 1 followed (k-1) zeroes: 100...0 note k can 1 in case there no zeroes. (n - 1) end in format: 0 followed (k-1) 1's: 011...1 n & (n-1) therefore end in 'k' zeroes: 100...0 & 011...1 = 000...0 hence n & (n - 1) eliminate rightmost '1'. each iteration of remove rightmost '1' digit , hence can count number of 1's.

php - Facebook Sharing Wordpress Page Not Found -

Image
i'm having issues when sharing links website (boolerang) facebook. issue is: when share role, this: when go here facebook og object debugger , show existing information, says: time scraped - 8 hours ago. response code: 404. critical errors must fixed: bad response code url returned bad http response code. however, when "fetch new scrape information", updates, , link can shared in intended form forevermore, i.e.: these symptoms lead me believe issue not access-related, that's far get. edit: my robots.txt file looks - cause? user-agent: * disallow: /wp-content/plugins/ disallow: /wp-admin/ disallow: /candidates disallow: /my-account disallow: /past-applications disallow: /manage-jobs disallow: /resume please try first of code put in function.php <?php add_action('wp_head','add_meta_function'); function add_meta_function(){ if(is_single()){ global $post; echo '<meta prope

swift - What can I use instead of NSBitmapImageRep in iOS? (Water ripples example) -

i found interesting post water ripple simulation . includes xcode project little cocoa app osx. tried app running in ios using swift, couldn't find solution following problem: the osx app uses nsbitmapimagerep draw bitmap data array onto screen (this happens in bbrippleview.m). unfortunately, nsbitmapimagerep not available in ios. tried using cgimage instead, "kind of working": can see kind of water ripples, split in weird way , don't move way supposed to. guess cgimage expects bitmap data in different format gets it. edit: here ios rippleview class: rippleview.swift edit 2: modified rippleview.swift what right way implement following osx code segments in ios using swift? image = [[nsimage alloc] initwithsize:nsmakesize(cols, rows)]; bufrep = [[nsbitmapimagerep alloc] initwithbitmapdataplanes:null pixelswide:cols pixelshigh:rows

Expand array of 1 element every loop C -

i have let user how many inputs wants , every loop need expand array let others input, when n=-1 need end loop. this code: void extend(int *a) { int *pt; pt = (int*) realloc(a , sizeof(int)); } int main() { int *a; = (int*)malloc(sizeof(int)); int i=0; int n=0; while(n!=-1) { scanf("%d", &n); if(n != -1) { a[i] = n; extend(a); i++; } } return 0; } it works 3 values stops working, can loop want when n become -1 crashes. have "invalid next size" error in compiler. edit: this code works: int main() { int *a = (int*)malloc(0); int i=0; int n; { scanf("%d", &n); if(n!=-1) { i++; = (int*) realloc(a , i*sizeof(int)); a[i-1] = n; } } while(n!=-1); return 0; } the imporant mistake don't reassign new realloc() ed pointer prev

excel - Code meant to copy rows from one sheet to another if there are specific strings in 2 columns keeps crashing -

whenever run code crashes. please help! this code supposed do. unknown amount of filled rows, if column g of worksheet "current pm" contains either "as-001", "ee-001", "mm-001", "os-001", "co-001", "do-001", "fo-001", "fd-001", "to-001", "ip-001" , column h contains "pdr" copy row "current pm" sheet "print_current pms" sheet. sub sort4printing() dim integer, j integer = 2: j = 2 while isempty(worksheets("current pm").cells(i, 1)) = false if worksheets("current pm").cells(i, 8) = "pdr" if worksheets("current pm").cells(i, 7) = "as-001" or worksheets("current pm").cells(i, 7) = "ee-001" or worksheets("current pm").cells(i, 7) = "mm-001" or worksheets("current pm").cells(i, 7) = "os-001" or worksheets("current pm").cells

c# - Column is Identity Key but not Database Generated -

how designate column database identity unique, not database generated? here how if report_id database generated: [table("[report.settings]")] public partial class report_settings { [key] [column(order = 0)] public int instance_id { get; set; } [key] [column(order = 1)] [databasegenerated(databasegeneratedoption.identity)] public long report_id { get; set; } public string report_metadata { get; set; } public string report_grid_settings { get; set; } public virtual report report { get; set; } }

ibm mobilefirst - Liberty Profile Server Datasource Trouble -

i'm configuring liberty server work mobile first platform 7.0, when i'm trying access worklight console, shows me message " server error. contact server administrator. " , runtime environments area empty. looking information in messages.log see datasource wrong don't know configured modify it. have trace , datasource portion @ server.xml : [1/15/16 16:10:00:874 bot] 000000bc com.ibm.worklight.dataaccess.datastore.datastoreutil getworklightdatasourceproperties read properties file. allproperties: {ibm.worklight.admin.db.jndi.name=java:comp/env/jdbc/worklightadminds} [1/15/16 16:10:00:874 bot] 000000bc com.ibm.worklight.dataaccess.datastore.datastoreutil dereferenceproperties handling propname=ibm.worklight.admin.db.jndi.name propvalue=java:comp/env/jdbc/worklightadminds [1/15/16 16:10:00:874 bot] 000000bc com.ibm.worklight.dataaccess.datastore.datastoreutil dereferenceproperties handling propname=ibm.worklight.admin.db.openjpa.log pro

javascript - D3 update data on the wrong bars -

i want update data on click bars changing not right ones. there cant quite fix select. on click grey bars, should bar2 updating. should bar. example: https://jsfiddle.net/monduiz/kaqv37gu/ d3 chart: var values = feature.properties; var data = [ {name:"employment rate",value:values["erate15p"]}, {name:"participation rate",value:values["pr15p"]}, {name:"unemployment rate",value:values["urate15p"]} ]; var margin = {top: 70, right: 50, bottom: 20, left: 50}, width = 400 - margin.left - margin.right, height = 270 - margin.top - margin.bottom, barheight = height / data.length; // scale x axis var x = d3.scale.linear() .domain([0, 100]) //set input scale of 0 - 1. index has score scale of 0 1. makes bars more accurate comparison. .range([0, width]); var y = d3.scale.ordinal() .domain(["employment rate", "participation rate", "unemployment rate"]) .rang

mysql - Accessing rows from a mysqli join query in php -

i have following code: // db connection info set earlier $sql= "select `table_1.id`, `table_2.id`, `potato` `table_1.id` left join `table_2` on `table_1`.`id` = `table_2`.`id_of_other_table`;"; $rows = mysqli_query($connection, $sql); foreach ($rows $row){ $potato = $row["potato"]; $id = $row["table_2.id"]; } i can't table_2.id. i've tried doing print_r proper format, says it's mysqli object , don't more info that. however, can potato. i'm guessing it's calling syntax issue, i've searched multiple sites (stack , google included) , not found clear answer. so, need instead of $id = $row["table_2.id"]; ? assign aliases columns same name. $sql= "select `table_1`.`id` t1_id, `table_2`.`id` t2_id, `potato` `table_1.id` left join `table_2` on `table_2`.`id_of_other_table` = `table_1`.`id`;"; $rows = mysqli_query($connection, $sql); foreach ($rows $row){ $potato = $r

node.js - CI Runner - use G++ 4.8 for npm install step -

i want have ci runner use g++ 4.8 npm install step. messing around witht .gitlab-ci.yml - here current version: before_script: - . /etc/profile.d/frt_environment.sh - . /etc/profile.d/runner.sh - nvm use v5.3.0 build: script: - scl enable devtoolset-2 bash - g++ --version - npm install - gulp build tags: - shell style-analysis: script: - gulp style tags: - shell unforutnately build failing. step "scl enable devtoolset-2 bash" should sweitch g++ 4.8 , when runner on console directly. next line "g++ --version" meant capture version can debug happening here. not show version 4.8 instead 4.4. whcih cause build fail. here "head" of output gitlab-ci-multi-runner 0.7.2 (998cf5d) using shell executor... running on hqdevrunner01... fetching changes... removing node_modules/ head @ 082a6fa remove allow failure https://hqdevgit01.frtservices.com/operations/frt-technical-operations-portal 082a6fa..9e36ed9 master -> origin/master c

.net - How do you effectively model inheritance in a database? -

what best practices modeling inheritance in databases? what trade-offs (e.g. queriability)? (i'm interested in sql server , .net, want understand how other platforms address issue.) there several ways model inheritance in database. choose depends on needs. here few options: table-per-type (tpt) each class has own table. base class has base class elements in it, , each class derives has own table, primary key foreign key base class table; derived table's class contains different elements. so example: class person { public int id; public string firstname; public string lastname; } class employee : person { public datetime startdate; } would result in tables like: table person ------------ int id (pk) string firstname string lastname table employee -------------- int id (pk, fk) datetime startdate table-per-hierarchy (tph) there single table represents inheritance hierarchy, means several of columns sparse. discriminator column ad

floating point - Why is 24.0000 not equal to 24.0000 in MATLAB? -

Image
i writing program need delete duplicate points stored in matrix. problem when comes check whether points in matrix, matlab can't recognize them in matrix although exist. in following code, intersections function gets intersection points: [points(:,1), points(:,2)] = intersections(... obj.modifiedvgvertices(1,:), obj.modifiedvgvertices(2,:), ... [vertex1(1) vertex2(1)], [vertex1(2) vertex2(2)]); the result: >> points points = 12.0000 15.0000 33.0000 24.0000 33.0000 24.0000 >> vertex1 vertex1 = 12 15 >> vertex2 vertex2 = 33 24 two points ( vertex1 , vertex2 ) should eliminated result. should done below commands: points = points((points(:,1) ~= vertex1(1)) | (points(:,2) ~= vertex1(2)), :); points = points((points(:,1) ~= vertex2(1)) | (points(:,2) ~= vertex2(2)), :); after doing that, have unexpected outcome: >> points points = 33.0000 24.0000 the outcome should empty matrix. can see, fi

Gitlab docker executor - cache image after before_script -

in gitlab-ci there's option in .gitlab-ci.yml file execute commands before of actual script runs, called before_script . .gitlab-ci.yml examples illustrate installing ancillary programs here. however, i've noticed these changes not cached in docker when using docker executor. had naively assumed after running these commands, docker cache image, next run or test, docker load cached image produced after before_script . drastically speed builds. as example, .gitlab-ci.yml looks little like: image: ubuntu before_script: - apt-get update -qq && apt-get install -yqq make ... build: script: - cd project && make a possible solution go runner machine , create docker image can build software without other installation , reference in image section of yaml file. downside of whenever want add dependency, need log in runner machine , update image before builds succeed. nicer if had add dependency to end of apt-get install , have docker / gitl

ruby - Add one more same set of inputs on click rails -

how can add 1 more same set of inputs example education object, have 2 new education objects after submitting? preferable new set needs shown clicking on icon goes after existing set of inputs. this new method: def new @user = user.new @user.educations.build @user.works.build end and view it: <%= simple_form_for [:admin, @user] |u| %> <%= u.error_notification %> <%= u.input :name, label: "name" %> <p><b>photo</b></p> <%= image_tag(@user.photo_url, size: "80x90", class:"img-rounded") if @user.photo? %> <%= u.input :photo, label: false %> <%= u.input :tel, label: "tel.:" %> <h3>education</h3> <hr> <%= u.simple_fields_for :educations |e| %> <%= e.input :name, label: "university" %> <%= e.input :year_started, label: "started" %>

javascript - How to submit a form using JS with Ruby on Rails -

i have rails project using refile gem process file uploading, , submit form after user has selected file in file browser. i created button in navbar of rails app, , have following form. _nav.html.erb <div class='upload-image'> <form name="form_upload_image"> <p>upload image <i class="fa fa-upload"></i></p> <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) |form| %> <%= form.attachment_field :tshirt_image, direct: true, class: "fa fa-upload", input_html: { hidden: true, onchange: "uploadimage()" } %> <%= form.submit "update", class: "btn btn-primary" %> <% end %> <!-- form --> </form> </div> i call uploadimage js function once user has selected open button within file browser. i created navbar_ima

c# - Can I use the keyword "in" to separate parameters in a method declaration somehow? -

i create method uses keyword in instead of comma separate parameters in method declaration; similar foreach(a in b) method. example class structure public class length { public double inches; public double feet; public double yards; public enum unit { inch, foot, yard } dictionary<unit, double> inchfactor = new dictionary<unit, double>() { { unit.inch, 1 }, { unit.foot, 12 }, { unit.yard, 36 } }; public length(double value, unit unit) { this.inches = value * inchfactor[unit]; this.feet = this.inches / inchfactor[unit.foot]; this.yards = this.inches / inchfactor[unit.yard]; } } method definition in class // i'd know how use "in" ↓ public list<length> multiplesof(length divisor in length dividend) { double inchenumeration = divisor.inches; list<length> multiples = new list<length>(); while (inchenumeration <= dividend.inch

java - Switching between codes in my program -

i have 3 programs calculating pi , want refactor one. can't working using if or switch command. case 3. public class programpi { public static void main(string[] args) { // todo auto-generated method stub int z = integer.parseint(joptionpane.showinputdialog("wybierz metode liczenia pi 1=leibnitz 2=wallis 3=montecarlo:"));{ switch(z){ case 1: double pi=0; double mianownik=1; double = integer.parseint(joptionpane.showinputdialog("obliczamy pi metoda leibnitza podaj n: ")); (int x = 0; x < i; x++){ // obliczanie ciagu if (x % 2 == 0) { pi = pi + (1 / mianownik); } else { pi=pi - (1 / mianownik); } mianownik = mianownik + 2; } pi = pi * 4; system.out.println("przy n= " + + " pi = "

javascript - Cannot read property 'parentNode' of null. Error i get in console -

var button1 = document.getelementbyid("start"); var button2 = document.getelementbyid("stop"); var timegraph = document.getelementbyid("ceas"); var lapbutton = document.getelementbyid("lap"); var lame = document.getelementbyid("test"); var time = 0; var resetstart = 0; var myinterval; var body = document.getelementbyid("body"); var action = document.getelementbyid("lappara"); function start() { if (resetstart == 0) { resetstart = 1; running(); button1.innerhtml = "pause"; } else { resetstart = 0; button1.innerhtml = "resume"; clearinterval(myinterval); } } function reset() { time = 0; resetstart = 0; button1.innerhtml = "start"; timegraph.innerhtml = "00:00:00:00"; clearinterval(myinterval); var aux = action.parentnode; aux.removechild(action); } function ongoing() { time++;

android - Get child menu from NavigationView -

in menu of navigationview in drawer have nested menu: <item android:title="view options"> <menu> <item android:id="@+id/nav_gallery" android:icon="@android:drawable/ic_menu_gallery" android:title="gallery" android:enabled="true" android:checked="true"/> <item android:id="@+id/nav_slideshow" android:icon="@android:drawable/ic_menu_slideshow" android:title="slideshow" android:enabled="true" android:checked="false"/> </menu> </item> i know how standard menu item in 1 of callback method drawerlayout: public void ondraweropened(view drawerview) { navigationview navigationview = (nav

Data scraping with Python and Beautiful Soup -

i making first steps python & beautiful soup in order scrape data russian statistics website. looking @ different examples here on stack overflow, think code correct, , yet simple query not return site. when executing code, python command line remains blank, not return error. what's wrong here? my (very simple) code: from bs4 import beautifulsoup import urllib2 url = "http://www.gks.ru/bgd/free/b00_25/isswww.exe/stg/d000/000715.htm" page = urllib2.urlopen(url) soup = beautifulsoup(page.read()) print(soup) you need specify parser: soup = beautifulsoup(page.read(), 'html.parser')

playframework - How can I use TestNG with Java Play 2.4.x? -

i use testng in java play project instead of junit testing (it has more robust features). however, there doesn't appear documentation on how since play seems treat java second class citizen compared scala. know how configure java play project use testng? add following dependencies build.sbt : librarydependencies ++= seq( ... "org.testng" % "testng" % "6.8.8", "de.johoop" % "sbt-testng-interface_2.10" % "3.0.0", "org.scalatest" %% "scalatest" % "2.2.1", "org.scalatestplus" %% "play" % "1.4.0-m4" ) add following dependencies plugins.sbt (in "project [root-build]"): addsbtplugin("de.johoop" % "sbt-testng-plugin" % "3.0.2") restructure "test" directory classes part of package structure. example: test --- com.test.integration ------ integrationtest.java --- com.test.unit ------ unittest

fortran - Loading only one subroutine from module -

i have module in coded bunch of subroutines use. however, not every time need of them. is possible load 1 (or two...) subroutine module? my interest in doing there 1 particular subroutine requires module work, if i'm not going use subroutine prefer avoid loading module. here example of have module mylibrary implicit none contains subroutine proc1 print *, 'this proc1' end subroutine proc1 subroutine proc2 use extramod print *, 'this proc2' end subroutine proc2 end module mylibrary i able load in main program proc1 only, wouldn't have load module extramod (actually don't want need file). in main program, tried option only seems work variables , not subroutines. here example of main file program main use mylibrary, : proc1 implicit none call proc1 end program main when compile this, error "error in opening compiled module file. check include paths. [extramod]". any thoughts? what want not

python - How to use 2 ForeignKey filters one by one in 1 view - Django? -

hello , thank your answer: my taks: show article, show 3 questions (related article), show 3 answer each queston (related these questions). coomon test page. my models: class step(models.model): #main article title = models.charfield(max_length=200) description = models.charfield(max_length=200) annotation = models.textfield() main_text = models.textfield() def __str__(self): return self.title class question(models.model): #questios related article. step = models.foreignkey(step, on_delete=models.cascade) title = models.charfield(max_length=200, default = "pages") question_text = models.textfield() question_name = models.charfield(max_length=40, help_text="английские буквы", blank=true, null=true) class answer(models.model): #answers related questions question = models.foreignkey(question, on_delete=models.cascade) choice_text = models.textfield() votes = models.integerfield(default=0) answ

actionscript 3 - Load the first 30 items in my TextField then loading the rest when click -

i'm making air app (as3) flash. i've got sprite that's loading items database table. function complete(e:event):void { addchild(list); products = json.parse(loader5.data) array; for(var i:int = 0; < products.length; i++){ createlistitem(i, products[i]); } showlist(); } function createlistitem(index:int, item:object):void { var listitem:textfield = new textfield(); var myformat:textformat = new textformat(); myformat.size = 25 listitem.defaulttextformat = myformat; listitem.text = item.title; listitem.y = 140+ index * 40; listitem.width = 100; listitem.addeventlistener(mouseevent.click, function(e:mouseevent):void { showdetails(item); }); list.addchild(listitem); } function showlist():void { list.visible = true; } i have more 200 items loaded. i'd load (or display) 30 first one, , click on button load/display 30 next..etc (like "pages"). any idea how can ?

java - Android String.format locale set explicitly to US but Persian numbers are used for Integer -

the title explains all. string method = string.format( "select studymap.id,studymap.title,studymap.zorder,studymap.hierarchy_id,studymap.book_id," + "studymap.abstract,studymap.type,studymap.free_view,studymap.localpath,studymap.flags," + "studymap.visit_status,downloads.status download_status,downloads.studymap_id,studymap.publish_status "+ "from studymap left join downloads on studymap.id = downloads.studymap_id" + " studymap.book_id = %d order studymap.zorder", book.id); book.id integers, still error on devices: android.database.sqlite.sqliteexception: no such column: ۵۴۵ (code 1): , while compiling: select studymap.id,studymap.title,studymap.zorder,studymap.hierarchy_id,studymap.book_id,studymap.abstract,studymap.type,studymap.free_view,studymap.localpath,studymap.flags,studymap.visit_status,downloads.status download_status,download

c - OpenGL window doesn't open in xcode (7.2) when run as a child process -

i on os x 10.10.5, , xcode 7.2. have program spawns child process run visualization using opengl/glut, i.e. pid_t childpid; childpid = fork(); if(childpid == 0) { // child process glutinit(&argc, argv); ... } else{ // parent process else ... } when run in xcode, program never returns glutinit. if instead use parent process visualization, , child run else, i.e. if(childpid != 0) { // parent process glutinit(&argc, argv); ... } ... then opengl window pops up, , whole program runs fine. additionally, if run original version (with child doing visualization) when building makefiles in terminal outside of xcode, runs fine. any ideas on cause this? i haven't been able debug things far within xcode, because debugger follows parent process. if try attach child process through debug->attach process, error: "xcode couldn't attach “j2”. “j2” not support debuggable architecture." found questions on last issue of attaching other processes

ruby on rails - Schema dump with pre-existing MySQL database results in NoMethodError -

i've been trying schema dump new rails project using existing mysql database. here's setup in database.yml file: default: &default adapter: mysql2 encoding: utf8 pool: 5 username: username_example password: password_example host: localhost socket: /tmp/mysql.sock development: <<: *default database: databasename i added following gems gemfile , bundled: gem 'mysql2' gem 'activerecord-mysql2-adapter' after using command rake db:schema:dump following error in schema file: activerecord::schema.define(version: 0) # not dump table "tablename" because of following nomethoderror # undefined method `type' "text":string end any ideas on how fix appreciated, thanks! i discovered mysql version messing dump. removed activerecord mysql adaptor changed gemfile , dump worked perfectly: gem 'mysql2', '~> 0.3.13'

php - How do I make this loop once, break then continue the loop? -

i looping div horizontally float:left , works way should problem each div has unique height influenced content contained within, result can messy looking when browser re sized. php loop once, break, start new row looks same no matter how browser sized. if it's not obvious, not php , struggled piece have. <?php $url = "xml.php"; $xml = simplexml_load_file($url); $namespaces = $xml->getnamespaces(true); // namespaces for($i = 0; $i < 10; $i++){ $poster = $xml->channel->item[$i]->children($namespaces['x'])->poster; $html .= "<div class='wrapper' style='float:left;'>$poster</div>";} echo $html; ?> if understand want information have here suggest: your loop fine. lets want same no mater size of page. exemple : want 5 div on each row. use css it. you have total of 10 div need 2 rows. add loop : if($i = 5){ $html .= "<div class='wrapper' style='float:left;

php - Select one value from same column with same id -

i want select product detail , display 1 image of product same column. ex : fm_product table | p_id | p_name | p_price | p_member_id | << (added product member) ----------------------------------------- | 1 | shirt | 600 | 44 | | 2 | pants | 700 | 44 | | 3 | shoes | 800 | 45 | | 4 | bag | 900 | 45 | fm_product_image table | img_id | p_id_img | img_name | ----------------------------------- | 1 | 1 | shirt_1.jpg | | 2 | 1 | shirt_2.jpg | | 3 | 1 | shirt_3.jpg | | 4 | 2 | pants_1.jpg | | 5 | 2 | pants_2.jpg | | 6 | 2 | pants_3.jpg | | 7 | 3 | shoes_1.jpg | | 8 | 3 | shoes_2.jpg | | 9 | 4 | bag_1.jpg | | 10 | 4 | bag_2.jpg | member ids 44 select added product out put should : | p_name | p_price | img_name | ---------------------------------- | shirt | 600 | shirt_1

c++ - Assert is wrong, proven with cout -

when run this, in main() cout prints 5.395. assert says failed!! mind boggling, why happening? #include <iostream> #include <cassert> using namespace std; const float = 1.6; const float c = 1.55; const float g = 2.2; const float t = 1.23; char empty[18]; int arraysize; void copyarray(char sourcearray[], char targetarray[], int size) { for(int i=0;i<size;i++) { targetarray[i] = sourcearray[i]; } } double getavgdensity(char aminoacid) { char aminoupper = toupper(aminoacid); aminotoarray(aminoupper); double counter = 0; int codontotal = arraysize / 3.0; if (arraysize == 0) return 0; else { (int = 0; < arraysize; i++) { counter += chartodouble(empty[i]); } return (counter / codontotal); } } int main() { cout << getavgdensity('a') << endl; // prints 5.395 assert(getavgdensity('a')==5.395); return 0; } edit: answers, multiplied 1000,

php - Ajax form only submitting sometimes -

there several questions on none of answers have worked me. have tried them all. i tried minimize code pasting, it's kind of hard script i have comment form submitted via ajax php script saves comment , gets comments , redisplays them new comment can displayed without refreshing page. only comments submit database , redisplay properly. usually every other submit comment saved. every other time nothing seems happen. my real issue comments not being saved every time 1 submitted. here javascript , ajax call: $(document).ready(function(){ var working = false; $('#commentform').submit(function(e){ if(working) return false; working = true; $('#submitcomment').val('working..'); $('span.error').remove(); $.post('/ajax/comment.process.php',$(this).serialize(),function(msg){ working = false; $('#submitcomment').val('submit'); if(ms

date - How to pass a variable to the mv command to rename a file text with spaces and the variable's text in a bash (.sh) file -

i create variable , store day, date & time in it: now=$(date "+%a %d/%m/%y% %h:%m") then pass $now mv command rename file. e.g. create file named a.txt title , current date: printf "file report (" > ~/desktop/a.txt echo $now"):\n" >> ~/desktop/a.txt then try rename file variable ($now) included in name: mv ~/desktop/a.txt ~/desktop/'file report $now'.txt what should last line be? tried these 2 options. mv ~/desktop/a.txt ~/desktop/'file report' $now.txt & mv ~/desktop/a.txt ~/desktop/'file report'${now}.txt assuming reasonably bourne-like shell (such bash), variable substitution not happen inside single quotes. need use double quotes: mv ~/desktop/a.txt "${home}/desktop/file report ${now}.txt" (i'm not sure whether curly braces required, can't hurt) you need change date command avoid use of slashes. example: now="$(date '+%a %d-%m-%y% %h:%m

java - Android Cursor NPE dumpCursorToString returns values -

as title says, i'm experiencing nullpointerexception occurs @ first getstring() in below method. debugging have used databaseutils.dumpcursortostring() view cursor , there values within cursor between if statement , do statement, changes. use same code in method in separate activity , works flawlessly. public arraylist<string> getmusic() { helper = new dbhelper(context); db = helper.getreadabledatabase(); string[] cols = new string[]{music_id, music_country, music_blues, music_rock, music_metal, music_hiphop, music_classical, music_punk, music_techno, music_jazz, music_other}; cursor c = db.query(table_music_int, cols, null, null, null, null, null); int count = c.getcount(); log.v("interest cursor ", "count: " + count); // log row count if (c.movetofirst()) { log.v("interest cursor ", databaseutils.dumpcursortostring(c)); // dump cursor values { musi

spring - Pivotal Cloud Foundry with Mongo DB -

we planning use mongo db application deployed in cloud foundry. came across link talks limitations of integration. cloud foundry not support mongo db managed service or not support mongo db if external connection parameters used? i have used cloudfoundry learning spring boot , cloud deployment, , deployed 2 spring boot apps 1 mongodb service provided cf , configured externally. in both case mongodb service provider mongolab (mongolab.com) cf provides mongodb via mongolab service can mongodbass mongolab.com , configure app use mongodb. the link posted refers "p-mongodb" service, doesn't exists anymore. ran cf marketplace , don't see p-mongodb available. guess pivotal removed old p-mongodb service new mongolab service. checkout link - https://console.run.pivotal.io/marketplace/mongolab . ps: here deployed app - http://blogaggregator.cfapps.io