This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def iterate(h, depth: 0) | |
| h.each do |k,v| | |
| value = v || k | |
| puts "-" * depth + " " + k | |
| if value.is_a?(Hash) | |
| iterate(value, depth: depth + 1) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun geeknote-create-from-region (beg end) | |
| "Create a note from selected region via Geeknote" | |
| (interactive (if (use-region-p) | |
| (list (region-beginning) (region-end)) | |
| (list nil nil))) | |
| (setq title | |
| (format-time-string "%Y-%m-%d %H:%M:%S" (current-time))) | |
| (setq content | |
| (format "%s" (if (and beg end) | |
| (buffer-substring-no-properties beg end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "pathname" | |
| require "fileutils" | |
| require "date" | |
| BACKUP_PATH = "~/Documents/evernote_backup" | |
| def osascript(script) | |
| system "osascript", *script.split(/\n/).map { |line| ["-e", line] }.flatten |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) + '⌒)' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| kebun=->(s){$><<s[0]+(s[1..-2].chars.shuffle*'')+(!s[1]?'':s[-1])} | |
| # kebun.call('ケンブリッジ') => ケンブッリジ, ケリッブンジ, ケリンブッジ, ケリブンッジ, ケンッリブジ ... | |
| # kebun.call('ケン') => ケン | |
| # kebun.call('ケ') => ケ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| # clas_eval でダミーのアクションを定義する | |
| ApplicationController.class_eval do | |
| def dummy_action | |
| render :nothing | |
| end | |
| end | |
| # Rails.application.routes.draw が呼ばれたときにルートをクリアする動作を無効にする |