Skip to content

Instantly share code, notes, and snippets.

View williamli's full-sized avatar

Willi#m ⬣ williamli

View GitHub Profile
@williamli
williamli / ssh-key-generation.md
Created December 5, 2018 01:51 — forked from cybersamx/ssh-key-generation.md
Generate a new SSH key pair

Mac and Linux

  • Open Terminal

  • Check if you already have a SSH keypair generated. Do the following:

    $ ls -la ~/.ssh/id_rsa*
    

If the files exist, you already have SSH installed. IMPORTANT: But if you wish to regenerate the SSH key pair, at least back up your old SSH keys.

@williamli
williamli / Baidu TongJi + China Firewall = DDOS "Great Cannon"
Last active June 20, 2023 22:01
Baidu TongJi's Javascript Library (//hm.baidu.com/hm.js) Changes (by Firewall of China) to launch DDOS attack on enemy websites?
The Great Firewall of China seems to be hijacking Baidu Analytics (TongJi)'s Javascript code,
launching DDOS attacks on enemy websites from browsers.
Different hm.js (TongJi library) libraries are spotted and load interchangably.
An altered hm.js code is used when DDOS is observed.
More Info: https://stackoverflow.com/questions/45874555/baidu-tongji-analytics-is-directing-browsers-to-ddos-chinas-enemies
@williamli
williamli / easings.scss
Created August 3, 2017 11:07
Easings variables for SCSS
// taken from http://easings.net/
$ease-in-out-back: cubic-bezier(0.680, -0.550, 0.265, 1.550);
$ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.150, 0.860);
$ease-in-out-expo: cubic-bezier(1.000, 0.000, 0.000, 1.000);
$ease-in-out-sine: cubic-bezier(0.445, 0.050, 0.550, 0.950);
$ease-in-out-quint: cubic-bezier(0.860, 0.000, 0.070, 1.000);
$ease-in-out-quart: cubic-bezier(0.770, 0.000, 0.175, 1.000);
$ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1.000);
$ease-in-out-quad: cubic-bezier(0.455, 0.030, 0.515, 0.955);
@williamli
williamli / hongkong_districts_ups.json
Last active June 16, 2022 08:28
102 Hong Kong Districts (UPS) in JSON with Traditional Chinese Translation
// UPS District and Codes for Hong Kong, extracted from UPS Shipping Package Developer Kit PDF
[
{
"name": "Aberdeen",
"translations": {
"zh": "香港仔"
},
"code": "SD1"
},
Router.route('/login', function () {
if (!Meteor.userId())
{
this.render('login', {
data: function(){
return {is_login: true};
}
});
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@williamli
williamli / .htaccess
Last active December 22, 2015 07:39
device (mobile vs desktop) based smart website redirecting with htaccess and cookies
# Instruction
# mobile site: m.example.com
# desktop site: example.com
# use query string target=mobile to enforce a mobile view on mobile site on desktop (set once and store in cookie)
# use query string target=desktop to enforce a desktop view on desktop site on mobile (set once and store in cookie)
# use query string target=default to reset view preference to default
RewriteEngine On
# Checks query string for target, sets cookie and refresh
@williamli
williamli / .htaccess
Created September 3, 2013 11:12
HTTPS Enforcer for Apache .htaccess in 3 Lines
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]