Skip to content

Instantly share code, notes, and snippets.

@codeforkjeff
codeforkjeff / solarize.sh
Created November 27, 2011 06:43
shell script for setting gnome-terminal color palette to use Solarized theme
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
// run this in the javascript console, hit play on the vimeo video.
// when it's finished playing, the entire transcript should be in the "transcript" variable
var transcript = "";
var lastCaption = "";
function appendCaption() {
var cap = $(".vp-captions").text();
if(cap != lastCaption) {
transcript += " " + lastCaption;
@codeforkjeff
codeforkjeff / glob_test.sh
Created October 3, 2014 02:36
demo of "set -f" in bash
#!/bin/bash
# run this in a dir with some .zip files
# note that we do NOT escape glob patterns here
opts="-iname *.zip"
# normally, bash will expand *.zip and find will complain about arguments
echo "find will complain:"
find $opts
echo "========================================"
// https://www.codewars.com/kata/complete-the-pattern-number-13/python
object Pattern {
def spaces(size: Int) = Seq.fill(size)(" ").mkString
// line is 0-indexed
def pattern(n: Int, xArg: Int = 1, line: Int = 0, acc: Seq[String] = Seq[String]()): String = {
val x = if(xArg <= 1) 1 else xArg
if(line < n) {
val numToPrint = (line + 1) % 10
# illustrates interesting effects of #extend
module Mixin
def testo
"in mixin"
end
end
@codeforkjeff
codeforkjeff / ipfs-api-encoding.py
Created January 25, 2016 22:40
possible encoding problem with ipfs-api
# run this with LC_ALL and LANG env vars set to "en_US.utf8"
import ipfsApi
utf8_filename = u"clich\xe9.txt".encode('utf8')
with open(utf8_filename, "w") as f:
f.write("this is just a test")
c = ipfsApi.Client('127.0.0.1', 5001)
@codeforkjeff
codeforkjeff / gist:6373518
Last active December 21, 2015 22:09
twentytwelve-jeff child theme: style.css
/*
Theme Name: Twenty Twelve Child
Theme URI: http://codefork.com/
Description: Jeff's Tweaked Twenty Twelve
Author: Jeff
Author URI: http://codefork.com/
Template: twentytwelve
Version: 0.1.0
@codeforkjeff
codeforkjeff / gist:6373527
Last active December 21, 2015 22:09
twentytwelve-jeff child theme: functions.php
<?php
function twentytwelve_jeff_body_class( $classes ) {
if(isset($_SERVER['HTTP_USER_AGENT'])) {
if(strpos($_SERVER['HTTP_USER_AGENT'], "Chrome") !== false) {
$classes = array_diff($classes, array('custom-font-enabled'));
}
}
return $classes;
}
(defun my-replace (regex rep str &optional start)
(save-match-data
(let ((found-pos (string-match regex str (or start 0))))
(if found-pos
(let* ((match (substring str found-pos (match-end 0)))
(replacement (if (stringp rep)
rep
(or (funcall rep match) ""))))
(my-replace regex
rep
(defun my-replace (regex rep str &optional start)
"Replace matches of regex in str with the result of applying
rep function to the match.
This exists because of a quirk in replace-regexp-in-string:
because it calls the REP function in a while loop that uses
string-match and replace-match, the REP function can't use
string-match without messing up the match state in the loop.
If rep returns nil, an empty string is used as the