Skip to content

Instantly share code, notes, and snippets.

View phluid61's full-sized avatar
😶
¯\_(ツ)_/¯

Matthew Kerwin phluid61

😶
¯\_(ツ)_/¯
View GitHub Profile
@phluid61
phluid61 / .htaccess
Created March 24, 2014 22:14
offline compression in Apache
AddType text/html .html_gz
AddType text/javascript .js_gz
AddType text/css .css_gz
AddEncoding gzip .html_gz .css_gz .js_gz
IndexIgnore *_gz
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}_gz -f
@phluid61
phluid61 / curl_get_contents.php
Last active August 29, 2015 14:01
curl_get_contents -- if your jerk ISP disables allow_url_fopen
<?php
function curl_get_contents($url) {
$ch = curl_init($url);
# curl options
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
# socket options
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
@phluid61
phluid61 / template-jquery.js
Created March 10, 2015 23:43
javascript templates
"use strict";
(function(globals,$){
/* scoped, safe, happy code goes here */
$(function(){
/* example jQuery onload function */
});
})((1,eval)('this'),jQuery);
@phluid61
phluid61 / analyse.rb
Created April 7, 2015 07:24
colour analysis of CSS files
#!/bin/env ruby
if ARGV.length == 0
puts "Usage: #$0 *.css"
exit 1
end
$dict = {}
ARGV.each do |f|
@phluid61
phluid61 / tools.css
Last active August 29, 2015 14:20
HTMLised RFC stylesheet
/*
* URL: "https://tools.ietf.org/html/*"
*/
body{font-size:1em!important;background:#fff;color:#000}
div.content{font-family:monospace;width:72ch!important; padding:0; margin:0 auto}
hr{width:100%!important;margin:0.5em 0}
small small{font-family:sans-serif;font-style:italic}
/* pure decoration: */

Keybase proof

I hereby claim:

  • I am phluid61 on github.
  • I am phluid61 (https://keybase.io/phluid61) on keybase.
  • I have a public key whose fingerprint is B99C 2E7E 1FD9 EABB A0CE C529 62B4 8913 E7EC 5EF9

To claim this, I am signing this object:

@phluid61
phluid61 / float_range.patch
Last active December 27, 2015 13:19
float ranges
diff --git a/range.c b/range.c
index ebd0811..8cb4da8 100644
--- a/range.c
+++ b/range.c
@@ -419,11 +419,21 @@ range_step(int argc, VALUE *argv, VALUE range)
if (!rb_obj_is_kind_of(step, rb_cNumeric)) {
step = rb_to_int(step);
}
- if (rb_funcall(step, '<', 1, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step can't be negative");
@phluid61
phluid61 / output.log
Last active February 1, 2016 05:09
Ruby / Oniguruma case-insensitive non-word quirk
$ ruby -v re.rb
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
non-word:
/\W/ => []
/\W/i => []
/[\W]/ => []
/[\W]/i => ["fF", "Ss"]
not word/leading word:
/^\w/ => ["f"]
@phluid61
phluid61 / a.rb
Created February 25, 2016 22:34
ruby 'require' scope
require_relative 'b'
Foo.new.foo
p ['Main in a.rb', $global, bar, Baz.qux]
@phluid61
phluid61 / proc_curry.rb
Last active August 24, 2016 05:02
JRuby proc currying error
puts RUBY_DESCRIPTION
if $VERBOSE
# Works:
prc = proc{|a,b,c| [a,b,c] }
p prc.curry.call()
p prc.curry.call(1)
p prc.curry.call(1,2)
p prc.curry.call(1,2,3)