This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add the following in .zshrc: | |
... | |
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl) | |
... | |
### Fix slowness of pastes with zsh-syntax-highlighting.zsh | |
pasteinit() { | |
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} | |
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use ImageMagick convert | |
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf | |
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 1) Install Xcode 11 | |
# 2) Install command line tools: `xcode-select --install` | |
# 3) Install HomeBrew | |
# 4) brew tap cartr/qt4 && brew install cartr/qt4/[email protected] subversion rbenv | |
# 5) Setup rbenv | |
# 6) Run this command | |
PKG_CONFIG_PATH="$(brew --prefix cartr/qt4/[email protected])/lib/pkgconfig" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
# Add the following to your shell init to set up gpg-agent automatically for every shell | |
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
source ~/.gnupg/.gpg-agent-info | |
export GPG_AGENT_INFO | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countPieces() { | |
it = b.pieces(); | |
var i = 0; | |
while (it.current()){ i++; it.next() } | |
return i; | |
} | |
function getRandPiece() { | |
var it = b.pieces(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
# Maps logical Rails types to MySQL-specific data types. | |
def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
return super unless type.to_s == 'integer' | |
case limit | |
when 1; 'tinyint' | |
when 2; 'smallint' | |
when 3; 'mediumint' | |
when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder | |
use strict; | |
use warnings; | |
use URI::Escape qw(uri_escape_utf8); | |
use open IO => ":utf8", # UTF8 by default | |
":std"; # Apply to STDIN/STDOUT/STDERR |
This is how I debug SystemStackError when there is no stack trace.
My first attempt was:
begin
a_method_that_causes_infinite_recursion_in_a_not_obvious_way
rescue SystemStackError
puts caller
end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Weighted Moving Average (WMA) | |
# http://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average | |
# | |
# Given a hash, calculates the weighted moving averages of its values within | |
# a window size given. Modifies the original hash values. | |
# | |
# @param hash [Hash] the hash for whom values calculate the weighted moving | |
# averages. | |
# @param maws [Fixnum] the Moving Average Window Size. The greatest this | |
# number is the smoothest the calculated averages will be. |
NewerOlder