Skip to content

Instantly share code, notes, and snippets.

View dorentus's full-sized avatar
🎲
🌎🌍🌏

ZHANG Yi dorentus

🎲
🌎🌍🌏
View GitHub Profile
# Uncrustify 0.60
newlines = auto
input_tab_size = 4
output_tab_size = 4
string_escape_char = 92
string_escape_char2 = 0
tok_split_gte = false
utf8_bom = ignore
utf8_byte = false
utf8_force = false
@dorentus
dorentus / backup.sh
Created October 22, 2013 16:27 — forked from likuku/backup.sh
#!/bin/sh
# Warning!
# if you DIY a stage package like this,
# you must use the Stage3`s /etc/udev/*
# or rm /etc/udev/rules.d/70*
# Warning!
# last edited by likuku on 2012.03.29
DATE=`date +%Y_%m_%d_%H_%M_%S`
ARCH=`uname -m`
$ ruby -ropenssl -e "puts OpenSSL::VERSION"
$ ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
@dorentus
dorentus / include.d~common-basedir
Created December 12, 2013 09:07
NGINX configurations
#
# $BASE_DIR = case $http_host
# when "a.example.com"
# "a.example.com"
# when "a.b.example.com"
# "b.example.com"
# end
#
set $BASE_DIR $http_host;
if ($http_host ~* ^([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+)$) {
@dorentus
dorentus / auto-hostname
Created February 8, 2014 06:03
/etc/network/if-up.d/auto-hostname
#!/bin/sh
set -e
fqdn=$(dig -x `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'` +noall +answer | grep PTR | awk '{print $5}')
fqdn=${fqdn%.}
if [ -z $fqdn ]; then
exit 0
fi
@dorentus
dorentus / ramdish.sh
Last active February 9, 2017 08:19
ramdisk.sh
#!/bin/bash
RD=ramdisk
if [ ! -e "/Volumes/$RD" ]; then
diskutil erasevolume HFS+ "$RD" `hdiutil attach -nomount ram://16777216` # 8G
# ~/Library/Developer/Xcode
mkdir -p "/Volumes/$RD/Xcode"
@dorentus
dorentus / bf.js
Last active August 29, 2015 13:57
yet another brainfuck interpreter
function brainLuck(code, input){
code = code || '';
input = input || '';
var memory = (function () {
var storage = [], cursor = 0;
return {
read: function () {
return storage[cursor] || 0;
},
write: function (c) {
@dorentus
dorentus / befunge.js
Last active January 19, 2016 19:14
yet another befunge interpreter
function interpret(code) {
var machine = (function () {
var stack = [];
return {
push: function (v) {
stack.push(v);
return this;
},
pop: function () {
interpret = (code) ->
class Machine
constructor: -> @stack = []
push: (v) -> @stack.push(v)
pop: -> @stack.pop()
top: -> @stack[@stack.length - 1]
String.prototype.bytes = function () {
var bytes = [], i = 0;
while ( true ) {
var byte = this.charCodeAt(i);
if ( isNaN(byte) ) break;
bytes.push(byte);
i += 1;
}
return bytes;
}