Skip to content

Instantly share code, notes, and snippets.

View glebm's full-sized avatar

Gleb Mazovetskiy glebm

View GitHub Profile
diff --git a/src/extender.cpp b/src/extender.cpp
index 6d96b8d0..8456a6a1 100644
--- a/src/extender.cpp
+++ b/src/extender.cpp
@@ -287,11 +287,11 @@ namespace Sass {
// Note: this function could need some logic cleanup
// ##########################################################################
void Extender::addExtension(
- SelectorListObj& extender,
- SimpleSelectorObj& target,
# A module which is an instance of the Script class encapsulates in its scope
# the top-level methods, top-level constants, and instance variables defined in
# a ruby script file (and its subfiles) loaded by a ruby program. This allows
# use of script files to define objects that can be loaded into a program in
# much the same way that objects can be loaded from YAML or Marshal files.
#
# See intro.txt[link:files/intro_txt.html] for an overview.
class Script < Module
# The file with which the Script was instantiated.
@glebm
glebm / bootstrap_user.rb
Created April 18, 2011 21:21
Capistrano recipe to create a user on EC2
set :aws_private_key_path, "~/.ec2/mrkey.pem"
namespace :setup_server do
desc "adds a user and uploads his id_rsa.pub to the EC2 instance's deploy users authorized_keys2 file"
task :create_deploy_user do
# \\n becomes \n
commands = <<-SH.split("\n").map(&:strip).join(";")
sudo echo hi
sudo groupadd admin
@glebm
glebm / setup_load_paths.rb
Created January 25, 2012 16:06
Sets up load paths for RVM to be used with Passenger
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
@glebm
glebm / unicorn
Created August 3, 2012 00:21
Unicorn /etc/init.d script for use with bundler
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
# Updated by glebm for newer unicorn and to use with bundle exec
#
## A sample /etc/unicorn/my_app.conf
@glebm
glebm / url_subdomain.rb
Created November 6, 2012 13:58
Get subdomains working in tests (scary)
# -*- encoding : utf-8 -*-
module UrlSubdomain
def subdomain!(sub = 'account')
# Some day this hack won't be necessary
# (when Capybara, Rspec, and Rails learn to work together)
# For now it only works if we run it twice
# I do not know why, and it would be a waste of time to find out
2.times do
sub = 'account' if sub.blank?
host = "#{sub}.#{DOMAIN}"
#!/usr/bin/env ruby
# coding: utf-8
require 'net/http'
require 'json'
# a simple wrapper to do an HTTPS GET
def fetch_uri(url)
STDERR.puts "GET #{url}" if ENV['VERBOSE']
uri = URI(url)
#!/usr/bin/env ruby
require 'base64'
require 'open-uri'
# file or url
def get_css(src)
if src.start_with? 'http'
src = src.gsub('|', '%7C')
STDERR.puts "# GET #{src}"
# simulate modern browser to get woff
@glebm
glebm / README.md
Last active October 12, 2018 15:36
Universal Rails async onPageLoad script (Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks)

This lets you load application JavaScript asynchronously from <head>. Compatible with Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks. Compatible with all browsers and IE9+ (only IE10+ will actually benefit from this though).

How to use this:

  1. Add the HTML snippet just before the closing </body> tag.

  2. Add the on_page_load.js script to the beginning of your application.js, and use window.App.onPageLoad(...) instead of document.addEventListener('DOMContentLoaded', ...) and jQuery(($) -> ...) everywhere.

  3. Include your JavaScript like so:

    <head>
@glebm
glebm / generate.js
Last active October 24, 2017 18:57
A quick hack to generate a codepoint set presence condition (JS)
const regenerate = require('regenerate');
/* char-graphic? */
const SETS = ['Letter', 'Mark', 'Number', 'Punctuation', 'Symbol'].map(category =>
require(`unicode-10.0.0/General_Category/${category}/code-points.js`));
/* char-blank? */
// const SETS = [['\t']].concat(['Space_Separator'].map(category =>
// require(`unicode-10.0.0/General_Category/${category}/code-points.js`)));