Skip to content

Instantly share code, notes, and snippets.

/*
Adapted from https://github.com/sindresorhus/github-markdown-css
The MIT License (MIT)
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@ivalkeen
ivalkeen / application.rb
Last active April 24, 2016 18:21
Blog gists
# Use memory store for assets cache in development/test to avoid caching
# to tmp/assets, because it causes hiding of deprecation messages in
# stylesheets, sometimes break parallel_tests and doesn't always refresh
# gem stylesheets in development
config.assets.configure do |env|
if Rails.env.development? || Rails.env.test?
env.cache = ActiveSupport::Cache.lookup_store(:memory_store)
end
end
@ivalkeen
ivalkeen / summ.js
Last active August 31, 2015 13:53
Trello sum
javascript:$('.list').each(function(i, col) {
var ests = $($(col).find('.list-card-title').text().match(/\[([\dF-]+)+\]/ig)).map(function(_, estStr) {
console.log("Found string: ", estStr);
var result = estStr.replace(/[\[\]]/g, '');
if (result.length == 4) {
result = result.split('').reduce(function(sum, current) {
var currentValue = parseInt(current.replace('-', '0').replace(/f/i, '16'));
return currentValue + sum;
}, 0);
@ivalkeen
ivalkeen / prepare-commit-msg
Last active August 29, 2015 14:22
Git hooks
#! /bin/zsh
# if git branch name contains number, add leading [#NNN] to the commit message
# so github will add reference to specific issue
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NUMBER=$(git symbolic-ref --short HEAD | sed "s/[^0-9]//g")
COMMIT_TEXT=$(cat $1)
if [ -n "$BRANCH_NUMBER" ] && ! [[ $COMMIT_TEXT =~ "\[.*#$BRANCH_NUMBER\]" ]]; then
@ivalkeen
ivalkeen / example.rb
Created May 19, 2015 21:05
Testing tradeoff (black-box vs implementation or refactoring vs domain logic change)
require 'minitest/autorun'
class Doctor
def initialize(last_name)
@last_name = last_name
end
def display_name
"Dr. #{@last_name}"
end
@ivalkeen
ivalkeen / attached_asset.rb
Created May 25, 2012 19:34
Blog: Multiple files upload with paperclip
class AttachedAsset < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
has_attached_file :asset, :styles => { :large => "800x800", :medium => "400x400>", :small => "200x200>" }
attr_accessible :asset, :asset_file_name
end
@ivalkeen
ivalkeen / pdf2djvu for reader
Created November 22, 2011 06:08
Shell: Convert colorful PDF to black-text DJVU to increase readability on monochrome readers
# cut page 23 from pdf
pdftk smashing_css.pdf cat 23 output sheet.pdf
# crop margins
pdfcrop --margins '-50 -100 -100 30' sheet.pdf sheet1.pdf
# convert to monochrome (text) djvu
pdf2djvu -o file.djvu --fg-colors=black --anti-alias --dpi=600 file.pdf