Skip to content

Instantly share code, notes, and snippets.

View julik's full-sized avatar
💭
🎺

Julik Tarkhanov julik

💭
🎺
View GitHub Profile
@julik
julik / inspect_headers.rb
Created December 24, 2013 22:16
Inspect Rack headers going through a middleware step
# Somehow Firefox 3 on Flame Oldest Linux In The Universe
# gets the .tgz files double-cooked compressed. This MW is
# intrduced to verify why that happens
class HeaderSniffer
def initialize(app, path_regexp = /\.tgz/)
@path_regexp = path_regexp
@app = app
end
def call(env)
curl http://logik-matchbook.org/MatchboxShaderCollection.tgz | tar xfz -; cp -r shaders /wherever-you-want/
curl http://logik-matchbook.org/MatchboxShaderCollection.tgz | tar xfz - && ./INSTALL.command
@julik
julik / digest.rb
Created December 9, 2013 11:08
digest a file with Ruby via OpenSSL
require 'openssl'
def digest_file(file_path, digest_class)
chunk_size = 1024 * 1024 # a meg
d = digest_class.new
File.open(file_path, 'r') do | f |
while chunk = f.read(chunk_size) do
d << chunk
end
end

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@julik
julik / parser.py
Created November 26, 2013 10:39
Yo dawg, I heard you like Nuke so I wrote this so that you can parse your Nuke TCL while you tickle yo' Python. Ya dig?
TERMINATORS = ["\n", ";"]
ESC = "\\"
QUOTES = ['"', "'"]
class c:
"""
Will be at the start of a list representing an expression
in curly braces. Every c() is equal to any other c()
"""
@julik
julik / artboards_to_svg.jsx
Last active December 27, 2015 07:39
Export every Illustrator artboard to SVG without resaving your file under different names and showing you any dialogs
var exportToDir = "/Users/julik/Code/apps/mvp/public/icons/";
/* Crop every icon in your Illustrator file witha named artboard. This script will export them all */
var docRef = app.activeDocument;
docRef.save();
// Get the source path
var originalPath = app.activeDocument.fullName.toString();
// Allocate a copy of the current document that we will throw away. We do this
uniform sampler2D input1;
uniform float adsk_input1_w, adsk_result_w;
void main()
{
// this should output the width of the input1 into the G channel of the shader,
// but it's value is always zero. And it wasn't. The test_shader stipulates that
// adsk_{sampler_name}_w / adsk_{sampler_name}_h : when declared as a float
// uniform, this gives access to each texture's resolution
// but it's broken now
@julik
julik / copier.js
Created August 19, 2013 10:18
Copypaste implementation
// Detect Control/Shift/Alt key status
var CTRL = false;
var SHIFT = false;
var ALT = false;
var CHAR_CODE = -1;
var menuItemDiv = null;
var curMouseX, curMouseY;
@julik
julik / holdit.py
Created July 26, 2013 15:34
Break out of the ReadGeo range with first/last frame holds
readgeo = nuke.selectedNode()
# register the first frame of the selected readgeo
hold_first = int(readgeo["range_first"].value())
# and the last frame
hold_last = int(readgeo["range_last"].value())
# generate the holds
hold_before = nuke.nodes.FrameHold(first_frame = hold_first)
hold_before.setInput(0, readgeo)