Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🏴‍☠️

aycabta aycabta

💭
🏴‍☠️
View GitHub Profile
@aycabta
aycabta / _README.md
Last active Mar 31, 2018
RDoc with frozen_string_literal
View _README.md

RDoc with frozen_string_literal

# use Ruby 2.4.3
$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]

# source code of Ruby 2.4.3
$ find . -maxdepth 1 -name "ruby-2.4.3"
./ruby-2.4.3
View my_remover.rb
# Reads unified diff file of CRuby documents between "before" and "after"
# from standard input and removes fixed line number changes
class MyRemover
def initialize
@lines = STDIN.readlines
@pos = 0
puts read_file_sections.flatten.join
end
View doctest.sh
#!/bin/bash
if [ $# -ne 1 ]; then
echo 'Usage: ./doctest.sh username/repository'
exit -1
fi
GITHUB_REPOSITORY_PATH=$1
GITHUB_USERNAME=`echo $GITHUB_REPOSITORY_PATH | sed -e 's/\/.\+$//'`
if [ ! -d original-rdoc ]; then
View Makefile
all: freebsd_pwm
freebsd_pwm: freebsd_pwm.o
clang freebsd_pwm.o -o freebsd_pwm
freebsd_pwm.o: freebsd_pwm.c
clang -c freebsd_pwm.c
clean:
rm freebsd_pwm freebsd_pwm.o
View freebsd_led_blink.c
View Makefile
all: test
test: test.o
gcc bcm2835-1.50/src/bcm2835.o test.o -o test
test.o: test.c
gcc -c -Ibcm2835-1.50/src/ test.c
clean:
rm test test.o
View one_click.rb
require 'mechanize'
EMAIL = ''
PASSWORD = ''
agent = Mechanize.new
agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'
puts 'log in try...'
page = agent.get('https://www.amazon.co.jp/')
signin_path = page.search('script').map(&:text).select { |t| t.include?('nav-flyout-ya-signin') }.first.gsub(/^.+nav-flyout-ya-signin[^>]+><a href='([^']+)'.+$/m, '\1')
View dymo.rb
require 'libusb'
VENDOR_ID = 0x0922
PRODUCT_ID = 0x8003
SCALING_FACTOR = 0.1
usb_context = LIBUSB::Context.new
device = usb_context.devices(idVendor: VENDOR_ID, idProduct: PRODUCT_ID).first
unless device
puts 'Device not found'
View gemoji_test.rb
require 'open-uri'
require 'json'
open('https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json') do |f|
json = JSON.parse(f.read)
puts json.size # => 1338
end
View .lvimrc
" for CRuby
if &filetype=='c'
setlocal noexpandtab tabstop=8 shiftwidth=4 softtabstop=4
endif