Skip to content

Instantly share code, notes, and snippets.

@halka
halka / quicksort.php
Created February 6, 2020 06:45
quicksort
<?
function quicksort(&$arr, $left, $right) {
$pivot = $arr[$left];
$i = $left;
$j = $right;
while(1) {
while($arr[$i] < $pivot) $i++;
while($pivot < $arr[$j]) $j--;
if($i >= $j) break;
@halka
halka / gist:aca1ed08c8ff1ae41cb631a391b8cc3d
Last active November 19, 2019 13:49
I actually looked at your online profile before emailing this...

Dear Halka,

My name is Jack from J-Tech.dev. I am a technical recruiter in Tokyo.

We have some new roles with a great new company owned by 3 of the largest tech companies in the world.

Fastest Growing Engineering Team in Japan Global team with bilingual environment Grew from 0 to 18 million users in less than 2 years Very competitive salaries

Verifying my Blockstack ID is secured with the address 1Fvtaa47N58iUUB1euRw4xeLkoHdVXFEpd https://explorer.blockstack.org/address/1Fvtaa47N58iUUB1euRw4xeLkoHdVXFEpd
@halka
halka / suica_balance.py
Created September 26, 2017 10:33
交通系ICカードの残高を調べる
# -*- coding: UTF-8 -*-
import nfc
import struct
service_code = 0x090f
def on_connect(tag):
sc = nfc.tag.tt3.ServiceCode(service_code >> 6, service_code & 0x3f)
bc = nfc.tag.tt3.BlockCode(0, service=0)
be = struct.unpack('>2B2H4BH4B', bytes(tag.read_without_encryption([sc],[bc])))
@halka
halka / hakodatebus_reaching.js
Last active November 8, 2016 06:50
Node.jsとcheerio-httpcliを使って函館バスの接近情報を取得。函館駅前から亀田支所まで。
var client = require('cheerio-httpcli');
client.setBrowser('chrome');
var domain ='http://hakobus.jp/';
var buses = new Array();
client.fetch(domain+'result.php?in=3&out=155', {}, function(err, $, res) {
$('tr').each(function(idx) {
// var object = $(this).text().match(/約(\d+)分後に到着します|まもなく到着します/);
require 'serialport'
require 'pp'
SerialPort.open('/dev/ttyUSB0', 38400, 8, 1, SerialPort::NONE) do |com|
while true
cc = com.gets
if /^\$GPRMC/ =~ cc
ll = cc.split(',')
lat_h = ll[3][0..1].to_f
long_h = ll[5][0..2].to_f
lat_m = ll[3][2..-1].to_f / 60

Keybase proof

I hereby claim:

  • I am halka on github.
  • I am a_halka (https://keybase.io/a_halka) on keybase.
  • I have a public key whose fingerprint is A93E DF69 6980 6A6B 1395 B5A8 07FD B2DA 0A07 4717

To claim this, I am signing this object:

@halka
halka / metartoimkayac.php
Created November 3, 2013 05:21
noaa.govからmetarを取ってきてim.kayac.com経由でiPhoneにプッシュ配信する例。cronで数分おきに発火させてます。
<?php
//noaaからmetarを取得する
function push_metar($airport,$username){
$airport=strtoupper($airport);
$old_filename="metars/${airport}.old";
$metar=file_get_contents("http://weather.noaa.gov/pub/data/observations/metar/stations/${airport}.TXT");
$old_metar=@file_get_contents($old_filename);
if(strcmp($metar,$old_metar)!=0){
file_put_contents($old_filename, $metar);
$data=array("message"=>$metar);
<?php
class Tsuruhaday
{
function calc_tsuruhaday()
{
//ツルハデーですか
$today=(int)date('d');
$hour=(int)date('H');
$end_of_month=(int)date('t');
$body=null;
@halka
halka / shigotoguide_hakodate.rb
Created July 19, 2013 04:58
求人情報誌をRSSにするスクリプト
# -*- encoding: utf-8 -*-
require 'rubygems'
require 'mechanize'
require 'kconv'
require 'rss/maker'
require 'time'
require 'date'
system("mv ./shigoto.xml archive/"+(Date.today-7).to_s+".xml")
agent = Mechanize.new
agent.get('http://hakodate.sgnavi.com/job_list.php')