This file contains hidden or 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
| // ==UserScript== | |
| // @name GlitchMonkey | |
| // @namespace http://d.hatena.ne.jp/youpy/ | |
| // @include * | |
| // ==/UserScript== | |
| var Corruptions = { | |
| 'image/jpeg': function() { | |
| return this.replace(/0/g, Math.floor(Math.random() * 10)); | |
| }, |
This file contains hidden or 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 'base64' | |
| path = ARGV.shift | |
| if File.exists?(path) && path.match(/^(.+)\.(.+)$/) | |
| files = [] | |
| filename = $1 | |
| ext = $2 | |
| 10.times do |i| | |
| 10.times do |j| | |
| File.open(path,'r') do |f| |
This file contains hidden or 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 python | |
| print max([i * k for i in range(10, 100) for k in range(10, 100) if str(i * k) == str(i * k)[::-1]]) | |
| # => 9009 |
This file contains hidden or 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
| /* | |
| * this depends on jQuery.js, jQuery.hashchange.js | |
| * #! 使ったときにアレな感じになるの多かったので | |
| */ | |
| (function($, btn) { | |
| // util method | |
| // check prototype contamination | |
| if(!Array.prototype.contains){ | |
| // check to exist optional value in array | |
| Array.prototype.contains = function(value){ |
This file contains hidden or 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
| /* | |
| * this depends on jQuery.js, jQuery.hashchange.js | |
| * 使っていたライブラリが既にonにしている画像を mouse over して mouse out した時とかに _onを消したりしてきたので書いた. | |
| * pjax 諸事情により使えず, flagment url 使っていて, それで tab change したい時とかに 「mouse over(_on)->click(ここではアクティブな画像にしたいので_on[他でやってる])->mouse out(_on消す) 」とかなってしまってたのも hashchange した段階で一回イベント取り除くことで一応解決した. | |
| */ | |
| (function($, btn) { | |
| // util method | |
| // check prototype contamination | |
| if(!Array.prototype.contains){ | |
| // check to exist optional value in array |
This file contains hidden or 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
| describe('Array クラスは', function() { | |
| var arr = null; | |
| // beforeEach: arr を初期化 | |
| // afterEach 追加した要素の後処理をかをできる | |
| beforeEach(function() { | |
| arr = [1, 2, 3]; | |
| }); | |
| it('length プロパティで配列長を取得する事ができる', function() { | |
| expect(arr.length).toEqual(3); |
This file contains hidden or 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
| (function($){ | |
| /* promise returner */ | |
| function doAsyncThing(){ | |
| var dfd = $.Deferred(); | |
| var timeA = aFewMilliSec(); | |
| var timeB = aFewMilliSec(); | |
| setTimeout(function(){ | |
| // success | |
| dfd.resolve('something seems to be successed.', timeA); |
This file contains hidden or 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
| # session キー指定 | |
| application.secret_key = 'foo' | |
| # SQLAlchemy の使い方 | |
| from flaskext.sqlalchemy import SQLAlchemy | |
| application.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:////tmp/fast_atnd.db" | |
| class User(db.Model): | |
| id = db.Column(db.Integer, primary_key=True) | |
| username = db.Column(db.String(80), unique=True) | |
| email = db.Column(db.String(120), unique=True) |
This file contains hidden or 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
| { | |
| "meta", | |
| "response" { | |
| "member" => { | |
| "name" => "toqoz" | |
| } | |
| } | |
| } | |
| /* | |
| というレスポンスが返ってくる場合 「toqoz」につくclass名/id名 は |
This file contains hidden or 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
| [~]$ cd /path/to/js | |
| // original のファイルの置き場 | |
| [/path/to/js]$ mkdir src | |
| [/path/to/js]$ vi src/foo.js | |
| [/path/to/js]$ vi src/bar.js | |
| [/path/to/js]$ vi Makefile | |
| #----------- | |
| SRC = src/foo.js src/bar.js | |
| COMB = foobar.js | |
| all: $(COMP) |