Skip to content

Instantly share code, notes, and snippets.

@areina
areina / bm-rescue-vs-check-ips.rb
Last active August 29, 2015 13:56
Benchmark about rescue exceptions
require 'benchmark/ips'
Benchmark.ips do |bm|
path = "/tmp/unknown_file.unknown_ext"
bm.report("using rescue") do
begin
File.read(path)
rescue
"file doesn't exist"
$ battle --ask-sudo-pass --config-file=https://db.tt/aG2uyydU
## Downloading config from url ###################################################################################
Fatal Task: localhost => Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 530, in _executor
exec_rc = self._executor_internal(host, new_stdin)
File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 621, in _executor_internal
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args)
File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 878, in _executor_internal_inner
self.callbacks.on_failed(host, data, ignore_errors)
(defun t-pull-request()
(interactive)
(async-shell-command "hub pull-request")
(with-current-buffer "*Async Shell Command*"
(add-hook 'comint-output-filter-functions
'(lambda (txt)
(if (string-match-p "https" txt)
(browse-url txt)))
nil t)))
[~]$ curl http://foo:8086/db/bar/series\?u\=root\&p\=root\&q\=select%20sum\(value\)%20from%20service_31189720689_metric_79198034909.1m%20where%20time%20%3E%20%272010-09-01%2000%3A00%3A00.000%27%20AND%20time%20%3C%20%272010-09-30%2023%3A59%3A59.000%27
[{"name":"service_31189720689_metric_79198034909.1m","columns":["time","sum"],"points":[[0,1.020721e+06]]}]%
[~]$ curl http://foo:8086/db/bar/series\?u\=root\&p\=root\&q\=select%20value%20from%20service_31189720689_metric_79198034909.1m%20where%20time%20%3E%20%272010-09-01%2000%3A00%3A00.000%27%20AND%20time%20%3C%20%272010-09-30%2023%3A59%3A59.000%27
[{"name":"service_31189720689_metric_79198034909.1m","columns":["time","sequence_number","value"],"points":[[1283299200000,72026860001,1020721]]}]%
@areina
areina / org-protocol-elfeed.md
Last active August 29, 2015 14:12
Snippets for subscribe feeds with elfeed (emacs) from conkeror

In your emacs files:

(defun org-protocol-elfeed (data)
  (let ((url (org-protocol-sanitize-uri data)))
    (elfeed-add-feed url)
    (customize-save-variable 'elfeed-feeds elfeed-feeds)))

(add-to-list 'org-protocol-protocol-alist
             '("Subscribe to feed with elfeed."
@areina
areina / ubiquo_in_jruby
Created February 16, 2010 10:16
Install ubiquo with jruby
install jdk and jre
install jruby with rvm
rvm install jruby -v 1.4.0
use jruby
rvm jruby
install rails
gem install rails -v 2.3.2
install columnize (ruby-debug needs it)
gem install columnize
install ruby-debug
(defn foo-root [component]
(fn [data _owner]
(reify
om/IRender
(render [_]
(let [ctor (js/React.createFactory
(js/React.createClass
#js
{
:getDisplayName (fn [] "muiroot-context")
@areina
areina / unifyrepotips
Created February 8, 2012 10:55
Pasos que s'han fet per unificar els repos d'ubiquo.
* Unificar els repos (tret de http://stackoverflow.com/questions/277029/combining-multiple-git-repositories)
Here's a solution I gave here:
First do a complete backup of your phd directory: I don't want to be held responsible for your losing years of hard work! ;-)
$ cp -r phd phd-backup
Move the content of phd/code to phd/code/code, and fix the history so that it looks like it has always been there (this uses git's filter-branch command):
$ cd phd/code
@areina
areina / ubuntu-stumpwm
Created March 6, 2012 08:27
Ubuntu 11.10 Unity and Stumpwm
/usr/share/xsessions/gnome-stumpwm.desktop
[Desktop Entry]
Name=Stumpwm Unity
Comment=Tiling window manager
TryExec=/usr/bin/gnome-session
Exec=gnome-session --session=stumpwm
Type=XSession
installation in ubuntu 11.10
$ cd ~/sources
$ git clone https://github.com/djcb/mu.git
$ cd mu
$ sudo apt-get install libtool libgmime-2.4-dev libxapian-dev
$ autoreconf -i
$ configure
$ make
$ make install