Skip to content

Instantly share code, notes, and snippets.

View vaicine's full-sized avatar
🥞

James Harries vaicine

🥞
View GitHub Profile
dependencies:
pre:
- gem install bundler
@vaicine
vaicine / gist:11173681
Created April 22, 2014 10:42
Count CSS selectors (ruby)
class CSSCount
MAX_SELECTORS_DEFAULT = 4095
# returns the specified split of the passed css_string
def self.split_string(css_string, split = 1, max_selectors = MAX_SELECTORS_DEFAULT)
rules = split_string_into_rules(css_string)
extract_part rules, split, max_selectors
end
@vaicine
vaicine / gist:11172501
Created April 22, 2014 09:54
CSS selector count
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@vaicine
vaicine / devtools.md
Last active December 28, 2015 07:59 — forked from Demwunz/devtools.md

#Fazal's list of dev tools

##JavaScript ###Node frameworks

###Polyfills

@vaicine
vaicine / gist:5644393
Created May 24, 2013 15:37
Dirty little csv to html table parser in ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'csv'
require 'sinatra'
get '/' do
csv = CSV.read("test.csv")
html = "<table> \n"
row_count = csv.count
csv.each_with_index do |row, row_position|
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'uri'
TMP_DIR = "/tmp/gems"
@vaicine
vaicine / gist:5567141
Created May 13, 2013 09:21
Textfill that actually works
(function($) {
$.fn.textfill = function(maxFontSize) {
maxFontSize = parseInt(maxFontSize, 10);
return this.each(function(){
var ourText = $("a", this),
parent = ourText.parent(),
maxHeight = parent.height(),
maxWidth = parent.width(),
fontSize = parseInt(ourText.css("fontSize"), 10),
multiplier = maxWidth/ourText.width(),
@vaicine
vaicine / gist:5495474
Created May 1, 2013 14:13
Office zombie apocalypse roulette tag

The rules are simple:

  • At the start of the week, a number of people are emailed. For a company of about 50 people you could do 4.
  • Of the four people, 1 person is emailed to tell them they are infected (zombie). The other three people are emailed to tell them they are doctors.
  • The infected person must infect as many people as possible. To do so they tell a person they are infected - that's it. However, if someone overhears them, both people become immune and are out of the game.
  • Once you become infected, you can either do nothing, or infect more people. You should email HR with an email 'i'm infected' to let them know you're infected.
  • If an infected person tries to infect a doctor, the infected person is now immune and can't infect any more people. They must tell the doctor who infected them. This also goes for if the doctor overhears an infected trying to infect someone.
  • Once the doctor gets told of the infector, they must wait until the following day and then approach the infector and ask t

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse