Skip to content

Instantly share code, notes, and snippets.

View rip-tyang's full-sized avatar
Coding, and thinking about the ultimate meaning of life, and more coding

Thomas Yang rip-tyang

Coding, and thinking about the ultimate meaning of life, and more coding
View GitHub Profile
# one space between array and no space at the end
emojis=(🐶 🐺 🐱 🐭 🐹 🐰 🐸 🐯 🐨 🐻 🐷 🐮 🐵 🐼 🐧 🐍 🐢 🐙 🐠 🐳 🐬 🐥 🍳 🍞 🐓 🐔 🌄 🌲 🌳 🌴 🌵 🌷 🌺 🌸 🌹 🌻 🌼 💐 🌾 🌿 🍀 🍁 🍂 🍃 🍄 ☀️ ⛅️ ☁️ ☔️ 🌈 🌊 🗻 🌍 🌞 💻 🚽 📚 ✂️ 🔪 🍔 🍕 🍖 🍗 🍘 🍙 🍚 🍛 🍜 🍝 🍞 🍟 🍣 🍤 🍥 🍱 🍲 🍳 🍴 🍏 🍇 🍉 🍊 🍌 🍍 🍑 🍒 🍓 🍡 🍢 🍦 🍧 🍨 🍩 🍪 🍫 🍬 🍭 🍮 🍰 🍷 🍸 🍶 🍹 🍺 🍻)
# single quote so it will change everytime you hit return
function emoji {
echo "${emojis[$RANDOM % ${#emojis[@]}]} "
}
# Get the current ruby version in use with RVM:
# if [ -e ~/.rvm/bin/rvm-prompt ]; then
# RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} "
@rip-tyang
rip-tyang / print_self.c
Last active October 17, 2018 05:09
Print self c
#include <stdio.h>
int main() {
char *s = "#include <stdio.h>%c%cint main() {%c char *s = %c%s%c;%c printf(s, 10, 10, 10, 34, s, 34, 10, 10, 10, 10);%c return 0;%c}%c";
printf(s, 10, 10, 10, 34, s, 34, 10, 10, 10, 10);
return 0;
}
@rip-tyang
rip-tyang / keybase.md
Last active November 7, 2021 00:39
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@rip-tyang
rip-tyang / cloneArray.coffee
Created March 1, 2016 17:26
CoffeeScript Utility Functions: deep clone nested array
class Util
@cloneArray: (arr) =>
if Array.isArray arr
_arr = arr.slice 0
return _arr = _arr.map @cloneArray
else if typeof arr is 'object'
throw Error 'Cannot clone nested array with object'
else
return arr
@rip-tyang
rip-tyang / arr.coffee
Last active March 1, 2016 21:59
CoffeeScript Utility Functions: create multidimensional array with sizes of each dimension and a value/function
class Util
# construct multidimensional array with value or function
# @para (size1, size2, size3, ..., value/func)
# @func (index1, index2, index3, ...) -> value
# example:
# Util.arr() -> []
# Util.arr(2) -> [0, 0]
# Util.arr(2, 3) -> [3, 3]
# Util.arr(2, 3, 0) -> [[0,0,0],[0,0,0]]
# Util.arr(2, 3, function (a, b) { return a + b; }) -> [[0,1,2], [1,2,3]]
@rip-tyang
rip-tyang / shuffle.coffee
Created March 1, 2016 01:51
CoffeeScript Utility Functions: shuffle array
class Util
# Fisher-Yates (aka Knuth) Shuffle
@shuffle: (array) ->
currentIndex = array.length
# While there remain elements to shuffle...
while 0 isnt currentIndex
# Pick a remaining element...
randomIndex = ~~(Math.random() * currentIndex)
--currentIndex
# And swap it with the current element.
@rip-tyang
rip-tyang / 2dArrayRotate.coffee
Last active March 1, 2016 02:01
CoffeeScript Utility Functions: rotate 2d array
class Util
@isSquareArray: (arr) ->
Array.isArray(arr) &&
Array.isArray(arr[0]) &&
arr.length is arr[0].length
@rotateArrayClockwise: (arr) ->
if not @isSquareArray arr
throw Error 'Not a 2 dimensional array'