George Opritescu

Developer from somewhere

react-native unable to download js bundle

Got this error message:

Unable to download JS bundle. Did you forget to start the development server or connect your device?

To fix, I had to run:

react-native start

and then click reload on the AVD.

Read More

fixing java.awt.HeadlessException when starting AVD under ubuntu linux

I kept receiving java.awt.HeadlessException when starting the AVD. I found the fix here

Basically:

sudo apt-get install openjdk-6-jre

Then open the android script from ANDROID_HOME, or wherever your android sdk is, and modify java_cmd=”java” to java_cmd=”/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java”

Read More

setting default node version in nvm

For example to make 5.3.0 the default node available:

nvm alias default v5.3.0
Read More

custom monitoring script in ubuntu

I wanted to have a way to run something repeteadly and have visual output. Luckily, indicator-sysmonitor allows you to configure a custom script. You can get a full description on how to do it, by following this link. I find it very useful to add the path to a shell script, and to call whatever you want from it. So, I’ve configured the path to be ~/code/sysmenu.sh, with the following contents:

#!/bin/bash
source ~/.rvm/scripts/rvm
cd /home/geo/code/sidekiq-queue
ruby extractor.rb

Of course, you could run node, python, c, or whatever your heart desires. Just make sure your script produces output, since that output is what’s displayed by your indicator. For example, I use it to keep track of the jobs that are being processed by sidekiq, how many jobs are running, how many are queued, and how many scheduled.

Read More

handling cookies with Mechanize

cookie_file = File.join(File.dirname(__FILE__), "cookies.yml")

w = Mechanize.new
if File.exists?(cookie_file)
  w.cookie_jar.load cookie_file
end

w.get("http://some_url")

# or whatever logic to verify whether you need to authenticate or not
if w.page.forms.count != 0
  form = w.page.forms.first

  email_field = form.field("admin_user[email]")
  pwd = form.field("admin_user[password]")

  email_field.value = "your_username@your_domain.com"
  pwd.value = "password"

  form.submit
end

w.cookie_jar.save(cookie_file, session: true)
Read More

git push all remote branches and tags to new remote

git push new_remote_name refs/remotes/origin/*:refs/heads/*
git push new_remote_name refs/tags/*:refs/tags/*
Read More
git

access the exception object of an rspec test

Add an after hook like this:

after(:each) do |ex|
  if ex.example.exception
    # do smth here
  end
end
Read More

virtualbox dns issues

Found that running this, solves my “virtualbox temporary failure in name resolution” errors.

VBoxManage modifyvm Linux --natdnshostresolver1 on
Read More

schedule a sidekiq worker to run in a few minutes

MyWorker.perform_in(5.minutes, worker_args)
Read More