Skip to content

Instantly share code, notes, and snippets.

@olivierlacan
olivierlacan / launch_sublime_from_terminal.markdown
Created Sep 5, 2011
Launch Sublime Text 2 from the Mac OS X Terminal
View launch_sublime_from_terminal.markdown

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active Mar 25, 2021
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/
View migrate_postgresql_database.md

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@olivierlacan
olivierlacan / gist:4062929
Last active Feb 10, 2021 — forked from Gregg/gist:968534
Code School Screencasting Framework
View gist:4062929

Screencasting Framework

The following document is a written account of the Code School screencasting framework. It should be used as a reference of the accompanying screencast on the topic.

Why you should care about screencasting?

You're probably aren't going to take the time to read this document if you're not interested, but there are a lot of nice side effects caused by learning how to create quality screencasts.

  1. Communicating more effectively - At Envy Labs we produce screencasts for our clients all the time. Whether it's demoing a new feature or for a presentation for an invester, they're often much more effective and pleasent than a phone call or screen sharing.
@olivierlacan
olivierlacan / git_log.md
Created Aug 2, 2012
My git log custom output aliases
View git_log.md
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
git config --global alias.mylog "log --pretty=format:'%h %s [%an]' --graph"

To check that they've been added correctly, first run git config --list. You should see something like this in the midst of all your other configuration:

alias.hist=log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
View gary_bernhardt_screencasting_parley.md

I'm planning on either writing this up in detail or maybe doing a screencast about screencasting, but I'll give a short version here.

On sound quality:

This matters a lot. In decreasing order of importance:

  1. Remove echo. You have to hear this to understand. Set up a mic in front of your mouth and record a sentence. Then, put a thick comforter over you and the mic and say it again at the same distance. Listen to
@olivierlacan
olivierlacan / An_example.markdown
Created Feb 18, 2012 — forked from renz45/An_example.markdown
Re-style Sublime Text 2 sidebar to a darker theme
View An_example.markdown

This re-styles your sublime text 2 sidebar to be darker, so it doesn't blind you when using a dark theme.

Dark sublime text 2 sidebar

Save the Default.sublime-theme file into packages/Theme - Default, make a backup of your original if you want to be able to go back easily.

View dd_wrt_startup_script_orange_livebox.sh
### Version 16 20181010
### https://lafibre.info/remplacer-livebox/tuto-remplacer-la-livebox-par-un-routeur-dd-wrt-internet-tv/
### Informations utilisateur
user=fti/abcdefg
pass=hijklmn
maclivebox=01:23:45:67:89:AB
verlivebox=3
serlivebox=ABCDE0123456789
@olivierlacan
olivierlacan / rendering_partials.md
Last active May 31, 2019
How to use shorthand syntax for rendering partials in Rails
View rendering_partials.md

Inside of Rails views, you can call partial views (any view file named with an underscore as the first character) like this:

render partial: "partial_name"

You can also pass local variables, which is fantastic to ensure that your views & partials don't try to access data you didn't specifically hand to them from the controller.

@tylerhunt showed me this week that it was possible to avoid using instance variables (which are copied from the Rails controller to the corresponding Rails views) altogether by passing local variables to the view.

@olivierlacan
olivierlacan / database.rake
Last active Apr 19, 2019
Database rake tasks that I use on Code School to ferret out huge tables with millions of rows and see how many indices they have and to see which tables have missing indices on associated tables (foreign keys). The latter was taken from this great post by Tom Ward: https://tomafro.net/2009/09/quickly-list-missing-foreign-key-indexes
View database.rake
namespace :database do
task fat_tables: :environment do
c = ActiveRecord::Base.connection
max_table_name_width = 0
tables = c.tables.sort_by do |t|
max_table_name_width = t.length if t.length > max_table_name_width
@olivierlacan
olivierlacan / p_value_from_z_score.md
Last active Oct 21, 2018
Determine P value from positive AND negative Z scores
View p_value_from_z_score.md

Obtain P value from positive and negative Z scores

My fiancée is working on her master's thesis and her professor recommended a website that gives her P values when she plugs in Z scores.

The website works fine (although it crashes for a while on incorrect input) but it provides no transparency as to the formula used to compute the P value.

More problematic, she had to input hundreds of numbers into it which took forever. I tried to find an Excel formula that could replicate the results of the website