Skip to content

Instantly share code, notes, and snippets.

@ser1zw
ser1zw / crawler.sh
Last active December 11, 2023 02:05
#!/bin/bash
set -euo pipefail
WAIT_SECONDS=1
USER_AGENT='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0'
logger_info() {
echo "$(LANG=C date --rfc-3339=seconds) [INFO] ${1}"
}
@ser1zw
ser1zw / update-allenv.py
Last active December 11, 2023 00:53
update-allenv
#!/usr/bin/env python
import os
import subprocess
HOMEDIR = os.getenv('HOME')
GIT_COMMAND = 'git pull --rebase origin master'
git_clone_dirs = ['.rbenv', '.rbenv/plugins/ruby-build', '.pyenv']
brew_commands = ['perlbrew self-upgrade', 'perlbrew -f install-cpanm', 'nodebrew selfupdate']
@ser1zw
ser1zw / rpn.rb
Created December 6, 2018 09:29
逆ポーランド記法の練習
require 'set'
class RPN
def initialize(exp)
@exp = exp.split(/\s+/)
@stack = []
@operators = Set['+', '-', '*', '/', '%'].freeze
end
def eval
@ser1zw
ser1zw / priorityqueue.rb
Created November 16, 2018 08:02
Priority Queueの練習
# Priority Queueの練習
#
# 参考
# - https://ufcpp.net/study/algorithm/col_heap.html
class PriorityQueue
attr_reader :data, :test_function
def initialize(test_function = ->(a, b) { a <=> b })
@data = []
@ser1zw
ser1zw / heapsort.rb
Created November 12, 2018 11:32
ヒープソートの練習
# ヒープソートの練習
#
# 参考
# - https://ufcpp.net/study/algorithm/col_heap.html
# - https://ufcpp.net/study/algorithm/sort_heap.html
def make_heap(array, last_index)
while (last_index > 0)
parent = ((last_index - 1) / 2).floor
break unless (array[last_index] > array[parent])
# https://www.tensorflow.org/get_started/eager
# Configure imports and eager execution
from __future__ import absolute_import, division, print_function
import os
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow.contrib.eager as tfe
@ser1zw
ser1zw / watson-speech-to-text.rb
Created July 18, 2015 15:15
Bluemix Watson の Speech To Text API をローカルから使用するサンプル
require 'uri'
require 'net/http'
username = "<YOUR API KEY>"
password = "<PASSWORD>"
file = 'TEST.wav'
response = nil
url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=ja-JP_BroadbandModel'
@ser1zw
ser1zw / LinkedList.c
Created June 23, 2015 05:37
リンクリストの練習
// -*- mode: c; coding: utf-8 -*-
/*
* リンクリストの練習
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* リストの要素型
@ser1zw
ser1zw / send-message.ps1
Created May 25, 2015 09:25
E-mail tool in PowerShell
################################################################################
# E-mail tool in PowerShell
#
# 0. Set execution policy to "RemoteSighed" in PowerShell
# Set-ExecutionPolicy RemoteSigned
#
# 1. Right click this file and select "Run with PowerShell" from context menus.
# Or run the following command in cmd.exe.
# powershell -Sta -File send-message.ps1
#
@ser1zw
ser1zw / insert_sql_generator.rb
Created May 5, 2015 02:04
INSERT query generator for Oracle
#
# INSERT query generator for Oracle
#
# Requirements:
# - Ruby 2.0 or later (https://www.ruby-lang.org/)
# - ruby-oci8 (gem install ruby-oci8)
# - Oracle Database
#
require 'oci8'