Skip to content

Instantly share code, notes, and snippets.

@firstspring1845
firstspring1845 / Xorshift.java
Last active December 21, 2015 06:49
Xorshiftアルゴリズムを使用して乱数を発生させるクラスです 初期化処理とか正規乱数周りとか結構いい加減だったり
public class Xorshift
{
private long[] seed;
private double nextGaussian;
private boolean hasNextGaussian;
public Xorshift()
{
long l = System.currentTimeMillis();
@firstspring1845
firstspring1845 / Xorshift.cs
Created August 19, 2013 08:15
Xorshiftアルゴリズムを(ry C#に移植しただけなのでRandomクラスに準拠していなかったり色々適当です
using System;
namespace Yggdrasill
{
public class Xorshift
{
private long[] seed;
public Xorshift()
{
@firstspring1845
firstspring1845 / ReflectionUtil.java
Created September 22, 2013 07:52
リフレクションするやつ
package net.firstspring.lib;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class ReflectionUtil
{
@SuppressWarnings("unchecked")
public static <T,E> E getField(Class<?> c, T instance, String field)
@firstspring1845
firstspring1845 / rpn.py
Last active December 27, 2015 10:59
逆ポーランド電卓
stack = []
for s in raw_input().split():
if s in ('+','-','*','/'):
stack.append(eval('{2}{1}{0}'.format(stack.pop(),s,stack.pop())))
else:
stack.append(int(s))
print stack.pop()
@firstspring1845
firstspring1845 / rpn.rb
Created November 5, 2013 07:17
逆ポーランド電卓
stack = []
for s in gets.split()
if ['+','-','*','/'].include?s
stack.push(eval(stack.pop.to_s+s+stack.pop.to_s))
else
stack.push(s.to_i)
end
end
puts stack.pop
@firstspring1845
firstspring1845 / rauth_twitterstream.py
Last active December 27, 2015 18:09
rauth使ってUserStream受信してみる Python2で使う時はl.decode()をlにすればいいはず
import sys,json
from rauth.service import OAuth1Service
auth = OAuth1Service(
name='twitter',
consumer_key='key',
consumer_secret='secret',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url='https://api.twitter.com/oauth/access_token',
authorize_url='https://api.twitter.com/oauth/authorize')
@firstspring1845
firstspring1845 / dha_lo_jd_gen.py
Last active December 31, 2015 12:29
┃━┏┃
import random
choice = random.choice
dha_lo_jd = '━┃┓┛┏┗┳┻┣┫╋'
def generate(num):
print(''.join([choice(dha_lo_jd) for i in range(num)]))
@firstspring1845
firstspring1845 / updatename.py
Last active January 2, 2016 00:28
あぷでねーむ
# -*- encoding:utf-8 -*-
import re,threading
import twitter,util
t = {34:None,60:None,62:None,12288:None,65288:40,65289:41,10:None,65312:64} #全角スペース等の除去とか一部全角記号を半角に変換とか
r = re.compile('\([^(]*?@' + twitter.account.name + '.*?\)')
def on_data(data):
if 'friends' in data:
global ids
ids = set(data['friends'])
package com.orekyuu.javatter.view;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.lang.reflect.Method;
import javax.swing.JPanel;
package net.firstspring.javatter.plugin;
import java.awt.Image;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;