Skip to content

Instantly share code, notes, and snippets.

@5t111111
5t111111 / 1_1.py
Last active July 10, 2016 00:01
Doing Math with Python Chapter 1 programming challenge
def odd_or_even(x):
if x % 2 == 0:
return 'even'
else:
return 'odd'
def next_nine_number(x):
for i in range(0, 9):
x = x + 2
@5t111111
5t111111 / _info
Created June 28, 2016 14:50
Re:dash with Docker (Use MySQL as Data Source)
https://github.com/getredash/redash/blob/0456caf798cbdb0de934d7d223861211df7186a3/docker-compose-example.yml
https://github.com/getredash/redash/blob/0456caf798cbdb0de934d7d223861211df7186a3/setup/docker/create_database.sh
FROM ruby:2.3.1
MAINTAINER Hirofumi Wakasugi <[email protected]>
RUN apt-get update && apt-get install -qq -y build-essential nodejs --fix-missing --no-install-recommends
ENV INSTALL_PATH /kawaiichan
RUN mkdir $INSTALL_PATH
WORKDIR $INSTALL_PATH
@5t111111
5t111111 / application_controller_test.rb
Created April 5, 2016 07:15
ApplicationController で定義されている before_action の動作テストと、それが実際に呼ばれていることのテストについて
require 'test_helper'
# clas_eval でダミーのアクションを定義する
ApplicationController.class_eval do
def dummy_action
render :nothing
end
end
# Rails.application.routes.draw が呼ばれたときにルートをクリアする動作を無効にする
@5t111111
5t111111 / cabmridge.rb
Last active February 16, 2016 09:39
ケブンリッジにシャッフルのテストを
require 'strscan'
module StringWithCabmridge
refine String do
def cabmridge_word
self[0] + self[1..-2].chars.shuffle.*('') + (self[1] ? self[-1] : '')
end
def cabmridge_whole_text
buffer = StringScanner.new(self)
@5t111111
5t111111 / kebun.rb
Last active February 15, 2016 12:57
ケブンリッジ関数 (単語だけに対応です…)
kebun=->(s){$><<s[0]+(s[1..-2].chars.shuffle*'')+(!s[1]?'':s[-1])}
# kebun.call('ケンブリッジ') => ケンブッリジ, ケリッブンジ, ケリンブッジ, ケリブンッジ, ケンッリブジ ...
# kebun.call('ケン') => ケン
# kebun.call('ケ') => ケ
@5t111111
5t111111 / Makefile
Created December 17, 2015 01:46 — forked from notozeki/Makefile
An example Ruby extension written in Crystal
CRYSTAL = crystal
UNAME = "$(shell uname -ms)"
LIBRARY_PATH = $(shell brew --prefix crystal-lang)/embedded/lib
LIBS = -levent -lpcl -lpcre -lgc -lpthread
LDFLAGS = -Wl,-undefined,dynamic_lookup
TARGET = crystal_example_ext.bundle
$(TARGET): crystal_example_ext.o
$(CC) -bundle -L$(LIBRARY_PATH) -o $@ $^ $(LIBS) $(LDFLAGS)
@5t111111
5t111111 / pre-push
Last active November 30, 2015 01:14
An example pre-push hook script to prevent direct pushing to master excluding the following cases -> All commit logs for the commits to be pushed start with "[ALLOW_MASTER]"
#!/bin/bash
# An example hook script to prevent direct pushing to master excluding the following cases
# - All commit logs for the commits to be pushed start with "[ALLOW_MASTER]"
# e.g [ALLOW_MASTER] Fix something
z40=0000000000000000000000000000000000000000
while read local_ref local_sha1 remote_ref remote_sha1
do
@5t111111
5t111111 / pre-push
Last active October 13, 2016 06:32
git pre-push hook to prevent direct pushing to master
#!/bin/sh
# An example hook script to prevent direct pushing to master
while read local_ref local_sha1 remote_ref remote_sha1
do
# If you also want to prevent direct pushing to branches in addition to master branch,
# just copy and paste the below and replace "master" with the branch name you desire.
# ==========> Copy & paste START
if [[ "${remote_ref##refs/heads/}" = "master" ]]; then
@5t111111
5t111111 / doala.rb
Last active August 29, 2015 14:26
本当にひどいコードです。
class Doala
def move(number)
hand = -> (n) { n % 2 == 0 ? '⌒' : 'ー' }
f = Fiber.new do
n = 0
reverse = false
line_length = 50
loop do
line = "\r" + " " * n + '(' + hand.call(n) + '(´・△・`)' + hand.call(n) + '⌒)'