Skip to content

Instantly share code, notes, and snippets.

View kyontan's full-sized avatar
♨️

kyontan kyontan

♨️
View GitHub Profile
#!/usr/bin/env ruby
require 'capybara'
# require 'capybara/poltergeist'
require "selenium-webdriver"
Capybara.current_driver = :selenium
url = "http://qrlogic.pwn.seccon.jp:10080/game/"
@kyontan
kyontan / Helper.cpp
Last active October 31, 2015 02:40
Arduino で ADXL345 (加速度センサー) と OSL641501 (8x8 ドットマトリックスLED) を使った教材用のラッパーライブラリ
#include <Wire.h> // I2C用
#include <ADXL345.h> // 加速度センサ用
#include <TimerOne.h> //timer1 //timer0はdelay、timer2はtoneで使われてる(´・ω・`)
// #include "dtmtdatas.h"
#include "Helper.h"
// val の値を min と max の値に収まるようにする
// val < min :=> min
// min <= val <= max :=> val
@kyontan
kyontan / rpn.rb
Last active August 29, 2015 14:26
逆ポーランド記法で計算するやつ
#!/usr/bin/env ruby
class Array
alias_method :top, :last
end
def eval_rpn(stack)
commands = {
"+": ->x, y { x + y },
"-": ->x, y { x - y },
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Test
{
public static void main (String[] args) throws java.lang.Exception
@kyontan
kyontan / gist:5ac417f87a9be340c2c2
Created March 25, 2015 09:26
AudioQueueを使ってPCMを再生
NSData *recordedPcm;
AVAudioPlayer *player;
AudioQueueRef audioQueue;
AudioQueueBufferRef audioQueueBuffers;
// Queue/Buffer への追加は playPCM での1回しかしないため、コールバックでは何もしない (必要があればここで追加)
static void AQOutputCallback(void *userData, AudioQueueRef audioQueueRef, AudioQueueBufferRef audioQueueBufferRef) {
return;
}
@kyontan
kyontan / buttons.css
Created August 24, 2014 12:59
CSS3 Buttons
input.button, button.button {
height: 34px;
cursor: pointer;
-webkit-appearance: none;
}
.button {
background-color: #EEE;
display: inline-block;
vertical-align: middle;
@kyontan
kyontan / slice_bit_string.c
Last active August 29, 2015 14:05
Slice bit string
#include<stdio.h>
#include<stdbool.h>
void print_bit_string(unsigned char n) {
for(int i=7; 0<=i; i--) {
printf("%d", (n >> i) & 1);
}
}
unsigned char slice_bit_string(unsigned char data[], int data_len, char slice_unit, int idx) {
// Rounding methods implementation in C
// 2014 kyontan No Rights Reserved (CC0)
// https://creativecommons.org/publicdomain/zero/1.0/deed.ja
/* Supporting methods
- ceil (round up)
- floor (round down)
- truncate (round towards zero)
- round off (round half up)
- JIS Z8401:1999 round (round to the nearest even)
@kyontan
kyontan / README.md
Last active August 29, 2015 13:56
Refrection and Refraction Simulator using Xwindow

反射・屈折のシミュレータ

ソースの質に関してはお察しください

コンパイル方法

  • Mac ( XQuartz が必要です。 ここからダウンロードしてください。)
clang++ reflection_reflaction.cpp -std=c++11 -I /usr/X11R6/include -L /usr/X11R6/lib -l X11
@kyontan
kyontan / gist:8616126
Last active January 4, 2016 11:39
clearfix micro
.cf:after {
content: "";
display: table;
clear: both;
}