Skip to content

Instantly share code, notes, and snippets.

View momocow's full-sized avatar
🍭
Feed me plz

牛牛 momocow

🍭
Feed me plz
View GitHub Profile
@momocow
momocow / bimap.js
Last active January 9, 2020 12:40
Extremely dead simple bidirectional JS objects mimic native objects based on ES6 Proxy.
export const INVERSE = Symbol('inverse')
export function bimap (obj = {}) {
const inverse = Object.entries(obj)
.reduce(
(o, [k, v]) =>
Object.assign(o, { [v]: k }),
{}
)
return new Proxy(obj, {
get (target, prop) {
@momocow
momocow / monkey_patch_h11.py
Last active November 22, 2019 07:55
Monkey patch for h11. Although HTTP uses CRLF as line-breaks in headers, some implementations may still use LF. The script provides CRLF insensitive patch for ReceiveBuffer from h11.
from h11._receivebuffer import ReceiveBuffer
def monkey_patch():
def _maybe_extract_lines_crlf_insensitive(self):
if self._data[self._start : self._start + 2] == b"\r\n":
self._start += 2
return []
elif self._data[self._start : self._start + 1] == b"\n":
self._start += 1
return []
@momocow
momocow / delete_git_submodule.md
Created January 15, 2019 09:50 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@momocow
momocow / variable-named-function.js
Last active November 8, 2018 02:59
[Javascript] How to create a function whose name is from a variable.
function factory (name, fn) {
const scope = {
// wrapper
[name] (...args) {
return fn(...args)
}
}
return scope[name]
}

歌詞

二人で歩いた道
出会いの が また来るね

らした 月の影
やかに 優しくて
この空も この海も ずっと続くって
めての時 私そう思ってた
だけど全ては 消えてゆくのね

@momocow
momocow / gist:7d3669de96209e1d0ef69eca030f5cfd
Created September 10, 2018 13:57 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@momocow
momocow / docker-ce-install.sh
Last active May 24, 2018 07:43
A boiler script for Ubuntu 16.04 (x86_64) to install Docker-ce.
#!/usr/bin/env bash
#####################
# OS: Ubuntu 16.04 #
# H/W: x86_64 #
#####################
# Uninstall old versions
sudo apt-get remove docker docker-engine docker.io
hanayome:
versions:
latest: "1.2.1-alpha"
@momocow
momocow / oginv-bootstrap-iso.css
Last active October 8, 2016 07:26
Customized bootstrap CSS for OGInvoice (List-group, Badges, Collapse)
.bootstrap-iso {
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=50e6927506c1079739fb197624003527)
* Config saved to config.json and https://gist.github.com/50e6927506c1079739fb197624003527
*/
@momocow
momocow / OGInvoice.js
Last active March 6, 2017 17:35
OGame: Trade Tracker
// ==UserScript==
// @name OGInvoice
// @namespace https://github.com/momocow/OGInvoice
// @description OGame: Trade Tracker
// @version 3.0.1
// @author MomoCow
// @supportURL https://github.com/momocow/OGInvoice/issues
// @updateURL https://gist.githubusercontent.com/momocow/bf932d571dcad386193224ecd6e86d5c/raw/OGInvoice.js
// @include https://*.ogame.gameforge.com/game/index.php?*
// @run-at document-end