Skip to content

Instantly share code, notes, and snippets.

View serverwentdown's full-sized avatar

Ambrose Chua serverwentdown

View GitHub Profile
@serverwentdown
serverwentdown / robbyrussell.zsh-theme
Created December 3, 2014 07:27
robbyrussell.zsh-theme to not get confused between SSH and local shells
if [[ -n $SSH_CONNECTION ]]; then
local ret_status="%(?:%{$fg_bold[yellow]%}➜ :%{$fg_bold[red]%}➜ %s)"
else
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
fi
PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
@serverwentdown
serverwentdown / volume
Last active August 29, 2015 14:10
ubuntu + youtube-dl scripts
#!/bin/sh
amixer -D pulse sset Master $1
@serverwentdown
serverwentdown / handlebars-autorenderer.js
Last active August 29, 2015 14:10
handlebars-autorenderer
function AutoRenderer() {
var parser = new DOMParser();
this.handles = [];
this.context = {};
function Handle(scriptElement, context) {
var templateString = scriptElement.innerHTML;
this.template = Handlebars.compile(templateString);
this.context = context || {};
this.element = scriptElement;
}
@serverwentdown
serverwentdown / O.o.tree.js
Last active August 29, 2015 14:10
Object.observe() all child elements too.
function observeTree(object, cb) {
Object.observe(object, function (changes) {
if ((changes[0].type == "add" || changes[0].type == "update") && typeof changes[0].object[changes[0].name] == "object") {
observeTree(changes[0].object[changes[0].name], cb);
}
cb(changes);
});
}
@serverwentdown
serverwentdown / touchkeys.html
Created November 13, 2014 13:20
Some poorly-coded idea for keyboard-based "multitouch" (not multitouch for now) navigation and scrolling. By dragging your finger on the keyboard. The scrolling works!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
#cursor {
width: 48px;
height: 48px;
border-radius: 24px;
@serverwentdown
serverwentdown / nyan
Created November 6, 2014 14:37
nyantutorial
#!/bin/zsh
control_c() {
echo "Yes! You did it! ";
echo -n "Want more nyan? (y/n) "
read input
if [[ $input == "y" ]]; then
nc -v nyancat.dakko.us 23
else
echo "Aww, bye! "
@serverwentdown
serverwentdown / pa4.c
Created October 16, 2014 06:22
feel free to fork and improve, cos this is crappy code
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
// #include <math.h>
#include <time.h>
#include <sys/time.h>// For `gettimeofday()`
#include <string.h>
@serverwentdown
serverwentdown / homesync.sh
Created October 12, 2014 14:17
keep your $HOME in sync
#!/bin/zsh
# CONFIG
SERVER="example.com"
# Don't put trailing slashes btw.
REMOTEDIRECTORY="" # Set to "backup" to push to home directory of remote user. WARNING: Beginning with "/" will push to the remote root directory.
LOCALDIRECTORY="$HOME"
# REMOTEUSER="ambrosechua"
LOG=".homesync.log"
@serverwentdown
serverwentdown / enc.b64.Makefile
Last active August 29, 2015 14:07
Jekyll _posts encryption Makefile, but can be reconfigured easily. Feedback please! 😄
SHELL := /bin/zsh
DIRECTORY = "_posts"
EXT_ENC = ".aes.b64"
EXT_FILE = ".md"
ENCRYPTION = "aes-128-cbc"
all: usage
usage:
@serverwentdown
serverwentdown / infocomm.html
Created September 1, 2014 12:53
Derping around
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>infocomm</title>
<style>
* {
padding: 0;
margin: 0;
}