Skip to content

Instantly share code, notes, and snippets.

View hangingman's full-sized avatar
🦙

hangedman hangingman

🦙
  • Kanagawa, Japan
  • 20:43 (UTC +09:00)
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pyspark.sql import SparkSession
from pyspark import SparkContext
from pyspark.sql import Row
from pprint import pprint
import sys
reload(sys)
@hangingman
hangingman / gen-testcases.sh
Last active August 30, 2018 13:39
自分で書いた01ナップサック(D言語)とC++(https://beta.atcoder.jp/contests/abc032/submissions/607063)を比較
#!/bin/bash
MID_CASE=in-gen-mid.txt
SIGMA_V_CASE=in-gen-sigma-v.txt
SIGMA_W_CASE=in-gen-sigma-w.txt
# meet in the mid
# 1 <= N <= 30
# 1 <= W <= 10^9
N1=$((RANDOM%30))
@hangingman
hangingman / pmd.clj
Last active May 23, 2018 13:41
Clojure + smee.binary で PMDファイルをパース
(ns mmd-clj.pmd
(:use
[org.clojars.smee.binary.core]))
(def pmd-header
;; ヘッダファイル
(compile-codec
(ordered-map
:header
(ordered-map
@hangingman
hangingman / Vagrantfile
Last active March 20, 2018 03:52
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "mvbcoding/awslinux"
config.vm.box_version = "2017.03.0.20170401"
config.vm.network "forwarded_port", guest: 80, host: 80
# deploy codes
config.vm.provision "shell", privileged: false, inline: <<-SHELL
whoami #=> vagrant
echo $HOME #=> /home/vagrant
@hangingman
hangingman / Dockerfile
Created December 6, 2017 09:11
Airflow使いたい
FROM amazonlinux
# set yum repository mirror for jp
RUN yum -y install yum-plugin-fastestmirror
RUN sed -ri 's/#include_only=.nl,.de,.uk,.ie/include_only=.jp/g' /etc/yum/pluginconf.d/fastestmirror.conf
# install packages
RUN yum -y update
RUN yum -y install vim
RUN yum -y install passwd openssh openssh-server openssh-clients sudo iproute
@hangingman
hangingman / C.rb
Created November 12, 2017 07:28
AtCoder C - コイン
lines = <<'EOS'
3
2
4
8
EOS
#lines = $stdin.read
array = lines.split("\n")
<!DOCTYPE html>
<head>
<title>ビルド状況</title>
<style type="text/css">
body
{
margin: 0px;
padding: 15px;
}
@hangingman
hangingman / funcs.sql
Last active August 24, 2017 14:52
MySQLの関数作成
--
-- 単純な文字列結合の関数 String#join() 相当?
--
DROP FUNCTION IF EXISTS concat_as_ymd;
CREATE FUNCTION concat_as_ymd(ymd VARCHAR(8)) RETURNS VARCHAR(10) DETERMINISTIC
BEGIN
RETURN CONCAT_WS('-', SUBSTRING(ymd, 1, 4), SUBSTRING(ymd, 5, 2), SUBSTRING(ymd, 7, 2));
END;
@hangingman
hangingman / os.lds
Created November 23, 2016 06:17
object から .hrb 形式変換のためのリンカスクリプト(from: http://vanya.jp.net/os/haribote.html)
OUTPUT_FORMAT("binary");
SECTIONS
{
.head 0x0 : {
LONG(64 * 1024) /* 0 : stack+.data+heap の大きさ(4KBの倍数) */
LONG(0x69726148) /* 4 : シグネチャ "Hari" */
LONG(0) /* 8 : mmarea の大きさ(4KBの倍数) */
LONG(0x310000) /* 12 : スタック初期値&.data転送先 */
LONG(SIZEOF(.data)) /* 16 : .dataサイズ */
@hangingman
hangingman / bootpack.ld
Created November 23, 2016 06:06
object から .bim 形式変換のためのリンカスクリプト(from: http://hrb.osask.jp/wiki/?tools/obj2bim)
SECTIONS {
/*
* .bimのヘッダ
*/
.head 0x0 :
{
/*
* GNU ld version 2.14.90.0.7 20031029では、以下は、なぜか'+ 0'が必要。
* LOADADDR(.text)
* ADDR(.text)