Skip to content

Instantly share code, notes, and snippets.

@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
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use 5.010000;
use AE;
use AnyEvent::HTTP;
my @urls = (
@mala
mala / gist:1073612
Created July 9, 2011 14:20
jQuery MobileのloadPageで異なるホストを弾く
// jQuery MobileのloadPageで異なるホストを弾く
// Note: 同一ドメインにオープンリダイレクタがないか確認すること
(function($){
var old = $.mobile.loadPage;
var gethost = function(url){
var a = document.createElement("a");
a.href = url;
return a.host
};
@mala
mala / gist:1073591
Created July 9, 2011 13:50
jQueryでクロスドメイン読み込みを全般的に禁止する
// jQueryでクロスドメイン読み込みを全般的に禁止する
// Note: 同一ドメインにオープンリダイレクタがないか確認すること
(function($){
var gethost = function(url){
var a = document.createElement("a");
a.href = url;
return a.host
};
var old_beforesend = $.ajaxSettings.beforeSend;
@mala
mala / gist:1071708
Created July 8, 2011 12:19
Furlでローカルアドレスへのアクセス禁止したい
# FurlX::ParanoidAgent 的なやつ
my $furl = Furl->new(
inet_aton => \&_inet_aton,
);
sub _inet_aton {
my $addr = Net::DNS::Lite::inet_aton(@_);
if (is_local_addr($addr)) { return }
$addr;
anonymous
anonymous / jq_quickpatch.html
Created June 24, 2011 15:05
quick patch for jQuery selector XSS
<script type="text/javascript">
// http://ma.la/jquery_xss/
var _$=$;
$=function(){
if( typeof arguments[ 0 ] == "string" && /^#.*</.test( arguments[ 0 ] ) ){
throw new Error( "selector error" );
}
return _$.apply( this, arguments );
};
</script>
#!/usr/bin/env perl
use strict;
use warnings;
use DBIx::Sunny;
use Digest::MurmurHash qw/murmur_hash/;
use Text::ASCIITable;
use String::Random qw/random_regex/;
my $dbh = DBIx::Sunny->connect('dbi:mysql:test');
@hryk
hryk / glitch.rb
Created May 10, 2011 11:13
glitch your display.
#!/usr/bin/env macruby
#
# MacRubyで画面グリッチをフルスクリーン表示する
#
# http://twitter.com/negipo/status/67572370247913473
#
# ## Usage
#
# ./glitch.rb
#
#!perl
use strict;
use warnings;
use Getopt::Long;
use Test::Httpd::Apache2;
use Path::Class;
my $port = 5000;
my $root = '.';
/* Copyright 2011 by Yasuhiro Matsumoto
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS