Skip to content

Instantly share code, notes, and snippets.

View sters's full-sized avatar
🐱
meow!

sters sters

🐱
meow!
View GitHub Profile
(function(w,l){
//return;
var excludes = ['google.com'].join('|');
var trusted = ['dragonfly.opera.com','bit.ly','delicious.com','www.google.co.jp','gyazo.com','delicious.com','google.com','lingr.com','www.w3.org','ashula.info','fastladder.com','www.opera.com','opera-users.jp','puchi.co','oflo.in','ofton.in','opera-wiki.com','localhost','browser-festa.jp'
].join('|');
if ( !l.protocol.match(/http/)
|| ( w.parent !== w )
|| ( l.hostname.match(new RegExp('(' + excludes + ')$' )))
|| ( l.hostname.match(new RegExp('(' + trusted + ')$' )))
){
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@tamagokun
tamagokun / router.php
Last active March 12, 2020 11:15
Run a Wordpress site via PHP's built-in web server
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
@lunark
lunark / GenderEstimate.bas
Last active October 14, 2023 04:04
VBAマクロ向け関数。GenderEstimate。漢字の名前とふりがなから、性別を推定する関数
Public Function GenderEstimate(ByVal strMK As String, Optional strMF As String = "") As String
GenderEstimate = ""
strMK = Replace(Replace(Replace(strMK, " ", ""), " ", ""), "「", "")
strMF = Replace(Replace(StrConv(strMF, vbHiragana), " ", ""), " ", "")
'デバッグ用。こいつをブレークポイントに持ってきて挙動を確認する
'If strMK Like "理世" Then
' Debug.Print strMK
'End If
@shtwave
shtwave / gist:5162614
Last active November 10, 2021 07:04
netfilterチューニング
ip_conntrack: table full, dropping packet.
この一行のログに悩まされた方は多いのではないでしょうか。
自分もその一人です。
多くのブログには echo '500000' > /proc/sys/net/ipv4/netfilter/ip_conntrack_max で解決。みたいなことが書いてあると思います。
では、この数字について根拠はなんでしょうか。そもそも何のためにconntrack tableというものがあるのか考えたことはありますか?
闇雲に最大値をあげることにたいして抵抗がある方もいると思います。
このテキストは、転職後2日目にGWとして使っているLinux NAT BOXが爆発したことを起因とした、netfilterのチューニングについてまとめようと思います。
@oboenikui
oboenikui / Ohirune_Circle_Specification.md
Last active December 17, 2015 11:19
おひるねサークル仕様

##レベルについて
現在のレベルの変数をlevelとすると、次のレベルまでの総ポイント数(nextPoint)は
nextPoint = (level+1)*7*level/2+1;
で与えられます。何でこんな仕様にしたかはわかりません。遥か昔に忘れました。
つまり、例えば現在2Lvでおひるねポイントが9の場合は、(2+1)72/2+1=22なので、あと13ポイントで3Lvに見事レベルアップ、というわけです。

##おひるねできる時間と獲得ポイントについて

  • 寝る方
    最後に寝てから1時間以内の場合は、おひるねできません。働きましょう。ただし起きてからすぐ寝ることはできます。作者がそういう睡眠をよく取るからです。
@botchju
botchju / ohirune.html
Last active December 17, 2015 11:59 — forked from sters/ohirune.html
<html>
<body>
<a id="ohirune" target="_blank">おひるね</a>
<a id="okita" target="_blank">おきた</a>
<script type="text/javascript">
(function(){
function ohirune_web(mode){
var ohuton = ["[▓▓]", "[__]"];
@cmackay
cmackay / gist:5863257
Last active January 29, 2024 17:16
AppleScript to save and restore window position and sizes.
-- allSettings is a list of records containing {width:? height:? apps:{{name:? pos:? size:?},...}
-- for each display setup store the apps and their associated position and size
property allSettings : {}
-- create a variable for the current settings
set currentSettings to {}
display dialog "Restore or save window settings?" buttons {"Restore", "Save"} default button "Restore"
set dialogResult to result
@sasamijp
sasamijp / namechanger.rb
Created November 24, 2013 14:47
前Anonymousで公開してた
# -*- encoding: utf-8 -*-
require 'rubygems'
require 'tweetstream'
require 'twitter'
require './key.rb'
Twitter.configure do |config|
config.consumer_key = Const::CONSUMER_KEY
config.consumer_secret = Const::CONSUMER_SECRET
config.oauth_token = Const::ACCESS_TOKEN
# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる