Skip to content

Instantly share code, notes, and snippets.

View rrreeeyyy's full-sized avatar
😣
confounded

Ryota Yoshikawa rrreeeyyy

😣
confounded
View GitHub Profile
@rrreeeyyy
rrreeeyyy / rotate?.rb
Last active December 13, 2015 19:48
文字列a, bが回転であるか判定
def rotate?(a, b)
a.length == b.length && (a * 2).include?(b)
end
@rrreeeyyy
rrreeeyyy / is_cycle.rb
Last active December 24, 2015 07:49
配列が循環参照するか検出するメソッド Array#is_cycle?
class Array
def is_cycle?
!!(self.inspect =~ /[^"]\[\.\.\.\][^"]/)
end
end
@rrreeeyyy
rrreeeyyy / mmhiyoko.js
Created November 15, 2013 09:10
mmhiyoko
(!![]+Date())[30]+(!![]+Date())[30]+(+(101))["toString"](21)[1]+([![]]+[][[]])[10]+(+[![]]+[+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])])[10]+(!![]+[]["filter"])[10]+(+(20))["toString"](21)+(!![]+[]["filter"])[10]
@rrreeeyyy
rrreeeyyy / sushi.rb
Last active August 29, 2015 14:00
sushi
def 🍣 (🔪 , 🐠 )
((🐠 =~ / 🐠 | 🐟 | 🐡 /) and (🔪 =~ /🔪|🍴/))?
__method__:
'💩'
end
puts 🍣 '🔪 ', ' 🐡 ' #=> 🍣
@rrreeeyyy
rrreeeyyy / ipvs_http_api.rb
Created June 17, 2014 17:50
IPVS Web API using mruby-ipvs and mruby-simplehttpserver.
services = {}
def body_parser(body)
params = {}
body.split('&').each do |x|
tokens = x.split('=', 2)
if tokens && tokens.size == 2
params[tokens[0]] = HTTP::URL::decode(tokens[1])
end
end
SELECT
e.id AS event_id,
e.name,
s1.id AS schedule_id,
date_format(s1.due_date, '%Y/%m/%d') AS due_date
FROM events e
LEFT JOIN schedules s1
ON e.id = s1.event_id
WHERE s1.id IS NULL
OR s1.id = (
@rrreeeyyy
rrreeeyyy / check_users.go
Last active August 29, 2015 14:05
すごいてきとう
package main
import (
"bufio"
"bytes"
"fmt"
"log"
"os"
"os/exec"
@rrreeeyyy
rrreeeyyy / fizzbuzz.py
Last active August 29, 2015 14:05
FIzzBuzz.py
class FizzBuzz(object):
def __init__(self):
self.Buzz = lambda n: n % 5 == 0
self.Fizz = lambda n: n % 3 == 0
def call(self, n):
return ''.join([k for k, v in self.__dict__.items() if v(n)]) or n
print [FizzBuzz().call(n) for n in range(1, 101)]
@rrreeeyyy
rrreeeyyy / fizzbuzz-generator.py
Last active August 29, 2015 14:05
fizzbuzz-generator.py
class FizzBuzz(object):
def __init__(self):
self.Buzz = lambda n: n % 5 == 0
self.Fizz = lambda n: n % 3 == 0
def call(self, n):
return ''.join([k for k, v in self.__dict__.items() if v(n)]) or n
def generator(self, n, m):
_x = n
@rrreeeyyy
rrreeeyyy / serverspec-sshkey-passphrase.rb
Last active August 29, 2015 14:06
serverspec-sshkey-passphrase
require 'serverspec'
require 'pathname'
require 'net/ssh'
require 'highline/import'
include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
if ENV['ASK_SUDO_PASSWORD']