Skip to content

Instantly share code, notes, and snippets.

@biwakonbu
biwakonbu / eratosthenes.c
Created April 30, 2012 18:02
Eratosthenes
#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE 1
int main (int argc, char* argv[])
{
int i, p, k, count, n;
char flag[1000000];
@biwakonbu
biwakonbu / AverageCustomerAge.rb
Created December 6, 2012 14:50
プログラマのためのサバイバルマニュアル(Ruby file)
require 'test/unit'
require 'mocha/setup'
require 'rexml/document'
class CustomerStats
def initialize
@customers = []
end
@biwakonbu
biwakonbu / xor_exchange.c
Created January 12, 2013 01:12
XOR 交換と一時変数を使った swap の速度比較用プログラム。
#include <stdio.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
#define XOR_CHANGE(a,b) { \
if(a != b) { \
a ^= b; \
b ^= a; \
@biwakonbu
biwakonbu / example_1.c
Created January 20, 2013 18:51
C 言語に於けるグローバル変数の定義方法 ref: http://qiita.com/items/e485ca8b202a7b1f7851
#define GLOBAL_VALIABLE_DEFINE
#include "global.h"
@biwakonbu
biwakonbu / quicksort.c
Last active March 26, 2018 16:51
quicksort with c language.
#include <stdio.h>
#include <stdlib.h>
#define STRINGS_SIZE 32
#define DATA_SIZE 10000000
#define SWAP(a,b) {int temp; temp = a; a = b; b = temp;}
void quick_sort(int *, int);
void quick_sort_sub(int *, int, int);
@biwakonbu
biwakonbu / get_tokei_file.rb
Created January 21, 2013 00:37
某女性時計の画像ダウンロードスクリプト ref: http://qiita.com/items/6940fa137d261aa1be7c
require 'open-uri'
def to_date(date)
if date.to_s.length < 2
"0" + date.to_s
else
date.to_s
end
end
@biwakonbu
biwakonbu / window-create-SWT.java
Last active December 11, 2015 19:38
Java で Window 生成する方法(というかソース) ref: http://qiita.com/items/f37fe7f29d763951e51a
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorldSWT {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
@biwakonbu
biwakonbu / ranum.rb
Last active August 26, 2016 17:44
random 数の生成コマンド ref: http://qiita.com/biwakonbu/items/ca1da25b530bb5824856
# /usr/bin/ruby
1.step(ARGV[0].to_i, 1) do |i|
puts rand(ARGV[1].to_i)
end
#include <stdio.h>
#define DATA_SIZE 100000
#define STRINGS_SIZE 32
#define SWAP(a, b) { \
int tmp; \
tmp = a; \
a = b; \
b = tmp; \
}
@biwakonbu
biwakonbu / check_oauth2.rb
Last active August 29, 2015 14:01
OAuth 2 による GitHub 連携認証用 URI の生成サンプル
require 'oauth2'
client_id = 'CLIENT_ID'
client_secret = 'CLIENT_SECRET'
oauth = OAuth2::Client.new(client_id,
client_secret,
{
site: 'https://api.github.com',
authorize_url: 'https://github.com/login/oauth/authorize',