Skip to content

Instantly share code, notes, and snippets.

@ysmood
ysmood / gplus_clear_posts_btn.coffee
Last active December 19, 2015 13:09
A tool for G+ to remove all the loaded posts.
# A tool for G+ to remove all the loaded posts.
# This tool may be helpful when you have loaded lots of posts, and your browser is to slow to loading any more.
# You can trigger it either by press "C" or click the "Clear Posts" button.
# Jul 2013 ys
init = ->
stream_stage = document.querySelector('.wIa')
if stream_stage == null
return
@ysmood
ysmood / temp.sh
Last active December 21, 2015 05:18
ks() {
cur_dir=(pwd)
cd /opt/katawa-shoujo
Katawa\ Shoujo.sh
cd cur_dir
}
@ysmood
ysmood / ruby_var_test.rb
Created August 17, 2013 09:42
Performance test of the variable in different scopes.
$g = 10
def fun_g a
a += $g
end
def fun_l a
l = 10
a += l
end
@ysmood
ysmood / tail_recursion.c
Last active December 22, 2015 23:19
gcc test: `gcc -O3 tail_recursion.c`
#include "stdio.h"
void foo(x) {
printf("%d\n", ++x);
foo(x);
}
int main(int argc, char const *argv[]) {
foo(1);
return 0;
@ysmood
ysmood / archlinux_installation_guide.md
Last active December 23, 2015 15:29
archlinux_installation_guide

Archlinux Installation Guide

  1. Select kernel version "Other Linux 3.x kernel".
  2. Set the vm's hardware resource limitation.
  3. Boot Arch.
  4. Partition.
  • Show disk list: fdisk -l
  • Create partition: cfdisk /dev/sda 0. /dev/sda1 for boot. Primary, Bootable
  1. /dev/sda2 for swap. Primary, Type 82
@ysmood
ysmood / g.py
Created October 27, 2013 04:59
low = 0
high = 100
guess_number = (low + high) / 2
print("Please think of a number between 0 and 100!")
while True:
char = raw_input("Is your secret number " +
str(guess_number) + "?\n" +
"Enter 'h' to indicate the guess is too high." +
"Enter 'l' to indicate the guess is too low." +
@ysmood
ysmood / shift.py
Last active December 29, 2015 17:59
def buildCoder(shift):
def gen(a, z): return zip(map(chr, range(a, z)), map(chr, range(a + shift, z - shift) + range(a + 25 - shift, z)))
return dict( gen(ord('a'), ord('z')) + gen(ord('A'), ord('Z')) )
print buildCoder(3)
@ysmood
ysmood / break_deep_loop.js
Last active January 1, 2016 04:39
break_deep_loop
fun_closure = function(n) {
for (i = 0; i < n; i++)
(function(){
for (j = 0; j < n; j++)
for (k = 0; k < n; k++) {
if (j * k > n) return;
j + k;
}
})()
@ysmood
ysmood / troy.js
Last active January 20, 2016 07:03
ssh proxy
var net = require("net");
var fromPort = 9000;
var toPort = 22;
var toHost = "127.0.0.1";
function errorLog (err) {
console.error(err);
}
var server = net.createServer(function (con) {
@ysmood
ysmood / Subclass Example.js
Last active February 24, 2016 07:54
Subclass Example
function A () {
this._v = 1;
this.bar = function () {
return this._v;
}
}
A.prototype.foo = function () {
return this._v;
};