Skip to content

Instantly share code, notes, and snippets.

@leesei
leesei / fix
Created March 1, 2016 08:55
hexo #1788
==================== fix ====================
config.root = "/";
url_for("#") ==> "#"
url_for("#top") ==> "#top"
url_for("http://www.google.com") ==> "http://www.google.com"
url_for("https://www.google.com") ==> "https://www.google.com"
url_for("//www.google.com") ==> "//www.google.com"
@leesei
leesei / hexo-dev.sh
Last active February 25, 2016 17:29
Setup hexo development environment
mkdir hexo-dev
cd hexo-dev
git@github.com:hexojs/hexo.git
cd hexo; npm i
# can `npm run test` here
cd ..
git clone git@github.com:leesei/hexo-genstubs.git
cd hexo-genstubs; npm i
@leesei
leesei / Download 配信
Last active January 27, 2018 14:52
HMX
入Game Title 去Download 頁面:
- 配信,event予告
- Quest
+ Event Quest
+ Challenge Quest
- 貓
- Item Bag (Download 後去房間或集會所準備區Room Service 隻貓領取)
- DL 特典
@leesei
leesei / port_info.c
Last active September 29, 2015 05:58
code fragment for getting info of a dynamically bound port #c #socket
// code fragment for getting info of a dynamically bound port
struct sockaddr_in s_in;
int len = sizeof(s_in);
s_in.sin_family = AF_INET;
s_in.sin_addr.s_addr = INADDR_ANY;
s_in.sin_port = htons(0);
//SOCKET s = socket(AF_INET, SOCK_STREAM, 0); // TCP
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0); // UDP
bind(s, (SOCKADDR*) &s_in, sizeof(s_in));
getsockname(s, (SOCKADDR*) &s_in, &len);
@leesei
leesei / cLogger.js
Created August 20, 2015 16:14
Logger to Browser console (with colors)
// http://charlesbking.com/power_of_es6/#/21
//create a logger facade
class Logger {
//constructor
constructor (type = "Info") {
this.type = type;
}
//static methods
static create(type) {
@leesei
leesei / Google.desktop
Created July 19, 2015 06:42
Internet shortcuts
[Desktop Entry]
Encoding=UTF-8
Name=Link to Google
Type=Link
URL=https://www.google.com.hk/#q=google
Icon=text-html
@leesei
leesei / countAngularBindings.js
Created January 5, 2015 07:20
#snippets #js #angularjs
function getScopes(root) {
var scopes = [];
function traverse(scope) {
scopes.push(scope);
if (scope.$$nextSibling)
traverse(scope.$$nextSibling);
if (scope.$$childHead)
traverse(scope.$$childHead);
}
traverse(root);
@leesei
leesei / colors.source
Created November 28, 2014 09:05
#bash #color-source Color macro for BASH
# prompt color and format variables
# A color init string consists of one or more of the following numeric codes:
# * Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# * Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# * Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
# * Extended color codes for terminals that support more than 16 colors:
@leesei
leesei / evil_ctor.cpp
Created May 13, 2014 09:02
#c #evil-c-tor #c-tor
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
// An older, deprecated, politically incorrect name for the above.
// NOTE: The usage of this macro was baned from our code base, but some
// third_party libraries are yet using it.
// TODO(tfarina): Figure out how to fix the usage of this macro in the