Skip to content

Instantly share code, notes, and snippets.

@idennydeng
idennydeng / sshd.go
Created September 24, 2020 09:19 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@idennydeng
idennydeng / pre-commit.sh
Created March 24, 2020 07:21 — forked from dahjelle/pre-commit.sh
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
#! /bin/bash
ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, ""); print }'
@idennydeng
idennydeng / web-development-tool-index.md
Created May 16, 2017 18:04
Web Development Tool Index
@idennydeng
idennydeng / Full Stack JavaScript.md
Last active May 16, 2017 09:52 — forked from royshouvik/Full Stack JavaScript.md
Learn Full Stack JavaScript Web Development for FREE using resources like YouTube, Udacity and NodeSchool
@idennydeng
idennydeng / get-url-param.js
Last active November 28, 2018 15:51
getUrlParam
function getUrlParam (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'),
r = window.location.search.substr(1).match(reg);
return r != null ? unescape(r[2]) : null;
}
@idennydeng
idennydeng / killall.sh
Created May 21, 2015 02:54
Kill all processes by name
#! /bin/bash
ps -ef|grep -v grep |grep -e process_name |awk '{print $2}'|xargs sudo kill
@idennydeng
idennydeng / rails_tmp_cache_configure
Created November 11, 2014 06:31
configure tmp cache directory
# config/application.rb
config.cache_store = [ :file_store, "/tmp/rails-cache/" ]
config.assets.cache_store = [ :file_store, "/tmp/rails-cache/assets/#{Rails.env}/" ]
@idennydeng
idennydeng / ruby_simple_http_server.rb
Created September 11, 2014 04:30
Simplest Possible Ruby Web Server: Using Rack for a one-liner
rackup -b "run Rack::Directory.new '.'"
require 'sinatra'
get '/' do
File.read(File.join('public', 'index.html'))
# or
# send_file File.join(settings.public, 'index.html')
end