Skip to content

Instantly share code, notes, and snippets.

View FrankFang's full-sized avatar
🎯
Focusing

Frank Fang FrankFang

🎯
Focusing
View GitHub Profile
if &compatible
set nocompatible
endif
set hidden
set noautochdir
set shortmess=a
set autowriteall
filetype plugin indent on
unalias z
j() {
if [[ -z "$*" ]]; then
cd "$(_z -l 2>&1 | fzf +s | sed 's/^[0-9,.]* *//')"
else
_last_z_args="$@"
_z "$@"
fi
}
#!/usr/bin/env python
#
# Copyright 2015 clowwindy
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@FrankFang
FrankFang / find_dups.rb
Created November 9, 2017 15:35 — forked from rob-murray/find_dups.rb
Rails find duplicate records
columns_that_make_record_distinct = [:some_id, :another_name]
distinct_ids = Model.select("MIN(id) as id").group(columns_that_make_record_distinct).map(&:id)
duplicate_records = Model.where.not(id: distinct_ids)
@FrankFang
FrankFang / nginx-403-forbidden-error-hosting-in-user-home-directory.md
Created August 13, 2017 20:09 — forked from jhjguxin/nginx-403-forbidden-error-hosting-in-user-home-directory.md
nginx 403 forbidden error when server static file under user home directory
@FrankFang
FrankFang / application.html.erb
Created July 17, 2017 08:56 — forked from Dagnan/application.html.erb
Inline CSS or JS in Rails 5
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>
@FrankFang
FrankFang / registrations_controller.rb
Created June 14, 2017 07:02 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@FrankFang
FrankFang / nginx.conf
Created May 17, 2017 13:22 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@FrankFang
FrankFang / encryption-decryption.rb
Created May 7, 2017 23:27 — forked from gevans/encryption-decryption.rb
A couple examples of using asymmetric RSA signing and encryption using Ruby's OpenSSL libraries.
require 'openssl'
key = OpenSSL::PKey::RSA.new(2048)
p encrypted_string = key.public_encrypt('my plaintext string', OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
p decrypted_string = key.private_decrypt(encrypted_string, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
@FrankFang
FrankFang / forword-when-url-starts-with.js
Last active May 7, 2017 15:38
forword when url starts with ...
server{
location /image-server/ {
proxy_pass http://localhost:3000/;
}
}