Skip to content

Instantly share code, notes, and snippets.

View geta6's full-sized avatar

geta6 geta6

View GitHub Profile
@geta6
geta6 / initialize.sh
Created May 16, 2012 23:18
初期状態のUbuntuサーバを俺仕様にするスクリプト
#!/bin/bash
TMP=`mktemp`
if [[ $1 == '-h' ]]; then
echo "Usage: $0"
echo "Available option: [skip | Skip OS version check]"
exit
fi
@geta6
geta6 / moshroom.js
Created May 17, 2012 17:04
卑猥なGoogleロゴをモザイクにします Firefoxの場合はアドレスバーでなくブックマーク登録からご利用ください
javascript:(function(){var g=function(c){return document.getElementById(c?"hplogo":"lga")},g={i:g(0),d:g(1),w:g(1).naturalWidth,h:g(1).naturalHeight},d=document.createElement("canvas"),o=d.getContext("2d"),a=g.i.querySelector("a"),e=5;d.setAttribute("width",g.w+"px");d.setAttribute("height",g.h+"px");d.setAttribute("style",g.d.getAttribute("style"));o.drawImage(g.d,0,0);a.innerHTML="";a.appendChild(d);for(var k=0;k<g.h;k+=e){var f=(e<=g.h-k)?e:g.h-k;for(var l=0;l<g.w;l+=e){var m=(e<=g.w-l)?e:g.w-l,b=[0,0,0],n=o.getImageData(l,k,m,f).data;for(var j=0;j<n.length;j+=4){b[0]+=n[j];b[1]+=n[j+1];b[2]+=n[j+2]}var i=n.length/4;b[0]=Math.floor(b[0]/i);b[1]=Math.floor(b[1]/i);b[2]=Math.floor(b[2]/i);o.clearRect(l,k,m,f);o.fillStyle="rgb("+b.join(",")+")";o.fillRect(l,k,m,f)}}}());
@geta6
geta6 / SumToN.html
Created May 18, 2012 07:27
入力された値までの総和を求めます
<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <title>SumToN</title>
</head>
<body>
  <h1>Parameter</h1>
  <div>
@geta6
geta6 / hom.js
Created May 21, 2012 09:55
表示中の文章をアンビエントにほむほむに変換します
javascript:with(document.body)innerHTML=innerHTML.replace(/[%E4%B8%80-%E9%BE%A0|%E3%80%85]+/g,'%E3%81%BB%E3%82%80%E3%81%BB%E3%82%80').replace(/([w%EF%BD%97%E3%80%82%EF%BC%8E%EF%BC%81])/g,'%E3%81%BB%E3%82%80%E3%81%A3$1').replace(/!(?!-)/g,'%E3%81%BB%E3%82%80%E3%81%A3!').replace(/([%E2%80%A6%E3%80%81%EF%BC%8C,?%EF%BC%9F])/g,'%E3%81%BB%E3%82%80%E3%81%85$1');focus();
@geta6
geta6 / evalgyazz.js
Created May 30, 2012 04:13
gyazzのrow-textをjsでevalします id='req'に生テキストが入っててid='res'が存在してれば動く
var scr;
String.prototype.repeat = function (num) {
for (var i = 0, b = ''; i < num; i++) b += this;
return b;
};
(function () {
// CONSTANTS
var reg = {
@geta6
geta6 / escape.js
Created June 6, 2012 06:44
忙しい人のためのjsでHTMLをエスケープするやつ
function (text) {
var obj = document.createElement('pre');
obj[typeof obj.textContent != 'undefined'?'textContent':'innerText'] = text;
return obj.innerHTML;
}
@geta6
geta6 / direcursive.php
Created June 9, 2012 12:52
findとphpで、あるディレクトリ内のファイルを再帰的に日付順でソートして出力するですよー
<?php
exec('find $DIR -type f -print0 | xargs -0 ls -lt --time-style=long-iso "{}" 2>/dev/null', $e);
// -maxdepth
// -mindepth
// -mtime
preg_match_all('|[0-9]{2,}? +(.+?) (/.+)|', implode("\n",$e), $m, PREG_SET_ORDER);
@geta6
geta6 / feedburner.twig
Created June 9, 2012 15:47
iTunesのPodCastが認識できるXMLを吐きます
<?xml version="1.0" encoding="UTF-8" ?>
<rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
<channel>
<title>PodTest</title>
<link>http://example.com/</link>
<pubDate>{{ 'now' | date('r') }}</pubDate>
<language>ja</language>
<description>ぽどきゃすと</description>
<itunes:author>さくせいしたひと</itunes:author>
{% for feed in feeds %}
@geta6
geta6 / pressoct.sh
Created June 14, 2012 02:22
Setup Octopress
git clone https://github.com/imathis/octopress.git octopress
cd octopress
sudo gem install bundler
bundle install
rake install
echo "sample -> [email protected]:USERNAME/USERNAME.github.com"
rake setup_github_pages
@geta6
geta6 / fastcgi.conf
Created June 17, 2012 12:25
Nginxでディレクトリでサブドメインを切りながら共通エラーページを制御します.
:
error_page 404 = @404;
error_page 500 = @500;
error_page 502 = @502;
: