Skip to content

Instantly share code, notes, and snippets.

View dulao5's full-sized avatar

Du Zhigang (ト シゴウ) dulao5

View GitHub Profile
@jarifibrahim
jarifibrahim / cleaner.go
Last active February 9, 2024 16:37
Database cleanup hook using GORM
// DeleteCreatedEntities sets up GORM `onCreate` hook and return a function that can be deferred to
// remove all the entities created after the hook was set up
// You can use it as
//
// func TestSomething(t *testing.T){
// db, _ := gorm.Open(...)
//
// cleaner := DeleteCreatedEntities(db)
// defer cleaner()
//
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@toolness
toolness / sshify.py
Created March 14, 2017 20:31
A script to run a command within an ssh-agent session.
#! /usr/bin/env python3
"""
This utility will execute the given command (by default, your shell)
in a subshell, with an ssh-agent process running and your
private key added to it. When the subshell exits, the ssh-agent
process is killed.
"""
# This code was written by Atul Varma in February 2017. It requires
@hashrock
hashrock / diag.md
Last active February 26, 2024 05:51
作図系ツール・ライブラリまとめ

シーケンス図とかフローチャートをしごとで描画することになった場合、 テキストから生成できたら楽なので、それ系のツールまとめ

GraphViz

http://www.graphviz.org/

  • C製
  • Doxygen, Moinmoinなどと連携可能
  • ブロック図、クラス図、ネットワーク図など
@dulao5
dulao5 / Readme.md
Last active November 2, 2017 14:02
make-contents.md

Markdownドキュメントの目次を自動的に作るツールです。

  • main.jsのJavaScriptをコピーして、ここにペストしてください。
  • Bookmarklet nameMD Contentsを入力してください。
  • Compressボッタンを押してください。
  • 画面下の辺のMD Contentsの__リンク__を __ドロップ__して、ブラウザのBookmark Tools Barに移動してください。
  • 使いたい際に、ブラウザでMarkdownのページを開いて、Bookmark Tools BarMD Contentsをクリックしてください。
    • ポップアップの内容は目次です。すべてを選んで、Wikiにコピペしてください。
@voluntas
voluntas / webrtc_stack.rst
Last active June 4, 2023 13:23
WebRTC スタックコトハジメ

WebRTC スタックコトハジメ

WebRTC スタックについて

作:@voluntas
バージョン:0.0.3
url:https://voluntas.github.io/
@ngyuki
ngyuki / uopz-di-classes.php
Last active March 6, 2018 12:29
Example of uopz di experimental
<?php
interface SayInterface
{
public function say();
}
class Ore implements SayInterface
{
public function say()
{
@deltheil
deltheil / libcurl_dns.md
Last active March 15, 2019 00:54
libcurl options to control DNS lookup (cache, timeout, resolving time, etc). The short URL for this page is: http://git.io/libcurl-dns.

Easy handle interface

Options

Info

@rinh
rinh / require.jison
Created February 5, 2013 04:49
使用jison进行语义分析,生成AST并修改源代码
%lex
%s l_comment req
%%
"/*" { this.begin('l_comment'); return 'L_COMMENT_START'; }
<l_comment>"*/" { this.popState(); return 'L_COMMENT_END'; }
<l_comment>(.|\n) { return 'L_COMMENT_CHR'; }
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
x, y := 0, 1
return func() int {
x, y = y, x + y