Skip to content

Instantly share code, notes, and snippets.

@berfarah
berfarah / mac-firefox-profiles.md
Last active August 29, 2015 14:04
Getting Multiple Profiles to work on Mac

Run multiple Firefox profiles as separate Applications on Mac

Creating a new Firefox profile

Open terminal and execute the following to set up a profile:

/Applications/Firefox.app/Contents/MacOS/firefox-bin --ProfileManager

Using Automator to run the new Firefox profile as an application
@berfarah
berfarah / Default (OSX).sublime-keymap
Created July 18, 2014 23:54
Sublime Text: Copy paste entire line without \n
{ "keys": ["super+shift+c"], "command": "run_macro_file", "args": {"file": "Packages/User/macros/copy_line_without_newline.sublime-macro"} }
@berfarah
berfarah / no-gutter.css
Created July 22, 2014 04:00
Bootstrap – Class for gutter-less grid
.no-gutter.row,
.no-gutter.container,
.no-gutter.container-fluid{
margin-left: 0;
margin-right: 0;
}
.no-gutter>[class^="col-"]{
padding-left: 0;
padding-right: 0;
@berfarah
berfarah / uri.js
Created November 19, 2015 18:41 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@berfarah
berfarah / after.rb
Created November 27, 2015 14:21 — forked from mperham/after.rb
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@berfarah
berfarah / sqlgen_example.go
Created October 1, 2018 21:08
Iterative Optimization on Hot Paths
type User struct {
ID int64 `sql:",primary"`
Name string
}
@berfarah
berfarah / users.sql
Created October 1, 2018 21:12
Iterative Optimization on Hot Paths: What is sqlgen?
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255)
);
@berfarah
berfarah / user.go
Created October 1, 2018 21:13
Iterative Optimization on Hot Paths: What is sqlgen?
type User struct {
ID int64 `sql:",primary"`
Name string
}
@berfarah
berfarah / users.sql
Created October 1, 2018 21:17
Iterative Optimization on Hot Paths: Storing JSON in the database
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
configuration JSON
);
@berfarah
berfarah / users.go
Created October 1, 2018 21:17
Iterative Optimization on Hot Paths: Storing JSON in the database
type User struct {
ID int64 `sql:",primary"`
Name string
// The go struct representation of our data.
Configuration Configuration `sql:"-"`
// The JSON blob to be stored in and fetched from the database.
ConfigurationBlob []byte `graphql:"-" sql:"configuration"`
}