Skip to content

Instantly share code, notes, and snippets.

View icholy's full-sized avatar
💥
breaking things

Ilia Choly icholy

💥
breaking things
View GitHub Profile
@icholy
icholy / htmlline.py
Created June 17, 2012 20:36
pygments html formatter with line wrapping
# -*- coding: utf-8 -*-
"""
pygments.formatters.htmlline
~~~~~~~~~~~~~~~~~~~~~~~~
Formatter for HTML output which wraps each line in a span.
"""
__all__ = ['HtmlLineFormatter']
@icholy
icholy / hashlines.js
Last active October 6, 2015 05:47
highlight lines specified in hash
$(window).bind('hashchange', function() {
var m = /\#L(\d+)(\-L(\d+))?/.match(window.location.hash),
n1 = parseInt(m[1]),
n2 = parseInt(m[3]),
i;
if (!isNaN(n1)) {
n2 = isNaN(n2) ? n1 : n2;
for (n1 = 0; i <= n2; i++) {
@icholy
icholy / collection.md
Created August 23, 2012 21:12
Javascript Collection idea

Example data

// example data
var data = [
  { uid: 1, foo: 435, bar: "435dsjkds6fd5" },
  { uid: 2, foo: 035, bar: "4adsf35asdf65" },
  { uid: 3, foo: 305, bar: "435ads6asdfd5" },
  { uid: 4, foo: 075, bar: "4fds35adsf6d5" },
  { uid: 5, foo: 165, bar: "43fd5f6dfadf5" },

];

@icholy
icholy / method-search.clj
Last active October 9, 2015 14:18
search an objects or classes methods
(defn search-method [obj search-str]
"take an object and a search string and return a list of
of methods on that object that match the search string"
(let [clazz (if (= (.getClass obj) java.lang.Class)
obj
(.getClass obj))
re (re-pattern (str "(?i)" search-str))]
(for [method (seq (.getMethods clazz))
:let [method-name (.getName method)]
:when (re-find re method-name)]
@icholy
icholy / why.md
Created September 7, 2012 18:50
Ember.js .get/.set OCD

Ember.js .get/.set OCD

I see a lot of people using the .get() and .set() methods to access ALL of their properties. It's become taboo to access something directly and this is slightly rediculous.

Example

App.set("ApplicationController", Em.Controller.extend({
  /* stuff */  
}));
@icholy
icholy / browse.sh
Created October 12, 2012 14:48
quickly link the current dir to /var/www and open the browser there.
#!/bin/bash
REG_USER=icholy
LINK_NAME=browse
LINK_PATH=/var/www/$LINK_NAME
BROWSER_CMD=chromium-browser
# make sure we're root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2;
@icholy
icholy / server.coffee
Created October 29, 2012 18:47
brunch server with proxy support
express = require 'express'
httpProxy = require 'http-proxy'
sysPath = require 'path'
startExpress = (port, base, path, callback) ->
server = express()
server.use (request, response, next) ->
response.header 'Cache-Control', 'no-cache'
next()
server.use base, express.static path
@icholy
icholy / .vimrc
Last active October 12, 2015 06:28
My vimrc
" Ilia's VIM
set shell=zsh
set nocompatible
" leader
let mapleader = "\<Space>"
nnoremap <Space> <Nop>
" Hide Toolbar
@icholy
icholy / cars.txt
Created November 25, 2012 00:34
cars
http://stcatharines.kijiji.ca/c-cars-vehicles-cars-trucks-2002-Volkswagen-Golf-Low-Km-One-Owner-W0QQAdIdZ434332996
http://stcatharines.kijiji.ca/c-cars-vehicles-cars-trucks-2002-Volkswagen-Golf-Low-Km-One-Owner-W0QQAdIdZ434332996
Date Listed 24-Nov-12
Price $3,200.00
Address Thorold, ON, Canada
For Sale By Owner
@icholy
icholy / log.hpp
Created November 26, 2012 01:56
logging abstraction
//
// main.cpp
// test
//
// Created by Ilia Choly on 12-11-20.
// Copyright (c) 2012 Ilia Choly. All rights reserved.
//
#include <iostream>
#include <functional>