Skip to content

Instantly share code, notes, and snippets.

View spacemacs-cheshe.md

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@voldy
voldy / latency.markdown
Created Oct 9, 2016 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

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
@voldy
voldy / setup-bridge.sh
Created Jun 13, 2016 — forked from ismell/setup-bridge.sh
Scripts to re-create the docker0 bridge and setup a different ip subnet
View setup-bridge.sh
#!/bin/bash -e
IFADDR="192.168.3.1/24"
if [[ ! ip link show docker0 ]]; then
ip link add docker0 type bridge
ip addr add "$IFADDR" dev docker0
ip link set docker0 up
iptables -t nat -A POSTROUTING -s "$IFADDR" ! -d "$IFADDR" -j MASQUERADE
fi
View android links
View init.el
(global-set-key (kbd "C-c p f") 'projectile-find-file)
(global-set-key (kbd "C-c p F") 'projectile-find-file-other-window)
(global-set-key (kbd "C-c p d") 'projectile-find-dir)
(global-set-key (kbd "C-c p D") 'projectile-find-dir-other-window)
(global-set-key (kbd "C-c C-c d") 'projectile-dired)
(global-set-key (kbd "C-c p b") 'projectile-switch-to-buffer)
(global-set-key (kbd "C-c p a") 'projectile-ag)
(global-set-key (kbd "C-c p i") 'projectile-invalidate-cache)
(global-set-key (kbd "C-c p k") 'projectile-kill-buffers)
(global-set-key (kbd "C-c p p") 'projectile-switch-project)
View robot_user_agents.rb
require 'net/http'
require 'xmlsimple'
url = "http://www.user-agents.org/allagents.xml"
xml_data = Net::HTTP.get_response(URI.parse(url)).body
data = XmlSimple.xml_in(xml_data)
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
agent_names = agents.collect {|agent| agent["String"].first}
View project-web-reload.conf
# /etc/init/project-web-reload.conf
pre-start script
initctl restart project-web
sleep 15
end script
exec /usr/local/rvm/bin/default_bluepill restart
@voldy
voldy / gist:3699664
Created Sep 11, 2012
Ruby on Rails best practices
View gist:3699664

Ruby on Rails best practices

Code style

  • Use UTF-8. It’s 21 century, 8bit encodings dead now.
  • Use 2 space indent, not tabs
  • Use Unix-style line endings
  • Keep lines not longer than 80 chars
  • Remove trailing whitespace
@voldy
voldy / html5.haml
Created Aug 3, 2012 — forked from fnhipster/html5.haml
HTML5 HAML Template
View html5.haml
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
@voldy
voldy / gist:1808418
Created Feb 12, 2012
Capistrano Mongoid recipes
View gist:1808418
# Use the config/mongoid/#{rails_env}.yml file for mongoid config
namespace :mongoid do
desc "Copy mongoid config"
task :copy do
upload "config/mongoid/#{rails_env}.yml", "#{shared_path}/mongoid.yml", :via => :scp
end
desc "Link the mongoid config in the release_path"
task :symlink do