Skip to content

Instantly share code, notes, and snippets.

View falood's full-sized avatar

Falood Hao falood

  • ╮(╯_╰)╭
  • Osaka, Japan
View GitHub Profile
require 'grape/middleware/stack'
module Grape
# An Endpoint is the proxy scope in which all routing
# blocks are executed. In other words, any methods
# on the instance level of this class may be called
# from inside a `get`, `post`, etc.
class Endpoint
include Grape::DSL::Settings
include Grape::DSL::InsideRoute
@falood
falood / Exception Step 1.md
Last active March 11, 2017 16:45
Macro in maru step by step: Exception
def func do
  raise "xxx"
end

rescue_from MatchError do
  IO.puts "error"
end
@falood
falood / Params Step 1.md
Last active March 11, 2017 16:08
Macro in maru step by step: Parameters
params do
  requires :a
  optional :b
end

compile to

@falood
falood / Router Step 1.md
Last active March 11, 2017 15:47
Macro in maru step by step: Router
get :path do
  IO.puts 1
end

compile to

def route(%Plug.Conn{method: "GET", path_info: ["path"]}, _) do
#-*- coding: utf-8 -*-
set = {}
data = [(100, 200), (100, 300), (100, 400), (100, 500), (400, 600), (700, 500), (800, 800)]
def root(n):
global set
if n not in set:
@falood
falood / es.py
Last active August 29, 2015 14:00
# -*- coding: utf-8 -*-
from tornado.options import options
from pyes import (
ES,
Search,
FilteredQuery,
ANDFilter,
TermFilter,
ORFilter,
@falood
falood / gist:7545069
Last active December 28, 2015 18:39
merge two Module's function
defmodule M1 do
def fun(:arg1) do
IO.puts "arg1"
end
end
defmodule M2 do
def fun(:arg2) do
IO.puts "arg2"
end
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
# for Mountain Lion 10.8.3 - 10.8.5
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|