Skip to content

Instantly share code, notes, and snippets.

View emirotin's full-sized avatar
🏠
Working from home

Eugene Mirotin emirotin

🏠
Working from home
View GitHub Profile
@emirotin
emirotin / directory_watcher.py
Created December 29, 2010 20:08
A class to perform polling directory watch and call a specific process, the script to watch directory for HAML files, and the script to support CoffeeScript inside of them
# The script to monitor directory changes and execute specific files on changed files
# Tasks are executed one by one, on keyboard interrupt the last task is waited to finish (not terminated)
# written by Eugene Mirotin, December 2010
# heavily based on http://www.bryceboe.com/2010/08/26/python-multiprocessing-and-keyboardinterrupt/
import sys
import os
import multiprocessing, Queue
from signal import signal, SIGINT, SIG_IGN
>>> class A(object):
... def __init__(self, x):
... self.x = x
...
>>> class B(A):
... def __init__(self, x):
... super(B, self).__init__(x)
... print x
...
>>> B.__name__ = A.__name__
@emirotin
emirotin / CDN support for connect-assets.md
Last active December 13, 2015 17:28
connect-assets helpers for CDN support

The idea:

  • allow precompilation which outputs a set of compiled cache-busted files and produces a mapping object { source_path => compiled name }
  • make this mapping available to the production code through the environment variable (good for Heroku)
  • still support on-the-fly compilation for the development machine

asset-compilers.coffee is a adapter module around connect-assets and the "mapping" JSON. Also adds 2 custom compilers - a thin Sass wrapper around the official gem and a Jade compiler for client-side templates

build_assets.coffee is a CLI script using the previous module to perform the compilation and outputs the mapping JSON to a file. It also directly copies all the assets that do not need compilation

config.coffee is an example how STATIC_HOST is made available for the application

@emirotin
emirotin / gist:5614067
Created May 20, 2013 18:09
save Ember model (ember-restless) and redirect to its route
saveAndRedirect = (redirectTo) ->
->
model = @get('model')
model.saveRecord()
done = =>
model = model.constructor.find model.id
model.on 'didLoad', =>
@transitionToRoute redirectTo, model
model.on 'didCreate', done
model.on 'didUpdate', done
{ Grammar } = require 'first-mate'
scopeName = "source.sbvr"
module.exports =
class LanguageSbvrGrammar extends Grammar
constructor: (registry) ->
name = "SBVR"
super(registry, { name, scopeName, fileTypes: [ 'sbvr' ] })
exports.getPlainOptions = ->
# a helper method can be provided by the repo to flatten the options list if the CLI needs it
@emirotin
emirotin / SassMeister-input.scss
Created March 9, 2016 11:16
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$unit: 1rem;
$phoneWindowWidth: 768;
.formFooter {
padding-top: 1 * $unit 0;
@emirotin
emirotin / SassMeister-input.scss
Last active March 9, 2016 11:21
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$unit: 1rem;
$phoneWindowWidth: 768;
$phoneMQ: "only screen and (max-width: #{$phoneWindowWidth * 1px})";
.formFooter {
################################################
# Dockerfile to build panyabot container images
# Based on raspbian
################################################
#Set the base image to raspbian
FROM resin/raspberrypi-systemd:wheezy
# File Author / Maintainer
MAINTAINER Wachira Ndaiga
function logText(text) {
const elPre = document.createElement('PRE')
const elCode = document.createElement('CODE')
elPre.innerHTML = text
elCode.appendChild(elPre)
document.body.appendChild(elCode)
}
var text = "\
page 1\n\