A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
For Mac users, I highly recommend iTerm 2 + Solarized Dark
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Monokai</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
# The worst possible way to memoize something. | |
class X | |
def value | |
@value = really_expensive_operation | |
def value; @value end | |
@value | |
end | |
end |
Tested on: Rails 3.1 | |
If have error: | |
ActionDispatch::Session::SessionRestoreError (Session contains objects whose class definition isn't available. | |
Remember to require the classes for all objects kept in the session. | |
can fix by changing a char in secret token in initializers/secret_token.rb | |
MyApp::Application.config.secret_token |
require 'mail' | |
class EmailValidator < ActiveModel::EachValidator | |
attr_reader :record, :attribute, :value, :email, :tree | |
def validate_each(record, attribute, value) | |
@record, @attribute, @value = record, attribute, value | |
@email = Mail::Address.new(value) | |
@tree = email.__send__(:tree) |
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
$ git branch -r --merged | | |
grep origin | | |
grep -v '>' | | |
grep -v master | | |
xargs -L1 | | |
awk '{split($0,a,"/"); print a[2]}' | | |
xargs git push origin --delete |
08:58 Defi_: can anyone tell me if there are any obvious disadvantages to patching a blocking library to use fibers at the socket level? | |
08:58 Defi_: its far too much effort to have to rewrite large chunks of every library just to make it async and fiber-aware | |
08:59 raggi: if it uses non-stack stored state you could end up with concurrency issues (read: race conditions) | |
08:59 raggi: fibers as implemented in MRI have limited size stacks (4kb) | |
09:00 Defi_: hmm alright :/ | |
09:01 raggi: if the library is trying to be thread safe, it can make a real mess too | |
09:01 raggi: Defi_: just use threads. | |
09:02 Defi_: raggi: not gonna happen... | |
09:02 Defi_: even if this was a personal project, i wouldnt use threads | |
09:03 Defi_: guess ill just have to continue rewriting parts of a bunch of libs as i go |