Skip to content

Instantly share code, notes, and snippets.

View AlienHoboken's full-sized avatar

Jeremiah AlienHoboken

  • United States of America
View GitHub Profile
@AlienHoboken
AlienHoboken / gist:5278438
Created March 30, 2013 21:30
Javascript file path shortener. Depends on jQuery.
$(document).ready(function () {
var str = "H:\\Informatique\\Personnalisation\\Icones\\__\\Crystal GT PNG Pack\\Applications\\licq.png";
var maxLength = 25;
var tokens = str.split("\\");
var drive = tokens[0];
var fileName = tokens[tokens.length - 1];
var len = drive.length + fileName.length;
//remove the current lenth and also space for 3 dots and 2 slashes
var remLen = maxLength - len - 5;
@AlienHoboken
AlienHoboken / valve-data-format-jsonify.php
Last active October 14, 2021 15:31
This short PHP script will create valid JSON data from Valve Data Format (VDF) data, such as items_game.txt files for TF2 and DotA 2. This allows for much greater ease in parsing the data it contains.
<?php
//load VDF data either from API call or fetching from file/url
//no matter your method, $json must contain the VDF data to be parsed
$json = file_get_contents("items_game.txt");
//encapsulate in braces
$json = "{\n$json\n}";
//replace open braces
$pattern = '/"([^"]*)"(\s*){/';
@AlienHoboken
AlienHoboken / github_webhook_update.php
Created March 3, 2017 20:07
Support for GitHub webhook to update local repository utilizing secret key matching
<?php
//polyfill for missing hash_equals
if(!function_exists('hash_equals'))
{
function hash_equals($str1, $str2)
{
if(strlen($str1) != strlen($str2))
{
return false;
}
@AlienHoboken
AlienHoboken / terraform_remove_attrs.sh
Created August 19, 2020 21:03
Bash script to automatically remove attributes from terraform state file
set -e
if [ $# -eq 0 ]; then echo "No command specified\nAvailable commands:\n* remove [attribute_name]\n* commit\n"; exit; fi
if [ $1 = "remove" ]; then
if [ $# -eq 1 ]; then
echo "No attribute_name specified to remove\n"
exit
fi