Skip to content

Instantly share code, notes, and snippets.

@Kalyse
Kalyse / compile.js
Created March 12, 2012 14:26
Node Less Compiler
var fs = require('fs'), // file system access
path = require('path'),
less = require('less'); // less processor
var options = {
compress: true,
optimization: 1,
silent: false
};
@Kalyse
Kalyse / dimensions.php
Created March 22, 2012 12:25
Get the Image Dimensions Without Loading the Entire Image
function rangeCurl($url) {
$headers = array(
"Range: bytes=0-32768"
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($curl);
curl_close($curl);
}
# This module intentionally minimizes dependencies to mitigate breakage risk.
# Subset of Syslog's numerical severity codes (RFC 3164, Table 2)
SEVERITY =
ERROR: 3
WARN: 4
INFO: 6
DEBUG: 7
# Configuration
@Kalyse
Kalyse / arrowgasm.less
Created May 9, 2012 13:55
LessCSS Mixing for Providing Arrows
.arrowgasm(@position: top, @size : "4px", @background-color : #88b7d5, @border-width: "2px", @border-color : #c2e1f5, @arrowClass : "arrow_box"){
(~".@{arrowClass}") {
position: relative;
background: @background-color;
border: @size solid @border-color;
}
(~".@{arrowClass}:after"), (~".@{arrowClass}:before") {
bottom: 100%;
border: solid transparent;
@Kalyse
Kalyse / compile.js
Created August 28, 2012 11:14
Running Less
// $ node compile.js
var fs = require('fs'), // file system access
path = require('path'),
less = require('less'); // less processor
var options = {
compress: true,
optimization: 1,
silent: false
@Kalyse
Kalyse / fabfile.py
Created August 28, 2012 11:15
Fab Start Stop of inotifywait script watching for LESS CSS Files
def startcss():
with lcd(r"%s/bin" % local_dir):
local("nohup ./checkCss.sh &> /dev/null < /dev/null &")
def stopcss():
local("ps -ef | grep \"checkCss\" | grep -v \"grep\" | awk '{print $2}' | xargs kill -9")
@Kalyse
Kalyse / pingfcgi.sh
Created October 3, 2012 13:27 — forked from mpasternacki/pingfcgi.sh
Ping FCGI server, using cgi-fcgi program from libfcgi library.
#!/bin/sh
set -e
# Ping FCGI server. Uses cgi-fcgi program from libfcgi library.
# Retrieves the root path (/) from host:port specified on command line.
if [ -z "$1" ] ; then
echo "Usage: $0 host:port|path/to/socket" >&2
exit 1
fi
@Kalyse
Kalyse / newrelic.vcl
Created January 20, 2013 14:18
Structure Includes to a Varnish 3.0.x VCL file to support X-Request-Start time in NewRelic. --- Note, that since 3.0.x the old method no longer works.
........
C{
#include <syslog.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}C
sub vcl_recv {
@Kalyse
Kalyse / imagickColorHist
Created January 31, 2013 21:29
Histogram in Imagick. Create a Histogram using ImageMagick from the command line
convert image.png -resize 400x400 -format %c -dither None -quantize LAB -colors 1 -depth 8 histogram:info:- | sort -r
@Kalyse
Kalyse / gist:4991817
Created February 20, 2013 01:11
Count CSS Styles on a Page
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) {