Skip to content

Instantly share code, notes, and snippets.

View geckofu's full-sized avatar

Gecko Fu geckofu

View GitHub Profile
@geckofu
geckofu / gist:654d817de71892ac3c1636343cde33fe
Last active November 27, 2020 15:39
My uBlock Filters
dilidili.name
acg456.com
www.fzdm.com
nicotv.me
www.nicotv.me##.slide.ff-row.row
! 7/13/2020 https://www.bilibili.com
www.bilibili.com##.bilibili-player-video-danmaku

Keybase proof

I hereby claim:

  • I am geckofu on github.
  • I am gallant_matz (https://keybase.io/gallant_matz) on keybase.
  • I have a public key ASCCPDu82JdZ4y4hPiRJkEgDSWQFGltE49uutHBn7yckmgo

To claim this, I am signing this object:

@geckofu
geckofu / gist:06c26209ae25bee2982840a7d00c9298
Last active November 22, 2019 05:51
cVim configuration
let mapleader = ';'
set autoupdategist
let scrollstep = 100
let blacklists = ["https://mail.google.com/*", "https://ecs.console.aliyun.com/*", "https://twitter.com/*", "https://www.binance.com/*", "https://sentry.io/*", "https://www.douban.com/*", "https://photos.google.com/*", "https://dev.to/*", "https://lao.sb/*", "https://ace.c9.io/*", "https://feedly.com/*", "https://theplanttokyo.atlassian.net"]
@geckofu
geckofu / enhanced-fetch-api.js
Last active August 25, 2017 11:52
Explicit error handling, timeoutable `fetch()`
// Inspired by davej's gist: https://gist.github.com/davej/728b20518632d97eef1e5a13bf0d05c7
// Accepts same arguments as `fetch()`, then returns a promise
// - Reject if response is not ok (4xx, 5xx)
// - Reject if timeout (by default, a fetch won't timeout)
const enhancedFetch = (...args) => {
const whinyFetch = fetch(...args)
.then((response) => {
if (response.ok) {
return response
@geckofu
geckofu / iterator_pattern.rb
Last active August 29, 2015 14:19
iterator pattern
################# Enumerable Mixin
class Account
attr_accessor :name, :balance
def initialize(name, balance)
@name = name
@balance = balance
end
def <=>(other)
@geckofu
geckofu / composite_pattern.rb
Last active August 29, 2015 14:16
composite pattern
# use the Composite pattern when you are trying to build a hierarchy
# three moving parts: base class/interface (component), leaf classes, composite classes
class Task
attr_reader :name
def initialize(name)
@name = name
end
@geckofu
geckofu / strategy_pattern.rb
Last active August 29, 2015 14:16
strategy pattern
# the user of the strategy -- called the context class --
# can treat the strategies like interchangeable parts.
# In addition, because the strategy pattern is based on composition
# and delegation, rather than on inheritance, it is easy to switch strategies
# at runtime.
class PlainTextFormatter
def output_report(title, text)
puts("**** #{title} ****")
@geckofu
geckofu / template_method_pattern.rb
Created February 24, 2015 13:22
Template Method Pattern
# Template Method Pattern relies on inheritance
class Report
def initialize
@title = 'Monthly Report'
@text = ['Things are going', 'really, really well.']
end
def output_report
output_start
output_head
@geckofu
geckofu / composition_and_delegation.rb
Last active August 29, 2015 14:15
design patterns in ruby
# inherite way:
# - engine details are probably exposed to the Car
# - hard for engine-less vehicle's adaption
class Vehicle
def start_engine
end
def stop_engine
end
end