Skip to content

Instantly share code, notes, and snippets.

@ddrscott
ddrscott / pry_psql.rb
Last active August 19, 2021 19:17
Pry command to execute SQL as text or Rails scopes
# Load this file in your `.pryrc`
#
# load 'path/to/pry_sql.rb'
#
# See how to use this by running: `psql --help`
# Originally created for Rails 3.
# Updated to Rails 6
module Rails
class DBConsole
APP_PATH = Rails.root.join('config', 'application')
#!/usr/bin/env zsh
# Copied from https://github.com/paulirish/dotfiles/commit/6743b907ff586c28cd36e08d1e1c634e2968893e
function strip_diff_leading_symbols(){
color_code_regex=$'(\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K])'
# simplify the unified patch diff header
sed -E "s/^($color_code_regex)diff --git .*$//g" | \
sed -E "s/^($color_code_regex)index .*$/\
\1$(rule)/g" | \
Option Explicit
On Error Resume Next
Dim strProcName ' 終了するプロセス名
Dim objProcList ' プロセス一覧
Dim objProcess ' プロセス情報
Dim lngKillNum ' 終了したプロセス数
strProcName = "explorer.exe"
lngKillNum = 0
@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
" == Naming convention. == {{{1
" Command name
" - CamelCase
" Global function name
" - CamelCase
" Local function name
" - s:split_by_underbar
" Group name for autocmd
" - split-by-dash
" In vimrc, start with "vimrc"
@stackng
stackng / rails content_for caching
Created March 29, 2011 06:30
make action and fragment caching of rails3 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?