Skip to content

Instantly share code, notes, and snippets.

View wei's full-sized avatar
💡
Available

Wei He wei

💡
Available
View GitHub Profile
@wei
wei / Manually Pre-Sign Amazon Put Request
Created May 16, 2015 06:25
Manually Pre-Sign Amazon Put Request
var hmacSha1Base64 = function (message) {
return require("crypto").createHmac('sha1', process.env.AMAZON_SECRET_ACCESS_KEY)
.update(message)
.digest('base64')
}
var expires = Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 365
var put_request = "PUT\n" + md5Base64 + "\n"+contentType+"\n"+expires+"\n/"+ "xxxxxxx/" + bucketObjectKey
@wei
wei / fullbackup.php
Created June 2, 2015 22:15
CPanel Full Backup Cron Script
<?php
// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
// Cron Job Command: /usr/local/bin/php /home/<cpanel-username>/fullbackup.php
// This script contains passwords. It is important to keep access to this file secure (we would ask you to place it in your home directory, not public_html)
// You need create 'backups' folder in your home directory ( or any other folder that you would like to store your backups in ).
// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********
@wei
wei / generate-identicon.js
Created June 20, 2016 22:02
Generate Icons with SVG and Color Rounded Background
var COLORS = [
{iconColor: '#536D2F', bgColor: '#DDE2D5'},
{iconColor: '#5093A1', bgColor: '#DBE9EC'},
{iconColor: '#AF2F30', bgColor: '#EFD6D6'},
{iconColor: '#BE8341', bgColor: '#F2E6D9'},
{iconColor: '#784FA0', bgColor: '#E4DCEC'},
{iconColor: '#FFFFFF', bgColor: '#58B6E1'}
]
var fs = require('fs');
@wei
wei / whois-watch.sh
Last active August 4, 2017 13:26 — forked from zhovner/whois-change.sh
Monitor whois changes
#!/bin/bash
#
# Run this script once per minute
#
# * * * * * /path/to/whois-watch.sh google.com apple.com >> /var/log/whois-watch.log 2>&1
# update username in mail command
# update sed command depending on server return text
#
@wei
wei / NginxWWWRedirection.md
Last active November 22, 2024 03:52
Nginx WWW Redirection

Nginx WWW Redirection

Redirect non-www to www

For Single Domain:

server {
    server_name example.com;
    return 301 $scheme://www.example.com$request_uri;
}
@wei
wei / Google-Analytics-outbound-links.js
Last active January 23, 2020 21:10
Setup Google Analytics to track outbound links. Supports target="_blank".
@wei
wei / auto-select-first.js
Last active June 16, 2022 07:36
Google Maps API AutoComplete Auto Select First on Enter
selectFirstOnEnter(input){
const _addEventListener = input.addEventListener;
let hasHitDown = false;
// Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected, and then trigger the original listener.
function addEventListenerWrapper(type, listener) {
if (type === "keydown") {
var orig_listener = listener;
listener = function (event) {
if (event.which === 13) {
if (!hasHitDown) {

Keybase proof

I hereby claim:

  • I am wei on github.
  • I am towei (https://keybase.io/towei) on keybase.
  • I have a public key whose fingerprint is 01F3 7324 4CA2 866D 1E17 B054 D380 E53F 849A 5C7C

To claim this, I am signing this object:

@wei
wei / eco-server-order-on-ovhcloud-api.md
Created November 19, 2024 15:14 — forked from adns44/eco-server-order-on-ovhcloud-api.md
Eco server order process with OVHcloud API step-by-step

OVH - How to use the API to order any server? The answer is here!

I ASK YOU IN FIRST

This process is automateable. I'll write the know-how, how to do it. I kindly ask you! Do NOT ABUSE it! Please keep the oportunity to order limited edition servers for other ones!

How the OVH API works?

First of all, OVH provides API libraries to access the API. And for this too, they have an API console where you can try it. For now, we'll see the API console. We'll place an older. Lets go!