Skip to content

Instantly share code, notes, and snippets.

View kogecoo's full-sized avatar

kogecoo kogecoo

View GitHub Profile
@kogecoo
kogecoo / pso.py
Created November 2, 2017 18:02
Experimental implementation of simple Particle Swarm Optimization algorithm
import numpy as np
from numpy.random import rand, uniform
# reference: https://en.wikipedia.org/wiki/Particle_swarm_optimization#Parameter_selection
ob = lambda x: (np.power(x, 4.0) - x * x * 16 + x * 5).sum() / 2.0 # Styblinski-Tang function
lims = np.array([[-5.0, 4.0], [-3.0, 4.0]])
loop = 100
@kogecoo
kogecoo / staffroll.py
Created January 15, 2016 05:16
Generating staff roll movie (images) from vertically long image(s)
#!/usr/bin/env python
# -*- coding: utf-8 -*
from PIL import Image
import argparse
import os
def make(image_names, target_height, seconds, imgs_per_seconds, outfile_prefix, outdir):
try:
if not os.path.exists(outdir):
@kogecoo
kogecoo / tinyaozora.py
Created October 2, 2015 17:49
super tiny Aozora Bunko html2text converter
#!/usr/bin/env python
# -*- coding: utf-8 -*
from bs4 import BeautifulSoup as BS
import requests
import argparse
def convert(url, out, midashi, need_title, need_author):
@kogecoo
kogecoo / syncha0.3.1_patch
Created December 15, 2014 07:52
A patch for SynCha 0.3.1 to be perl-5.14 or later compatible.
diff --git src/event-noun.pl src/event-noun.pl
index 48c431f..3b8ae3b 100644
--- src/event-noun.pl
+++ src/event-noun.pl
@@ -32,22 +32,22 @@ sub new {
# (skip now. consider later)
# argument-identification model (in the same bunsetsul)
- for my $TYPE qw(ga o ni) {
+ for my $TYPE (qw(ga o ni)) {