Skip to content

Instantly share code, notes, and snippets.

View xxjapp's full-sized avatar

Xia Xionjun xxjapp

View GitHub Profile
@xxjapp
xxjapp / aes_128_ecb_test.rb
Created October 22, 2022 08:37
ruby aes 128 ecb example
require 'openssl'
require 'base64'
def aes_128_ecbe key, data
cipher = OpenSSL::Cipher.new('AES-128-ECB')
cipher.encrypt # this needs to be called first to make encryption work for AES-128-ECB
cipher.key = key
cipher.padding = 1
@xxjapp
xxjapp / test-csv.go
Last active May 17, 2019 02:28
golang csv encoding & decoding
package main
import (
"bytes"
"encoding/csv"
"fmt"
)
func main() {
array := []string{"a s,dA", "Bdaf"}
@xxjapp
xxjapp / cloudSettings
Last active March 13, 2020 02:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-03-13T02:12:56.522Z","extensionVersion":"v3.4.3"}
@xxjapp
xxjapp / json-simple - EncodingExamples.wiki.md
Last active September 3, 2018 07:13
json-simple - EncodingExamples.wiki

Run a Rails App in Production Locally

Steps

  • export SECRET_KEY_BASE

    export SECRET_KEY_BASE=`rake secret`
@xxjapp
xxjapp / hide php extension in url
Last active August 3, 2017 07:58
hide php extension in url
http://php.net/manual/en/security.hiding.php
So far I haven't seen a working rewriter of /foo/bar into /foo/bar.php, so I created my own. It does work in top-level directory AND subdirectories and it doesn't need hardcoding the RewriteBase.
.htaccess
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
@xxjapp
xxjapp / Linux Static IP
Created June 1, 2017 16:09 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@xxjapp
xxjapp / git command like svn update.txt
Created April 30, 2017 09:15
git command like svn update
svn update
=>
git stash && git pull && git stash pop --index
@xxjapp
xxjapp / install node.js
Created April 30, 2017 08:12
install node.js (include npm) from binary on linux
wg https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz
unxz node-v6.10.2-linux-x64.tar.xz
tar -xf node-v6.10.2-linux-x64.tar
mkdir /usr/node
mv node-v6.10.2-linux-x64 /usr/node
ln -s /usr/node/node-v6.10.2-linux-x64 /usr/node/default
vi ~/.bash_profile
------------------------------------
@xxjapp
xxjapp / one_line_clock.sh
Last active December 14, 2015 14:29
Use only one line eithor in bash script file or command line to display a digital clock. This line also shows some useful tricks in bash script
# Use only one line eithor in bash script file or command line to display a digital clock.
# This line also shows in bash script
# - A example of endless loop
# - Assigning output of command to a variable
# - "-n" "-e" of echo command
# - "\r" is used to reset the current line output
while sleep 1; do o=$(date); echo -n -e "\r$o"; done