Skip to content

Instantly share code, notes, and snippets.

View noodlehaus's full-sized avatar

noodlehaus noodlehaus

View GitHub Profile
@noodlehaus
noodlehaus / .vimrc
Last active December 30, 2015 18:29
vimrc settings, given pathogen and some plugins are already installed
" pathogen
execute pathogen#infect()
syntax on
filetype on
filetype plugin on
filetype indent on
" core settings
set ruler
set tabstop=2
@noodlehaus
noodlehaus / git-prompt.sh
Created December 9, 2013 06:53
git path info in PS1
# alias
alias ls='gls --color=always --group-directories-first'
alias ll='ls -l'
# git prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\.\1/'
}
export PS1="\[\033[38m\]\u@\h\[\033[01;36m\]:\w\[\033[32m\]\$(parse_git_branch)\[\033[37m\]$\[\033[00m\] "
@noodlehaus
noodlehaus / nomad.php
Created September 2, 2013 02:18
markdown-like, but not. function for formatting text.
<?php
function nomad($text) {
$text = htmlentities($text);
// strong
$text = preg_replace_callback('@\*(.+)\*@U', function ($m) {
return '<strong>'.trim($m[1]).'</strong>';
}, $text);
@noodlehaus
noodlehaus / web_app.php
Last active December 15, 2017 06:39
bare bones routing function for PHP.
<?php
// minimal routing
function web_app($routes, $req_verb, $req_path) {
$req_verb = strtoupper($req_verb);
$req_path = trim(parse_url($req_path, PHP_URL_PATH), '/');
$found = false;
if (isset($routes[$req_verb])) {
@noodlehaus
noodlehaus / fmt-test.php
Last active December 21, 2015 03:08
markdown-like string formatting function
<?php
include './fmt.php';
$text = '';
if (strtolower($_SERVER['REQUEST_METHOD']) === 'post')
$text = $_POST['text'];
?>
<!DOCTYPE html>
<html>
@noodlehaus
noodlehaus / ui-styles.css
Created July 25, 2013 08:59
controls style palette
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700);
/*----------------
* control styles
*/
body {
color: #333;
font-size: 14px;
line-height: 19px;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.edit {
padding-left: 18px;
background: #ff6 url(http://www.famfamfam.com/lab/icons/silk/i
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div><span id="host1">mysql-a</span>.protego.com</div>
<div><span id="host2">mysql-a</span>.protego.com</div>
function previewImage(file) {
var reader = new FileReader();
reader.onload = function (e) {
var o = $('<img class="img">').attr('src', e.target.result),
r = $('.img-box');
o.load(function (e) {
r.append(o);
var h = o.height(),
@noodlehaus
noodlehaus / gist:3212985
Last active October 7, 2015 19:18
[php] base conversion utilities (b58, dec, hex)
<?php
function b58_to_dec($val) {
return gmp_strval(gmp_init((string) $val, 58), 10);
}
function b58_to_hex($val) {
return gmp_strval(gmp_init((string) $val, 58), 16);
}
function dec_to_b58($val) {