Skip to content

Instantly share code, notes, and snippets.

View posaunehm's full-sized avatar

Hiroshi Maekawa (a.k.a. Posaune) posaunehm

View GitHub Profile
@posaunehm
posaunehm / gist:4087971
Last active March 26, 2021 19:24
Why OO Sucks by Joe Armstrong
@posaunehm
posaunehm / demo.js
Last active August 23, 2018 14:14
Puppeteer recorder demo
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
const navigationPromise = page.waitForNavigation()
await page.setViewport({ width: 1920, height: 1103 })
await page.goto('https://www.yahoo.co.jp/')
await page.click('form > #srchfield > #srchbd > p > #srchbtn')
await navigationPromise
await page.click('#WS2m > .w:nth-child(1) > .hd > h3 > a')
@posaunehm
posaunehm / gist:3756960
Last active March 25, 2018 12:39
Convert aac to mp3, using ffmpeg on mac
for file in *.m4a; do ffmpeg -qscale 0 -i "$file" "${file%.m4a}.mp3"; done
#128kに変換するなら-abを使う
for file in *.m4a; do ffmpeg -aq 100 -i "$file" "${file%.m4a}.mp3"; done
@posaunehm
posaunehm / ThreePhaseTest.java
Created December 12, 2017 01:42
3フェーズテストの説明
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class ThreePhaseTest {
@Test
void firstTest() {
// Arrange
@posaunehm
posaunehm / gist:8300175
Created January 7, 2014 14:35
call pandoc for JavaScript-Garden
pandoc title.txt intro/index.md object/general.md object/prototype.md object/hasownproperty.md object/forinloop.md function/general.md function/this.md function/closures.md function/arguments.md function/constructors.md function/scopes.md array/general.md array/constructor.md types/equality.md types/typeof.md types/instanceof.md types/casting.md core/eval.md core/undefined.md core/semicolon.md core/delete.md other/timeouts.md -o Javascript-Garden.epub
@posaunehm
posaunehm / twelve_factor.rb
Created January 10, 2014 16:04
http://twelve-factor-ja.herokuapp.com/ をepub/mobi化するスクリプト
# -*- coding: utf-8 -*-
require 'nokogiri'
require 'open-uri'
require "FileUtils"
target = "http://twelve-factor-ja.herokuapp.com"
html = Nokogiri::HTML(open(target))
top_article = html.css(".abstract")
@posaunehm
posaunehm / scraping_coq.rb
Last active January 2, 2016 09:39
プログラミング Coq(http://www.iij-ii.co.jp/lab/techdoc/coqt/coqt1.html) から電子書籍を作ります。 Nokogiriとcalibre コマンドラインツール必須。
require 'nokogiri'
require 'open-uri'
require "FileUtils"
target = "http://www.iij-ii.co.jp/lab/techdoc/coqt/"
html = Nokogiri::HTML(open(target))
url_list = html.css("#home-main ol li a").collect{|a| target + a["href"]}
require 'nokogiri'
require 'open-uri'
require "FileUtils"
html = Nokogiri::HTML(open("http://peta.okechan.net/blog/llvm%E3%81%AB%E3%82%88%E3%82%8B%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E8%A8%80%E8%AA%9E%E3%81%AE%E5%AE%9F%E8%A3%85"))
url_list = html.css("article li a").collect{|a| a["href"]}
article_list = url_list.collect{|url|
article_doc = Nokogiri::HTML(open(url))
@posaunehm
posaunehm / gist:7670851
Created November 27, 2013 04:55
環境変数をPowerShellから設定する。 参考:http://mtgpowershell.blogspot.jp/2011/01/blog-post_14.html 呼び出すメソッドはこれ。 http://msdn.microsoft.com/ja-jp/library/96xafkes.aspx 第3引数は、Machine, User, Processのいずれか。 http://msdn.microsoft.com/ja-jp/library/system.environmentvariabletarget.aspx
[Environment]::SetEnvironmentVariable(“temp”, “D:\temp”, “User”)
@posaunehm
posaunehm / MainWindow.xaml
Last active December 25, 2015 09:09
C# の素晴らしさを語る会 デモ用コード。 Install-Package PropertyChanged.Fody
<Window x:Class="FodyPractice.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox HorizontalAlignment="Left" Height="23" Margin="29,25,0,0" TextWrapping="Wrap" Text="{Binding FirstName}" VerticalAlignment="Top" Width="120"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="199,25,0,0" TextWrapping="Wrap" Text="{Binding FamilyName}" VerticalAlignment="Top" Width="120"/>
<TextBlock FontSize="40" HorizontalAlignment="Left" Margin="29,80,0,0" TextWrapping="Wrap" Text="{Binding DisplayName}" VerticalAlignment="Top" Height="60" Width="290"/>
</Grid>