This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
import java.util.zip.Deflater; | |
import java.util.zip.GZIPOutputStream; | |
public class CompressingOutputStream extends GZIPOutputStream { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: binary | |
require 'socket' | |
require 'zlib' | |
require 'stringio' | |
PADDING = 256 | |
GZIP = true | |
CHUNKED = true | |
def compress(gzip, io, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import javax.script.ScriptException; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
public class Main { | |
public static void main(String[] args) throws ScriptException, FileNotFoundException { | |
if(args.length == 0) System.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Main { | |
private final static Pattern SCRIPT_SRC_PATTERN = Pattern.compile("(src)(?:\\s*=\\s*)(?:(?:\"((?:\\.|[^\"])*)\")|(?:\'((?:\\.|[^\'])*)\')|([^>\\s]+))"); | |
public static void main(String[] args){ | |
String works = "<script src=\"test\"></script>"; | |
Matcher m = SCRIPT_SRC_PATTERN.matcher(works); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Save in file to_gemfile.rb | |
# Use like so | |
# gem list | ./to_gemfile.rb | |
gem_file = File.open("Gemfile", "w") | |
gem_file.write("source :rubygems\n") | |
STDIN.readlines.each do |line| | |
line = line.chomp | |
line =~ /(.*)\s\((.*)\)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run | |
# ruby main.rb <header_base_color> | |
# | |
# Examples | |
# ruby main.rb 666666 | |
# ruby main.rb EE7621 | |
# ruby main.rb EE7621 C48E48 FF3300 | |
# | |
# It looks nicer when the header_base_color is a darker color | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parse = require('css-parse') | |
var fs = require('fs') | |
var _ = require("underscore"); | |
var contents = fs.readFileSync("style.css", "utf-8"); | |
var x = parse(contents); | |
var printSelectors = function(regex){ | |
var importantSelectors = []; | |
_.each(x.stylesheet.rules, function(d){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
def read_elements(filename, element_path, id_name, &callback) | |
f = File.open(filename) | |
xml = Nokogiri::XML(f) | |
elements = [] | |
xml.xpath(element_path).each do |element| | |
element_id = element.attributes[id_name].value.to_s | |
elements.push(element_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
EventEmitter = require('events').EventEmitter; | |
var nextEvent = new EventEmitter(); | |
var requestId = 0; | |
function poll(){ | |
requestId++; | |
http.get("<url>", function(res){ | |
res.on('data', function(chunk){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof Object.keys === 'undefined'){ | |
Object.keys = function(o){ | |
var out = []; | |
for(var key in o){ | |
if(o.hasOwnProperty(key)){ | |
out.push(key); | |
} | |
} | |
return out; | |
} |
OlderNewer