Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / hexo-dev.sh
Last active February 25, 2016 17:29
Setup hexo development environment
mkdir hexo-dev
cd hexo-dev
[email protected]:hexojs/hexo.git
cd hexo; npm i
# can `npm run test` here
cd ..
git clone [email protected]:leesei/hexo-genstubs.git
cd hexo-genstubs; npm i
@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 / npmpub
Created March 9, 2016 15:50
update version in `package.json`, tag repo, publish to npm and push to remote #node #npm
#!/bin/bash
# update version in `package.json`, tag repo, publish to npm and push to remote
# expects version as input
if [ -z "$1" ]; then
echo "Missing version, use those accepted by 'npm version'"
echo
npm version -h
exit
fi
@leesei
leesei / ttc2ttf.py
Created November 7, 2017 03:57
Python script to convert a true type font collection into separate ttf files. Copy from http://pastebin.com/QXcAtP24
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite “Beer”
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):
@leesei
leesei / tag_errors.js
Last active August 6, 2018 07:42
hexo/test/scripts/hexo/tag_errors.js
'use strict';
var sinon = require('sinon');
describe.only('Tag Errors', () => {
var Hexo = require('../../../lib/hexo');
var hexo = new Hexo(__dirname);
before(() => {
hexo.init().then(() => {
@leesei
leesei / pdf_template.html
Last active September 25, 2019 18:28
weasyprint.test
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<main class="container">
{% for ticket in tickets %}
<section class="ticket">
<div class="content">{{ ticket }}</div>
@leesei
leesei / git-su
Last active March 29, 2020 11:43 — forked from pasela/git-su
git-su - switches user and sshCommand in the current repository
#!/bin/bash
#
# git-su - Git Switch User
# ========================
#
# git-su switches user and sshCommand in the current repository.
#
# USAGE
# -----
#