Skip to content

Instantly share code, notes, and snippets.

View jbenner-radham's full-sized avatar

James Benner jbenner-radham

View GitHub Profile
@jbenner-radham
jbenner-radham / jquery_loader.js
Last active December 17, 2015 20:29
A quick and dirty client side script to check directory depth, build a relative path and add a JQuery script element. After the first self-executing anonymous function a second fires with a slight delay (if JQuery isn't yet initialized) to verify that JQuery is loaded & ready to rock.
(function() {
// Pt. I - Put this near the top of the head to append JQuery (In case you need doc.ready or whatnot).
var pageDepth = 0, relPath;
for (var path = location.pathname, len = path.length, c = 0; c < len; ++c)
if (path[c] === '/')
pageDepth += 1;
@jbenner-radham
jbenner-radham / C-simple-dev.sublime-build
Last active December 19, 2015 01:49
A Sublime Text build file for quick and simple C hacking. Only tested on ST3 beta on Ubuntu.
{
"cmd": ["cc -std=c11 -Wall ${file} && ./a.out"],
// Tells Sublime to only trigger for C files,
// since it wants to use g++ for C for some reason...
"selector": "source.c",
"working_dir": "${file_path}",
"shell": true
}
@jbenner-radham
jbenner-radham / automagic_table_thingy.js
Last active December 23, 2015 16:59
JavaScript automagic table script scratchpad. If you happen to venture upon this at random it probably doesn't work...
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElement
function makeTable(data, exclude) {
var tbl = document.createElement('table'),
thead = tbl.createTHead(),
thead_row = thead.insertRow(),
exclude = exclude || [];
if (Array.isArray(data) && data.length >= 1) {
@jbenner-radham
jbenner-radham / word_uc.c
Created November 7, 2013 05:01
MariaDB/MySQL UDF to capitalize the first letter of each word in a space separated string. Tested on MariaDB 5.5.33a on Ubuntu 12.10.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "mysql.h"
// sudo gcc -Wall -std=c11 -I/usr/include/mysql -shared word_uc.c -o /usr/lib/mysql/plugin/word_uc.so -fPIC
my_bool word_uc_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
@jbenner-radham
jbenner-radham / wdsutil_boot_prog.go
Created November 26, 2013 20:02
A terrible WDSUtil script I made up real quick in Go (FYI, I don't know how to use Go at the moment... so this is mostly a learning experiment.) to set the boot program.
package main
import (
"os"
"os/exec"
"log"
"fmt"
)
func main() {
@jbenner-radham
jbenner-radham / wdsutil_boot_prog.rs
Last active December 30, 2015 04:49
A simple and hacky program to trigger wdsutil... even though it doesn't actually do that yet. It's a learning & comparison project of Go vs. Rust (I'm rooting for Rust) so let's see how it goes.
#[link(name = "wdsutil_boot_prog", vers = "0.0.0")];
fn main() {
use std::{io, os, run};
let argv : ~[~str] = os::args();
let argc : uint = argv.len();
let stderr : @io::Writer = io::stderr();
@jbenner-radham
jbenner-radham / walky-talky.rs
Created December 10, 2013 01:53
Playing around with file system navigation in Rust.
// Tested on Rust 0.8 on OS X.
fn main() {
use std::*;
// This include is for the POSIX dirent style methods like "is_dir()".
use std::rt::io::file::*;
// Returns a "Path" struct (kind of like the var name, OMG!)
@jbenner-radham
jbenner-radham / .gitignore
Last active December 30, 2015 22:19
Just a whole bunch of different gitignore rules aggregated together into one big Frankenstein's monster of a gitignore! ...which was all totally taken from https://github.com/github/gitignore
#######################################
# https://github.com/github/gitignore #
#######################################
#----------#
# Archives #
#----------#
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
@jbenner-radham
jbenner-radham / recurse_and_expand.cpp
Created December 19, 2013 15:15
Recursive directory code to "expand" Windows drivers that don't want to inject (e.g. Nvidia and AMD video drivers) using Boost (primarily for "filesystem".)
#include <cstdlib> // printf
#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/system/error_code.hpp>
// Included due to the MinGW bug which inhibits std::to_string() from being invoked.
// e.g. lexical_cast<string>(example_numeric_var)
#include <boost/lexical_cast.hpp>
<?php
class StdOut
{
public static function write()
{
$argv = func_get_args();
$dest = '';
foreach ($argv as $arg) {