Skip to content

Instantly share code, notes, and snippets.

View wujunze's full-sized avatar
:octocat:
Learning

Panda wujunze

:octocat:
Learning
  • Open Source
  • Earth
  • 18:25 (UTC +08:00)
View GitHub Profile
@lifei6671
lifei6671 / snowflake.php
Created August 15, 2017 01:49
PHP实现的snowflake算法
/**
* 使用 snowflake 算法生成递增的分布式唯一ID.
* 该算法支持 15 条业务线,4 个数据中心,每个数据中心最多 128 台机器,每台机器每毫秒可生成 4096 个不重复ID.
*/
class Snowflake
{
const SEQUENCE_BITS = 12;
const MILLISECOND_BITS = 39;
const BUSINESS_ID_BITS = 4;
const DATA_CENTER_ID_BITS = 2;
@antirez
antirez / resp3.md
Last active June 2, 2020 08:41
RESP3 protocol draft

RESP3 specification

Versions history:

  • 1.0, 2 May 2018, Initial draft to get community feedbacks.

Background

The Redis protocol has served us well in the past years, showing that, if carefully designed, a simple human readable protocol is not the bottleneck in the client server communication, and that the simplicity of the design is a major advantage in creating a healthy client libraries ecosystem.

Yet the Redis experience has shown that after about six years from its introduction (when it replaced the initial Redis protocol), the current RESP protocol could be improved, especially in order to make client implementations simpler and to support new features.

@cedricziel
cedricziel / migrate.sh
Created January 12, 2017 09:11
Very simple migration script to move from gitlab to gogs
#!/bin/env bash
## Needs `jq` (https://stedolan.github.io/jq/) on PATH
## and a personal gogs token of yours.
## Obtain token from https://git.example.com/user/settings/applications
## Usage:
## ./migrate.sh $clone_url $project_name [$optional_group]
## Migrate a repository to gogs into the user namespace of the token-user
## ./migrate.sh git@mygitlab.com:group/repo.git repo
## Migrate a repository to gogs into the group namespace `group` (needs to exist)
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
@mattstauffer
mattstauffer / log.md
Last active June 14, 2023 09:23
Introduction to GistLog

So, you might be asking yourself, what is GistLog?

GistLog is a blogging "platform" for people who want to quickly write and publish content, in Markdown, and don't want to bother with yet another platform and yet another login and yet another group hoarding their content. With GistLog, you use your pre-existing GitHub login, you store the data in your own GitHub account, and you can publish with a single click.

Using GistLog

  1. Create a public gist with a single file using Markdown. Set the gist description to be the title of your blog post
  2. Copy the gist URL, and paste it into the text box on the GistLog create page
  3. Copy your resulting URL and share it as your blog post—note that it will be in the form of https://gistlog.co/your-github-username/gist-id
  4. If you want to have your own GistLog landing page (e.g. gistlog.co/mattstauffer), [read all about it](https://gistlog.co/mattstauffer/a82db5
@saelo
saelo / decorator.go
Created March 8, 2015 19:45
Decorators in Go
package main
import (
"fmt"
"reflect"
)
func Decorate(impl interface{}) interface{} {
fn := reflect.ValueOf(impl)
@ancestral
ancestral / ASCII JS Keyboard Map
Created July 6, 2012 04:33
ASCII keyboard map for JavaScript keycodes (Mac)
/*
* JavaScript Keyboard Map (Mac layout)
*
*
* esc—— F1——— F2——— F3——— F4——— F5——— F6——— F7——— F8——— F9——— F10—— F11—— F12—— F13—————+
* | 27 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | ??? |
* ` ——— 1———— 2———— 3———— 4———— 5———— 6———— 7———— 8———— 9———— 0———— - ——— = ——— delete——+
* | 192 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
* tab———— Q———— W———— E———— R———— T———— Y———— U———— I———— O———— P———— [ ——— ] ——— \ ————+
* | 9 | 81 | 87 | 69 | 82 | 84 | 89 | 85 | 73 | 79 | 80 | 219 | 221 | 220 |
@tevino
tevino / epoll.go
Last active January 20, 2024 22:50
An example of using epoll in Go
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active April 1, 2024 11:21
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert