Skip to content

Instantly share code, notes, and snippets.

View bullfight's full-sized avatar
🚀

Patrick Schmitz bullfight

🚀
View GitHub Profile
@kachayev
kachayev / channels.erl
Last active December 15, 2017 19:36
Process communication programming
-module(channels).
-compile(export_all).
make() ->
Ref = make_ref(),
Pid = spawn(?MODULE, channel, [Ref]),
{channel, Pid, Ref}.
channel(Ref) ->
receive
attachments: parent_id, asset_id
domain_names: organisation_id
event_memberships: user_id, event_id
events: editor_id
group_actions: user_id, group_id
groups: user_id
icons: parent_id
invitations: sender_id
legacy_actions: item_upon_id
news_items: author_id
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@jrochkind
jrochkind / Explanation.md
Created October 15, 2012 17:19
Truncating html with nokogiri, with/without Rails

Rails has a handy truncate helper (which is actually mostly a method added to String ), but it warns you it's not safe to use on html source, it'll cut off end tags and such.

What if you want an HTML safe one? There are a variety of suggested solutions you can google, none of which were quite robust/powerful enough for me.

So I started with my favorite, by Andrea Singh, using nokogiri.

But:

  • I modified it to not monkey-patch Nokogiri, but be a static method instead (sadly making already confusing code yet more confusing, but I didn't want to monkey patch nokogiri)
@freeformz
freeformz / README.md
Created August 16, 2012 23:49
Using Heroku's Postgres's Fork feature to make/update staging dbs

This script assumes the following:

  1. Your app is named 'something' and that your staging app is named 'something-staging'. This seems to be a common thing.
  2. You only have a single staging HEROKU_POSTGRESQL databae.

Totally untested. 😏

What does it do?

  1. Grabs the current db name
@edhedges
edhedges / gist:2995805
Created June 26, 2012 13:30
Sublime Text 2 - Useful Shortcuts (Mac OS X)

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@guyboltonking
guyboltonking / compressed_static_assets.rb
Created March 21, 2012 20:37
Slightly hacky rails middleware for serving up precompiled gzipped assets
require 'action_dispatch/middleware/static'
module Middleware
class FileHandler < ActionDispatch::FileHandler
def initialize(root, assets_path, cache_control)
@assets_path = assets_path.chomp('/') + '/'
super(root, cache_control)
end
def match?(path)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@chetan
chetan / yardoc_cheatsheet.md
Last active May 4, 2024 11:12
YARD cheatsheet