Skip to content

Instantly share code, notes, and snippets.

@tompng
tompng / gikuSmooth2.js
Last active December 16, 2015 22:09
ヒストグラムのなめらか版、みたいな
function gikuSmooth(arr,length,T){
var K=10/3/T;
var data=[];
var xmap={};
for(var i=0;i<arr.length;i++){
var obj=arr[i];
var x,v;
if(obj.length){x=obj[0].length;v=obj[1];}
else{x=obj/length;v=1;}
if(xmap[x])xmap[x].v+=v;
@tompng
tompng / fbadkiller.js
Created May 23, 2013 13:36
FaceBookの広告にいいねを押さないスクリプト
var cnt=0;
function killAds(){
var units=document.getElementsByClassName("ego_unit");
try{selectAll()}catch(e){}
for(var i=0;i<units.length;i++){
if(units[i].innerHTML.match("広告"))try{findDisableButton(units[i])}catch(e){}
}
for(var i=0;i<units.length;i++){
var unit=units[i]
if(unit.innerHTML.match("さんが"))continue;
@tompng
tompng / growl_hogehoge.rb
Last active December 17, 2015 23:29
growlで遊び中
# coding: utf-8
require 'socket'
require 'digest'
class GrowlUDP
attr_accessor :app, :password, :types
def initialize op
self.app = op[:app]
self.password = op[:password]
self.types = op[:types]
@tompng
tompng / guruguru.rb
Last active December 18, 2015 07:28
勝てなかったrubyのぐるぐる渦巻きコードゴルフ http://codeiq.hatenablog.com/entry/2013/06/10/165837 108文字
n=gets.to_i/2
a=-n..n
a.map{|y|puts a.map{|x|"%#{4-21/(n+6)}d".%2*[2*y*y-y,2*x*x-x-z=(x-y).abs].max-~z}*' '}
@tompng
tompng / gist:5949809
Last active December 19, 2015 11:48 — forked from webcrafts/gist:5948862
#coding: utf-8
class Te
attr_accessor :te_num
def initialize num=nil
self.te_num = num ? num % 3 : rand(3)
end
def > te
(te_num + 1) % 3 == te.te_num
var express = require('express');
var http = require('http');
var cpus = require('os').cpus().length;
var app = express();
var net = require('net');
var cluster = require('cluster');
var socketio=require('socket.io');
var httpport = 4567;
var curlport = 5678;
process.on('uncaughtException',function(err){});
@tompng
tompng / ls2sl.cc
Last active April 9, 2020 19:29
ls2sl for mac
//g++ -framework ApplicationServices ls2sl.cc
//enable [System Preferences -> Universal Access -> Access for assistive devices]
#include <stdio.h>
#include <ApplicationServices/ApplicationServices.h>
#include <sys/time.h>
#define BUFSIZE 100
int keyBuffer[BUFSIZE];
struct timeval timeBuffer[BUFSIZE];
@tompng
tompng / bezier.js
Last active December 20, 2015 23:19
ベジェで遊んでみてる ひどいからgithubに移した https://github.com/tompng/bezierhogehoge/tree/bezier_eraser
BezierConverter={}
BezierConverter.BSearch=function(min,max){
if(min==undefined)min=0;
if(max==undefined)max=Infinity;
this.index=min;
this.ok=min-1;
this.ng=null;
this.result=function(result){
if(result)this.ok=this.index;
else this.ng=this.index;
@tompng
tompng / screenshotserver.js
Last active December 22, 2015 06:48
phantomjs screenshot server
var server=require('webserver').create();
var webpage=require('webpage');
var fs=require('fs');
var service=server.listen(8080,function(request,response){
var queryIndex=request.url.indexOf("?");
var params={};
if(queryIndex>=0){
var queries=request.url.substr(queryIndex+1).split('&');
for(var i=0;i<queries.length;i++){
@tompng
tompng / helloworld.rb
Last active December 23, 2015 09:59
HelloWorlds
#!ruby
def method_missing name, *args
n, a = name.to_s.chars.first, *args
return n + a.to_s if n.downcase == n || n.respond_to?(n)
String.class_eval{define_method(n){a.size - n.size}}
print n + a + (a.reverse.ord - n.ord - a.hex / n.send(n) - n.send(n)).chr
end
H H eeee l l oo
H H e l l o o