This file contains 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
# I don't like kyoko-np.net | |
127.0.0.1 kyoko-np.net | |
# Block Facebook IPv4 | |
127.0.0.1 www.facebook.com | |
127.0.0.1 facebook.com | |
127.0.0.1 login.facebook.com | |
127.0.0.1 www.login.facebook.com | |
127.0.0.1 fbcdn.net | |
127.0.0.1 www.fbcdn.net |
This file contains 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
/** | |
* 文字列中の空白行(スペースまじりのものを含む)が二行以上続いたときに一行に変換する | |
* 例: $tweet = multipleBlankLinesToOneBlankLine($tweet); | |
*/ | |
function multipleBlankLinesToOneBlankLine($str) { | |
// 改行コード(\r\n, \r, \n) を全て \n に統一 | |
$str = str_replace(array('\r\n', '\r', '\n'), '\n', $str); | |
// 改行コードで分割 | |
$lines = explode("\n", $str); | |
// 前後の空白を取り除く |
This file contains 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
#!/bin/bash | |
set -Ceu | |
######################### | |
# My Basic VM config # | |
# updated: 2017-01-23 # | |
# # | |
# ### How to use ### # | |
# - become root # | |
# - edit 3 params below # |
This file contains 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
$.ajax({ | |
type: "POST", | |
url: "api.php", | |
timeout: 10000, | |
cache: false, | |
data: {'hello': "world"}, | |
dataType: 'json' | |
}) | |
.done(function (response, textStatus, jqXHR) { | |
console.log(response); |
This file contains 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
$("#form").on("keydown", function (e) { | |
if ((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey) { | |
console.log("enter + ctrl"); | |
} else if (e.shiftKey && e.keyCode === 13) { | |
console.log("enter + shift"); | |
} | |
}); |
This file contains 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
// URLを入力するとTitleを自動補完する | |
$("#url").change(function () { | |
var url = $("#url").val(); | |
if (is_url(url)) { | |
$("#title").val("自動補完中...しばらくお待ち下さい。"); | |
// URLのようであれば問い合わせしに行く | |
$.ajax({ | |
type: "GET", | |
url: "https://crossorigin.me/" + url, | |
timeout: 10000, |
This file contains 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
<?php | |
// http://ameblo.jp/principia-ca/entry-11770810115.html | |
// ここ↑にはJavaのRedisのLockが書いてあり、それを参考にPHP版を作ろうとしたが上手く行かず。 | |
// try {} finallyとか、exceptionがなんかだめな感じ(´・ω・`) | |
define('LOCK_KEY_PREFIX', 'lock:'); | |
define('LOCK_EXPIRE_SEC', 30); | |
define('LOCK_SLEEP_MILL', 10); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title>RTCDataChannel Example</title> | |
</head> | |
<body> | |
<div> | |
<div> | |
<h2>RTCDataChannel Example</h2> |
This file contains 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
<script type="text/javascript"> | |
function downloadFile() { | |
var filename = document.getElementById("filename-input").value; | |
var text = document.getElementById("text").value; | |
console.log("filename:"); | |
console.log(filename); | |
console.log("text:"); | |
console.log(text); | |
var blob = new Blob([text], {type: "text/plain"}); | |
var url = window.URL.createObjectURL(blob); |
This file contains 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/perl -w | |
# This is a benchmark script forked from mybench (http://jeremy.zawodny.com/mysql/mybench/). | |
# Not only MySQL, Redis, MongoDB, HBase, all welcome! | |
# | |
# Usage: | |
# $ wget http://jeremy.zawodny.com/mysql/mybench/mybench-1.0.tar.gz | |
# $ tar zxvf mybench-1.0.tar.gz | |
# $ cd mybench-1.0 | |
# # download this file :) |
NewerOlder