Skip to content

Instantly share code, notes, and snippets.

@akkijp
akkijp / main.c
Last active April 4, 2016 03:23
挿入ソート、バブルソート、クイックソートの各種アルゴリズムソースコード(計測用main関数も付属)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void swap(int *p_from, int *p_to) {
int tmp;
tmp = *p_from;
*p_from = *p_to;
*p_to = tmp;
}
@akkijp
akkijp / mservice.zsh
Created October 17, 2015 21:03
macからlinuxのサービスコマンドみたいに扱えるようにした
_mservice_nginx() {
case $1 in
"start" ) nginx -t && nginx;;
"stop" ) nginx -s stop;;
"reload" ) nginx -s reload;;
"restart" ) nginx -t && nginx -s stop && nginx;;
"check" ) nginx -t;;
* ) echo "Usage: mservice nginx {start|stop|reload|restart|check}" 1>&2;;
esac
}
@akkijp
akkijp / .zshrc
Last active October 25, 2015 17:13
自分の oh-my-zsh 用の設定ファイル
# Path to your oh-my-zsh installation.
export ZSH=/Users/k4zzk/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="lukerandall"
# Uncomment the following line to use case-sensitive completion.
@akkijp
akkijp / main.go
Created October 17, 2015 22:57
go言語の中でc言語を利用する
package main
/*
#include <stdlib.h>
typedef int (*compare_t)(const void* a, const void* b);
int compareInts(int*, int*);
static void qsortInts(int* data, int len) {
qsort(data, len, sizeof(int), (compare_t)compareInts);
}
@akkijp
akkijp / main.c
Created October 20, 2015 01:27
自プロセスの環境変数を全て表示する
#include <stdio.h>
#include <stdlib.h>
extern char **environ;
int main(void){
char **p;
for(p=environ; *p; p++){
printf("%s\n", *p);
@akkijp
akkijp / main.c
Last active October 20, 2015 01:48
カレントワーキングディレクトリを表示する
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#define INIT_BUFSIZE 1024
/*
* return "/home/k4zzk/Desktop"
*/
@akkijp
akkijp / main.c
Created October 20, 2015 02:19
自力で、HTTPサーバーをc言語で1から作る!
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#include <string.h>
typedef void (*sighandler_t)(int);
/*
* 標準エラー出力にフォーマットしたものを出力して、プロセスを終了する。
* @vars (char *fmt, ...)
@akkijp
akkijp / TOPIX100_list.tsv
Created October 20, 2015 02:23 — forked from YoshihitoAso/TOPIX100_list.tsv
TOPIX100の銘柄リスト(TSV)
stock_code name
1605 国際石油開発帝石
1878 大東建託
1925 大和ハウス工業
1928 積水ハウス
1963 日揮
2502 アサヒグループホールディングス
2503 キリンホールディングス
2802 味の素
2914 日本たばこ産業
@akkijp
akkijp / main.rb
Last active October 20, 2015 07:50
twitter で指定ユーザーのツイートを過去200件まで自動取得する。取得したデータは、sqlight3にて保存される。
require 'rubygems'
require 'sqlite3'
require 'twitter'
require 'pp'
# ログイン
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
@akkijp
akkijp / main.go
Last active October 21, 2015 10:03
tmp golang test
package main
import "fmt"
func f1() (int, string, float32) {
return 0, "xyz", 3.14
}
func f2(a int, b string, c interface{}) {
fmt.Println(a, b, c)