Skip to content

Instantly share code, notes, and snippets.

View jtoy's full-sized avatar

jtoy

View GitHub Profile
@jtoy
jtoy / perlin.py
Created December 26, 2017 04:50 — forked from eevee/perlin.py
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
;; 訓練データ
(def text_classified_p '(["good" "bad" "good" "good"]
["exciting" "exciting"]
["good" "good" "exciting" "boring"]))
(def text_classified_n '(["bad" "boring" "boring" "boring"]
["bad" "good" "bad"]
["bad" "bad" "boring" "exciting"]))
;;多変数ベルヌーイモデル
(defn train [features]
@jtoy
jtoy / kill_hadoop_orphans.sh
Created April 28, 2012 16:57 — forked from dvryaboy/kill_hadoop_orphans.sh
Shell script to kill orphaned Hadoop Task processes
#!/bin/bash
# Kill tasks holding on to deleted userlogs. These are most likely abandoned jobs.
function get_bad_pids {
for i in `ps -ef | grep java | awk '{print $2;}'`; do
cnt=`/usr/sbin/lsof -p $i | grep deleted | grep /var/log/hadoop-0.20/userlogs/attempt | wc -l`;
if [ $cnt -gt 0 ]; then
PIDS=$i:$PIDS;
fi
require 'em-http'
EM.run do
def dispatch(opts)
opts
puts opts
h = EM::HttpRequest.new(opts[:uri]).get
h.callback { |rep| opts[:cb].call(rep) if opts[:cb] }
@jtoy
jtoy / newpost.rb
Created August 20, 2009 02:20 — forked from al3x/newpost.rb
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "#{Dir.pwd}/_posts/#{date_prefix}-#{postname}.textile"