Skip to content

Instantly share code, notes, and snippets.

View kazu69's full-sized avatar
:octocat:
⭐️ 🚀 🍻 🍶

kazu69 kazu69

:octocat:
⭐️ 🚀 🍻 🍶
View GitHub Profile
@ChristianPeters
ChristianPeters / css_splitter.rake
Created August 8, 2011 10:22
Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
require 'rake'
require 'css_splitter'
desc 'split css files'
namespace :css do
task :split do
infile = ENV['infile'] || raise("missing infile")
outdir = ENV['outdir'] || File.dirname(infile)
max_selectors = ENV['max_selectors'] || 4095
@avinasha
avinasha / css_transformer.rb
Created July 29, 2011 06:40
A Sanitize gem transformer which sanitizes any CSS in a HTML document.
check_css = lambda { |env|
node = env[:node]
node_name = env[:node_name]
# Don't continue if this node is already whitelisted or is not an element.
return if env[:is_whitelisted] || !node.element?
parent = node.parent
return unless node_name == 'style' || node['style']
if node_name == 'style'
unless good_css? node.content
node.unlink
@kazu69
kazu69 / exmaple.md
Last active August 7, 2016 05:42
rpmbuild custom package example

example

create rpm hello using rpmbuild.

docker build -t fedora -f ./fedora.dockerfile .
ocker run -it fedora /bin/bash
bash-4.3# hellow
bash: hellow: command not found
bash-4.3# hello
@nepsilon
nepsilon / one-line-browser-notepad.md
Created September 27, 2016 05:25
One-line browser notepad 📝 — First published in fullweb.io issue #67

One-line browser notepad 📝

Sometimes you just need to quickly take some notes.

A trick is to use the data: scheme with data:text/html to show just a piece of HTML in your browser. Then using the mighty contentEditable to make the whole thing editable.

To copy/paste into your browser address bar:

data:text/html,<html contenteditable>
# Our own variable where we deploy this app to
deploy_to = "/srv/example.com"
current_path = "#{deploy_to}/current"
shared_path = "#{deploy_to}/shared"
shared_bundler_gems_path = "#{shared_path}/bundler_gems"
# See http://unicorn.bogomips.org/Sandbox.html
# Helps ensure the correct unicorn_rails is used when upgrading with USR2
Unicorn::HttpServer::START_CTX[0] = "#{shared_bundler_gems_path}/bin/unicorn_rails"
@otaviomedeiros
otaviomedeiros / alias_matcher.rb
Created March 1, 2012 16:18
RSpec matcher for alias_method
# RSpec matcher for alias_method.
# https://gist.github.com/1950961
# Usage:
#
# describe User do
# it { should alias_from(:username).to(:email) }
# end
RSpec::Matchers.define :alias_from do |alias_method|
@anatoliychakkaev
anatoliychakkaev / demo.js
Created January 12, 2012 08:32
Require in runInNewContext
var Module = require('module');
var vm = require('vm');
var path = require('path');
var filename = process.cwd() + '/lib/eval.js';
var mod = new Module(filename);
var context = {
module: mod,
__filename: filename,
@jonathantneal
jonathantneal / css.js
Created July 31, 2012 16:02
css.js // parse, vendor-prefix, and render CSS; get vendor details
(function (global) {
function clean(css) {
return css
.replace(/\/\*[\W\w]*?\*\//g, "") // remove comments
.replace(/^\s+|\s+$/g, "") // remove trailing spaces
.replace(/\s*([:;{}])\s*/g, "$1") // remove trailing separator spaces
.replace(/\};+/g, "}") // remove unnecessary separators
.replace(/([^:;{}])}/g, "$1;}") // add trailing separators
}
@cjohansen
cjohansen / gist:739589
Created December 13, 2010 20:55
Showing how to fake server requests with Sinon.JS and Jasmine
/*
Load Sinon.JS in the SpecRunner:
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script>
<script type="text/javascript" src="sinon-1.0.0.js"></script>
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script>
http://cjohansen.no/sinon/
*/
@JackNova
JackNova / JavascriptMonads.js
Created December 19, 2012 18:28
Monads Implementation in javascript, as seen in crockford presentation at yui conf 2012
//BASIC PIECES, 3 functions: unit, bind and the bind argument
//function unit(value)
//function bind(monad, function(value))
//all three functions return a monad
/* The unit function is a constructor (returns a monad object)
* The magic is in the bind function
*
* There are AXIOMS:
* bind(unit(value)), f) === f(value)