Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
@jessejjohnson
jessejjohnson / SnowflakeIdGenerator.cs
Last active April 4, 2023 12:39
Generate Twitter Snowflake ID's
public class SnowflakeIdGenerator
{
public const byte DefaultMachineIdBits = 6;
public const byte DefaultSequenceBits = 12;
private readonly long _machineId = 0;
private readonly byte _machineIdBits = 0;
private readonly byte _sequenceBits = 0;
private readonly long _maxSequence = 0;
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private readonly object _lockObject = new object();
import requests
import sys
import os
import json
MAX_PAGE = 10
if __name__ == "__main__":
'''https://<your_gitlab_site_address>/profile/personal_access_tokens'''
@adiog
adiog / generate_local_certificate.sh
Created September 10, 2017 19:26
Generate local certificate
#!/usr/bin/env bash
SERVER=$1
OUTPUT=$2
#Overview
# The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.
# Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).
# SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring that the
@reagent
reagent / 00_README.md
Last active January 29, 2024 13:31
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (
@mimosa
mimosa / README.md
Created June 27, 2016 04:17
微信扫码登录。
  1. 判定是否在微信中打开
def wechat?
    request.user_agent =~ /MicroMessenger/i 
end
  1. 分别调用 微信网页扫码公众号授权
@pmhoudry
pmhoudry / trixUpload.js
Last active May 7, 2021 16:37
Trix upload button in VanillaJs
(function() {
// Adding upload button to Trix toolbar on initialization
document.addEventListener('trix-initialize', function(e) {
trix = e.target;
toolBar = trix.toolbarElement;
// Creation of the button
button = document.createElement("button");
button.setAttribute("type", "button");
button.setAttribute("class", "attach");
@liruqi
liruqi / block_aliyun.conf
Last active October 2, 2020 14:51
Block aliyun
/*
* https://myip.ms/view/ip_owners/179248/Aliyun_Computing_Co_Ltd.html
res = ""; for (i=0; i<41; i++) { console.log(arr[i].text); res = res + "\n" + arr[i].text; }
arr = $("table .JColResizer .row_name a")
101.132.0.0 - 101.133.255.255
101.200.0.0 - 101.201.255.255
101.37.0.0 - 101.37.255.255
106.14.0.0 - 106.15.255.255
@mul14
mul14 / deploy.rb
Created March 22, 2015 00:52
Deploy Laravel 4 with mina http://mina-deploy.github.io/mina/
require 'mina/git'
# Fix the SSH password prompt problem
set :term_mode, nil
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
@ChuckJHardy
ChuckJHardy / digital_ocean_setup.md
Last active October 27, 2023 17:51
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

@eddanger
eddanger / new_rails_api_project_part1.md
Last active March 7, 2018 10:08
New Rails 4.2 API project with Rivets.js, Coffeescript, Sass and Bootstrap