Skip to content

Instantly share code, notes, and snippets.

@45deg
45deg / Double_Pendulum.elm
Created February 28, 2015 18:09
Double Pendulum
import Signal
import List
import Graphics.Element(Element)
import Graphics.Collage as G
import Time as T
import Color
import Debug
-- model
@45deg
45deg / copyList.rb
Created March 28, 2015 09:04
Copy List from the other account (requires twitter gem, and the twitter lists having the same name. )
require 'twitter'
puts "Open browser and run below script in Console."
puts "$('.app-settings, .access').find('span:not(.heading):lt(2)').map(function(){ return $(this).text() }).toArray().join(':')"
print "Source: "
source_token = gets.chomp.split(':')
print "Target: "
target_token = gets.chomp.split(':')
print "Name: "
name = gets.chomp
@45deg
45deg / gist:c8c7758979907a838578
Last active August 29, 2015 14:20
Trace Monoid について

Trace Monoid について

Monoid

集合S (台集合と呼ぶ) と二項演算 • : S → S を与えられたとき、

  • 任意の a, b, c ∈ S に対して、 (a • b) • c = a • (b • c) [結合法則]
  • ある元 e ∈ S が存在し、任意の a ∈ S に対して e • a = a • e = a [単位元の存在]

を満たすとき モノイド という。 (文脈におおじて二項演算の記号は省略される)

@45deg
45deg / Vagrantfile
Created May 31, 2015 16:27
Vagrant-TeXLive
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision :shell, inline: <<-SHELL
if [ ! -f ~/.installed ]
then
sudo apt-get update
sudo apt-get -y install texlive
sudo apt-get -y install texlive-lang-cjk
sudo apt-get -y install dvipsk-ja
sudo apt-get -y install gv
@45deg
45deg / slide.md
Last active July 12, 2017 06:18
型について

型と証明とプログラム

今回の話

  • プログラムの「型」
  • 論理学の話
  • C言語がわかれば良い
    • Haskell が別れば尚良い
  • お手柔らかに

型とは

@45deg
45deg / userscript.js
Last active August 29, 2015 14:24
Project Euler: Translate Into Japanese (Tampermonkey, Greasemonkey?)
// ==UserScript==
// @name Project Euler: Translate Into Japanese
// @namespace https://gist.github.com/45deg/5551106ee5aa24f39e1d
// @version 0.1
// @description odz.sakura.ne.jp/projecteuler/ から日本語訳を取ってきて追加するスクリプト
// @author zakuro
// @run-at document-end
// @match https://projecteuler.net/problem=*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function(){
var img = new Image();
var c = document.createElement('canvas');document.body.appendChild(c);
var ctx = c.getContext("2d");
img.src = document.images[0].src;
img.onload = function(){ c.width = img.width; c.height=img.height;
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, img.width, img.height).data;
var arr = []; var pos = [];console.log(img.width,img.height); var are = [];
for(var i = 0; i < img.width * img.height; i++){
import random
import string
import sys
import base64
alphabets = string.lowercase + string.uppercase
base64s = set(alphabets + '0123456789' + '+' + '/')
appeared = set()
for i in range(100000):
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <syslog.h>
int main(int argc, char const* argv[])
{
int pid = 0;
int status;
@45deg
45deg / cluster_memo.md
Last active November 24, 2015 17:59
nodejs cluster module memo

Cluster Node.js v5.1.0 Manual & Documentation https://nodejs.org/api/cluster.html

var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
  // Fork workers.
 for (var i = 0; i &lt; numCPUs; i++) {