Skip to content

Instantly share code, notes, and snippets.

View ningsuhen's full-sized avatar

Ningsuhen Waikhom ningsuhen

View GitHub Profile
@ningsuhen
ningsuhen / README.md
Created December 21, 2015 16:34
Solarized Light Theme for CoderPad.io - Use https://chrome.google.com/webstore/detail/styler/bogdgcfoocbajfkjjolkmcdcnnellpkb?hl=en or similar extension to inject the css file
@ningsuhen
ningsuhen / SSH_Copy_To_Local_Clipboard.md
Last active March 7, 2020 01:00
A small script which will enable copying into local clipboard from remote ssh instance. Based on RemoteCopy.

#Installation Just add the code snippet of add_to_bash_profile to ~/.bash_profile or ~/.bashrc depending on your OS.

##Command Line Usage

rclip "Some String to be copied to your local Clipboard"
Input secret:

Press Cmd+V (copy) or Ctrl+V and press enter.

@ningsuhen
ningsuhen / programming-languages-forloop-benchmark.ipynb
Last active November 19, 2015 05:22
A simple ipython notebook for benchmarking for loop performance of common programming languages
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ningsuhen
ningsuhen / SpamLord.py
Last active November 8, 2015 14:01
Dan Jurafsky's NLP SpamLord
import sys
import os
import re
import pprint
my_first_pat = '(\w+)@(\w+).edu'
emails_pat_str = '(?:^|[ :">]+)((?:-?[a-z]-?){2,}|[a-z0-9\.]+)(?<!Server|cience) ?(?:@|[%20\( ]+at[\) %20]+|WHERE|&#x40;|\(followed by .*@) ?(?:((?:-?[a-z]-?){2,}|[a-z0-9-]+) ?(?:\.|;|[\(%20]*dot[\(%20]*|DOM| dt ) ?((?:-?[a-z]-?){2,}|[a-z]+)(?: ?(?:\.|;|\(?dot[\)]?) ?((?:-?[a-z]-?){2,}|[a-z]+))?|cs stanford edu)'
phones_pat_str = '(?:\+[0-9]{1,2})? ?\(?([0-9]{3})[\)\- ]+([0-9]{3})[- ]([0-9]{4})'
emails_pat_str2 = "<script>[ ]?(?:obfuscate)\('([a-z\.]+)','([a-z\.]+)'\);?[ ]?</script>"
"""
TODO
@ningsuhen
ningsuhen / latency.txt
Created November 6, 2015 16:34 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@ningsuhen
ningsuhen / deploy.sh
Last active April 3, 2020 16:57
deploy-hugo-site-to-github-pages A simple script for deploying static site generated by hugo into github pages
#!/usr/bin/env bash -xe
#allow passing a commit message
message=$1
if [ "$message" == "" ]; then
#use last git commit message for deploying into github pages
message=`git log -1 --pretty=%B`
fi
@ningsuhen
ningsuhen / xcode_cleanup_script.md
Last active October 30, 2015 10:40
Simple Shell Script for cleaning up XCode files - Credit - https://github.com/Seitk/Xcode-Cleanup-Script

Xcode-Cleanup-Script

My tiny Macbook Air was hungry for disk space and there were more than 18GB of unused files for xcode caching and application supports. So I wrote a shell script to cleanup those files. For files to be deleted and their usage, check this blog (http://blog.favo.org/post/31649090293/xcode-5-places-to-save-some-disk-space).

Files to be removed
~/Library/Developer/Xcode/Archives/*
~/Library/Developer/Xcode/DerivedData/*
~/Library/Developer/Xcode/iOS DeviceSupport/*
~/Library/Application Support/iPhone Simulator/?/Applications

@ningsuhen
ningsuhen / Regex.swift
Last active April 27, 2019 18:39
Swift extension for Native String class to support Regex match and Regex replace. Credit - http://www.swift-studies.com/blog/2014/6/12/regex-matching-and-template-replacement-operators-in-swift
import Foundation
struct Regex {
var pattern: String {
didSet {
updateRegex()
}
}
var expressionOptions: NSRegularExpressionOptions {
didSet {