Skip to content

Instantly share code, notes, and snippets.

View update-allenv.py
#!/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 Dec 6, 2018
逆ポーランド記法の練習
View rpn.rb
require 'set'
class RPN
def initialize(exp)
@exp = exp.split(/\s+/)
@stack = []
@operators = Set['+', '-', '*', '/', '%'].freeze
end
def eval
@ser1zw
ser1zw / priorityqueue.rb
Created Nov 16, 2018
Priority Queueの練習
View priorityqueue.rb
# 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 Nov 12, 2018
ヒープソートの練習
View heapsort.rb
# ヒープソートの練習
#
# 参考
# - 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])
View Get_Started_with_Eager_Execution.py
# 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 Jul 18, 2015
Bluemix Watson の Speech To Text API をローカルから使用するサンプル
View watson-speech-to-text.rb
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 Jun 23, 2015
リンクリストの練習
View LinkedList.c
// -*- mode: c; coding: utf-8 -*-
/*
* リンクリストの練習
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* リストの要素型
@ser1zw
ser1zw / send-message.ps1
Created May 25, 2015
E-mail tool in PowerShell
View send-message.ps1
################################################################################
# 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
INSERT query generator for Oracle
View insert_sql_generator.rb
#
# 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'
View prime-factorization-test.lisp
;; -*- mode: lisp; coding: utf-8 -*-
;; --------------------------------------------------------------------------------
;; 問題:
;;  210 = 2×3×5×7
;; 整数を素因数分解したとき、上のような、元の数の「各桁の和」と
;; 素因数分解した「×の個数」が等しくなる整数を求めるプログラムを
;; 書いてください
;; https://codeiq.jp/ace/joboffer_apli/q1237?dspn=RHuDm3lalVgWKiDtlJz7oTn0beWgAuPxV4vDWcWiBCBKvMnuVBMQcJTdHL8vKXSh
;; --------------------------------------------------------------------------------