Skip to content

Instantly share code, notes, and snippets.

@jgornick
jgornick / gist:33007
Created December 7, 2008 01:39
AutoHotkey Script for Apple Keyboard
/*
AutoHotkey Script
Use this script to map the Apple command key to the Alt Key and vice-versa.
This also fixes the alt-tab issues.
*/
; We don't need to see a tray icon
#NoTrayIcon
; Peform the map
@jgornick
jgornick / gist:33294
Last active January 5, 2017 05:05
PHP: Generate an 8 character long random string
<?php
///////////////////////////////////////////////////////////////////////////////
// Generate an 8 character long random string
///////////////////////////////////////////////////////////////////////////////
$chars = array('0', '1', '2', '3', '4', '5', '6', 'A', 'B', 'C', 'D', 'E', 'F');
$asset_key = '';
for ($x = 0; $x < 8; $x++)
$asset_key .= $chars[rand(0, 13)];
@jgornick
jgornick / gist:34051
Created December 9, 2008 19:35
Terminal Perl Based Rename Script
#!/usr/bin/perl -w
# rename
$op = shift or die "Usage: rename expr [files]n";
chomp (@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename ($was,$_) unless $was eq $_;
@jgornick
jgornick / gist:50602
Created January 22, 2009 16:39
Image(s) Observer
/*
Title: ImagesObserver
About: Author
Joe Gornick
*/
/*
Class: ImagesObserver
@jgornick
jgornick / gist:51169
Last active January 5, 2017 05:06
PHP: Generate a new htpasswd file
<?php
if (sizeof($_POST) > 0) {
$return_code = -1;
// Command to generate a new htpasswd
$command = 'htpasswd -nb ' . $_POST['new_username'] . ' ' . $_POST['new_password'];
// Execute command
exec($command, $result);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>Untitled Document</title>
</head>
@jgornick
jgornick / gist:114427
Created May 19, 2009 21:39
Blog: Zend Framework, Google Spreadsheets, and Me Example
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
class GSpreadsheet
{
public $gClient;
@jgornick
jgornick / gist:159385
Created July 31, 2009 19:29
Sequel Pro Binary Field Showing NULL
CREATE TABLE `provisionlists` (
`provision_list_id` int(11) NOT NULL auto_increment,
`provision_list_uuid` binary(16) NOT NULL,
`date_created` datetime NOT NULL,
PRIMARY KEY (`provision_list_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8
DELIMITER //
DROP TRIGGER IF EXISTS `events`.`insert_provision_list_uuid` //
@jgornick
jgornick / gist:179396
Created September 1, 2009 21:09
ZF: Captch Form Element Bug
http://www.zfforums.com/zend-framework-components-13/core-infrastructure-19/captcha-not-working-right-2577.html
## Add Element to Form [php]
<?php
public $captchaDecorators = array(
'ViewHelper'
);
$this->addElement('captcha', 'foo', array(
@jgornick
jgornick / Router.php
Created September 18, 2009 17:51
ZF: Bootstrap Process for I18n
<?php
class My_Application_Resource_Router extends Zend_Application_Resource_Router
{
public $_explicitType = 'router';
protected $_front;
protected $_locale;
/**
* Retrieve router object