Skip to content

Instantly share code, notes, and snippets.

☕️
Caffeinating

Jesse Donat donatj

☕️
Caffeinating
Block or report user

Report or block donatj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@donatj
donatj / ascii.php
Created Nov 9, 2011
Damn Simple PHP Ascii Art Generator
View ascii.php
#!/usr/bin/php -q
<?php
if(isset($argv[1]) && strlen($argv[1])) {
$file = $argv[1];
}else{
echo 'Please Specify a File';
exit(1);
}
@donatj
donatj / http.go
Last active Sep 12, 2018
Golang Basic Auth
View http.go
package utils
import (
"net/http"
)
func BasicAuth(handler http.Handler, username, password string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if u, p, ok := r.BasicAuth(); !ok || !(u == username && p == password) {
w.Header().Set("WWW-Authenticate", "Basic realm=\"ZorkIrc\"")
@donatj
donatj / ColorCLI.php
Created Oct 26, 2011
Simple CLI color class
View ColorCLI.php
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',
View examples.md

TypeScript

class MyLogicContainer {
    constructor(private x: number) { }
    
    add(y: number) {
        return this.x + y;
    }
}
@donatj
donatj / prblame
Created Jun 21, 2017
Find the pull request a line of a file was added with
View prblame
#!/bin/bash
set -e
blame=$(git blame "$1" -L "$2,$2" -p)
open "https://github.com/search?type=Issues&q=${blame:0:40}"
View preg_replace-bug.php
<?php
$content ='
"${folder}\\\\";
if (!isset($data[\'file\'])) { die("This doesn\'t appear to be a language constant file".nl); }
$translation = trim($value,"\' \\t\\n\\r\\0\\x0B");
\'es_ni\'=>\'Spanish (Nicaragua)\',
\'es_pa\'=>\'Spanish (Panama)\',
\'es_pe\'=>\'Spanish (Peru)\',
\'es_pr\'=>\'Spanish (Puerto Rico)\',
@donatj
donatj / lorem.php
Created Sep 22, 2010
PHP Flavored Lorem Ipsum Generator
View lorem.php
<?php
include('words_example.php'); //Our Datasetm $data
$patSize = 5;
foreach( $data as $word ) {
for( $i = 0; $i <= strlen( $word ) - 2; $i++ ) {
$j = 0;
$str = '';
View selector_string2array
/**
* Method for taking a string formatted as a css selector and breaking it down into id/classes/attributes/in-line styles
* to use in the creatin of an element. I.E. "#id.class.class2[attribute=value]{ border: 1px solid blue; }"
*
* @ignore this is the original regex i wrote, which was awesome, but broke on some edge cases ...
* "!(\#(.+?)(\.|\[|\{)){1,}!" => ' id="$2" $3', //ID
* "!(\.(.*?)(\[|\{)){1,}!" => ' class="$2" $3', //CLASS
* "!\[(.*?)=([^\[]*)\]!" => ' $1="$2" ', //ATTRS
* "!\{(.*)\}!" => ' style="$1" ', //INLINE STYLE
* "!\.([a-zA-Z_]+[\w\-]*)!" => ' $1', //SPECIFIC CLASSES
@donatj
donatj / matlock.php
Created Feb 23, 2012
Slow Query Log Parser
View matlock.php
#!/usr/bin/php
<?php
$file = false;
$defaults = array(
'maxQueryTime' => pow(2,32),
'minQueryTime' => 0,
'maxLockTime' => pow(2,32),
'minLockTime' => 0,
'maxRowsSent' => pow(2,32),
'minRowsSent' => 0,
@donatj
donatj / debug.css
Created Apr 20, 2012
Pure CSS Debuggery
View debug.css
*[class]:before {
position: absolute;
background: rgba(10,10,10,.6);
padding: 10px;
border-radius: 4px;
color: white;
font-size: 10px;
display: block;
content: "[" attr(class) "] " ;
}
You can’t perform that action at this time.