Skip to content

Instantly share code, notes, and snippets.

@mala
mala / jquery_xss_patch.js
Created April 26, 2012 13:23
jQuery XSS patch
(function(){
jQuery.fn.__init = jQuery.fn.init;
var old_expr = /^(?:[^<]*(<[\w\W]+>)[^>]*$)/;
var strict_expr = /^\s*</;
jQuery.fn.init = function(selector, context, rootjQuery){
if (typeof selector === "string") {
// console.log(selector);
if (old_expr.test(selector) && !strict_expr.test(selector)) {
throw 'Syntax error, html string must start with "<"';
}
package Plack::BenchmarkerBuilder;
use strict;
use warnings;
use parent 'Plack::Builder';
use Time::HiRes 'time';
sub import {
my $class = shift;
Plack::Builder->export_to_level(1, @_);
> perl -E 'say "生" & "死"'
生 Life U+751F \xe7\x94\x9f 11100111 10010100 10011111
死 Death U+6B7B \xe6\xad\xbb 11100110 10101101 10111011
愛 Love u+611B \xe6\x84\x9b 11100110 10000100 10011011
@repeatedly
repeatedly / downloader.d
Last active October 1, 2015 23:18
D言語でいかにしておっぱい画像をダウンロードするか〜2013
// Written in the D programming language.
/**
* High peformance downloader
*
* Implemented according to <a href="http://yusukebe.com/archives/20120229/072808.html">this implementation</a>.
*
* Example:
* -----
* dmd -L-lcurl -run downloader.d
@mala
mala / gist:2021195
Created March 12, 2012 11:04
忍者ツールズの利用規約、プライバシーポリシーの不備は何であるのか
** アクセス解析の類を設置するサイト運営者の一般的な想定
http://www.ninja.co.jp/rule/analyze
図1
訪問者 → 忍者ツールズ → 業務提携先
サイト運営者
この場合、業務提携先、業務委託先に「忍者ツールズが知っているデータ」の中で「忍者ツールズが第三者に提供しても大丈夫だと考えている情報」が共有されることになる。
それは利用規約とかプライバシーポリシーに、統計データのみとか、個人を特定できないようにするとか、必要な範囲でとか、守秘義務を結んだ上で、とか書かれるのが一般的。
@cho45
cho45 / github-widget.js
Created February 28, 2012 00:00
Expand any github api to HTML.
// Eg.: http://cho45.github.com/tasscss/
(function () {
var scripts = document.getElementsByTagName('script');
var script = scripts[scripts.length-1];
var container = document.createElement('div');
script.parentNode.insertBefore(container, script);
var callback; do {
callback = 'jsonp' + Math.floor(Math.random() * 0xffff);
@miyagawa
miyagawa / gist:1867992
Created February 20, 2012 05:35
Import non-reply Tweets into DayOne, incrementally. moved to https://github.com/miyagawa/dayone_import_tweets
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
require 'open3'
require 'date'
class Importer
attr_reader :screen_name
@kazeburo
kazeburo / gist:1778392
Created February 9, 2012 08:20
nginx HTTP/1.0 upstream keepalive
--- nginx-1.1.14.orig/src/http/ngx_http_upstream.c 2012-01-19 00:07:43.000000000 +0900
+++ nginx-1.1.14/src/http/ngx_http_upstream.c 2012-02-09 17:11:02.000000000 +0900
@@ -3426,6 +3426,13 @@
r->upstream->headers_in.connection_close = 1;
}
+ if (ngx_strlcasestrn(h->value.data, h->value.data + h->value.len,
+ (u_char *) "keep-alive", 10 - 1)
+ != NULL)
+ {
@riywo
riywo / gist:1681604
Created January 26, 2012 07:56
llinstallとllenvでikachan入れる
$ curl -kL https://raw.github.com/riywo/App-llenv/master/llenv-install | bash
and add your .bashrc or something
export LLENV_ROOT=$HOME/llenv
export LLENV_OSTYPE=`$LLENV_ROOT/bin/ostype`
export PATH=$LLENV_ROOT/bin:$PATH
$ llinstall init perl
$ llinstall install perl perl-5.14.2
@hirose31
hirose31 / gist:1668178
Last active June 7, 2021 07:46
/proc/PID/statからプロセスの起動時刻を知る
use POSIX qw(strftime sysconf _SC_CLK_TCK);
use File::Slurp;
use Time::Piece;
use Time::HiRes qw(time);
my $TIME_OF_BOOT = time_of_boot();
my $CLOCK_TICK = sysconf(_SC_CLK_TCK);
MAIN: {
my $pid = shift or die "missing PID";