Skip to content

Instantly share code, notes, and snippets.

View noodlehaus's full-sized avatar
😎
TPC rewrite

noodlehaus noodlehaus

😎
TPC rewrite
View GitHub Profile
@noodlehaus
noodlehaus / gist:66dbc0a1887706d523a9
Last active September 26, 2015 07:58
resample uploaded images (old version)
<?php
function save_and_resample($fname, $oname, $tname, $type, $imagew, $imageh)
{
$imgr = ( $imagew > $imageh ) ? IMAGE_MAX_THUMB_WIDTH/$imagew : IMAGE_MAX_THUMB_HEIGHT/$imageh ;
$neww = $imagew * $imgr;
$newh = $imageh * $imgr;
$fulw = $imagew;
$fulh = $imageh;
if ( $neww > IMAGE_MAX_THUMB_WIDTH ) {
@noodlehaus
noodlehaus / gist:1153656
Created August 18, 2011 08:29
patch the req object in express to include the pause() and resume() methods for event buffering (for async middleware)
/*
* patches the req object to have the pause() and resume() functions
* for event buffering (for async middleware).
* code is take from express' utils file
*/
const http = require('http'),
req = http.IncomingMessage.prototype;
// patch req object for async middleware
@noodlehaus
noodlehaus / JS array binary search
Created August 29, 2011 14:30
Binary search implementation for JS arrays
@noodlehaus
noodlehaus / jsonv
Created September 28, 2011 06:42
CLI tool for getting values from JSON text files.
#!/usr/bin/env node
const fs = require('fs');
var args = process.argv.slice(2);
if (args.length < 2) {
console.log('Usage: jsonv <jsonfile> <json-path-1> ... <json-path-n>');
process.exit(1);
}
@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) {
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(),
<!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>
<!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
@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;
@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>