Skip to content

Instantly share code, notes, and snippets.

View jasoncodes's full-sized avatar

Jason Weathered jasoncodes

View GitHub Profile
@mislav
mislav / _readme.md
Last active July 21, 2026 01:40
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:

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 25, 2026 13:41
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

#!/usr/bin/env bash
#
# Wraps curl with a custom-drawn progress bar. Use it just like curl:
#
# $ curl-progress -O http://example.com/file.tar.gz
# $ curl-progress http://example.com/file.tar.gz > file.tar.gz
#
# All arguments to the program are passed directly to curl. Define your
# custom progress bar in the `print_progress` function.
#

Researchers investigating the Rails parameter parsing vulnerability discovered that the same or similar vulnerable code had made its way into multiple other libraries. If your application uses these libraries to process untrusted data, it may still be vulnerable even if you have upgraded Rails. Check your Gemfile and Gemfile.lock for vulnerable versions of the following libraries.

Directly vulnerable libraries

rails

Vulnerable: <= 3.2.10, <= 3.1.9, <= 3.0.18, <= 2.3.14

Fixed: 3.2.11, 3.1.10, 3.0.19, 2.3.15

multi_xml

psql_output = `psql postgres -t -c 'SELECT replication_status()'`.strip
connected_at, master_pos, standby_pos, lag = psql_output.scan(/^\("(.*)",(.*),(.*),(.*)\)$/).flatten(1)
Capybara.add_selector :record do
xpath { |record| XPath.css("#" + ActionController::RecordIdentifier.dom_id(record)) }
match { |record| record.is_a?(ActiveRecord::Base) }
end
@ryanlecompte
ryanlecompte / sorted_array.rb
Created October 3, 2012 18:30
SortedArray backed by a binary search for insertion/query
require 'delegate'
# SortedArray is backed by a binary search when inserting elements
# via #<< as well as querying for an element with #include?
#
# Example:
# a = SortedArray.new
# 10.times { a << rand(100) }
# puts a # => [3, 24, 30, 40, 42, 43, 49, 67, 81, 88]
# a.include?(49) # => true
@pda
pda / query_spy.rb
Created September 3, 2012 04:05
QuerySpy for counting ActiveRecord queries, asserting against n+1 regressions.
# An SQL query spy derived from the perhaps deprecated SQLCounter
# in ActiveRecord::TestCase and/or activerecord/test/cases/helper.rb
class QuerySpy
# Returns the number of queries executed by yielding the given block.
# Examples:
#
# QuerySpy.count { get "/things" }.should == 1
#
# create_a_thing
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ChristianPeters
ChristianPeters / config-application.rb
Created April 16, 2012 12:29
Adapted for Rails Asset Pipeline: Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
#...
module MyProject
class Application < Rails::Application
config.assets.precompile += %w( ie6.css ie6_portion2.css ie7.css ie7_portion2.css ie8.css ie8_portion2.css ie9.css ie9_portion2.css)
#...