Skip to content

Instantly share code, notes, and snippets.

View jesse1981's full-sized avatar
💭
Nerding

Jesse Bryant jesse1981

💭
Nerding
View GitHub Profile
@jesse1981
jesse1981 / modCharting.vbs
Created April 20, 2013 15:42
Module for automatic spreadsheet formatting and chart generation in Excel.
Public Sub ChartAll()
On Error GoTo Handler
Worksheets.Add before:=Worksheets(1)
Sheets(1).Name = "Summary"
Sheets(1).Activate
'Application.ScreenUpdating = False
' Fix issue with invalid data type to MakeArray
Dim strSheetName As String
' end fix
@jesse1981
jesse1981 / directoryToArray.php
Last active December 16, 2015 11:19
PHP function to return a directory tree to an array.
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if (($file != "." && $file != "..") &&
(is_dir($directory. "/" . $file)) &&
($recursive)) $array_items = array_merge($array_items,
directoryToArray($directory. "/" . $file, $recursive));
if (is_dir($directory. "/" . $file)) {
$file = $directory . "/" . $file;
@jesse1981
jesse1981 / modRegistry.vbs
Last active January 11, 2024 11:16
Some sample registry get/set/monitor examples in VB Script.
const KEY_QUERY_VALUE = &H0001
const KEY_SET_VALUE = &H0002
const KEY_CREATE_SUB_KEY = &H0004
const DELETE = &H00010000
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
@jesse1981
jesse1981 / acao.php
Created April 23, 2013 15:02
Cross Domain Resource Sharing example
function isAllowedOrigin($origin) {
// your logic here
//...
return true;
}
if (($_SERVER["HTTP_ORIGIN"]=="http://www.yoursite.com.au") || (isAllowedOrigin($_SERVER["HTTP_ORIGIN"]))) {
header("Access-Control-Allow-Origin: *");
}
@jesse1981
jesse1981 / docCookies.js
Created May 6, 2013 12:14
Library provided by Mozilla for JS cookie handling.
var docCookies = {
getItem: function (sKey) {
return unescape(document.cookie.replace(new RegExp("(?:(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*)|.*"), "$1")) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
@jesse1981
jesse1981 / .htaccess
Created May 7, 2013 23:32
Typical htaccess rewrite implementation
RewriteEngine On
RewriteRule ^js - [L,NC]
RewriteRule ^img - [L,NC]
RewriteRule ^css - [L,NC]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)$ index.php?module=$1&action=$2&id=$3&format=$4 [QSA,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)$ index.php?module=$1&action=$2&id=$3 [QSA,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)$ index.php?module=$1&action=$2 [QSA,L]
RewriteRule ^(.*)$ index.php?module=$1 [QSA,L]
@jesse1981
jesse1981 / fetchgrams.js
Created May 7, 2013 23:42 — forked from harthur/fetchgrams.js
Fetch Instagram images which contain specified tag.
var http = require("http"),
url = require("url"),
fs = require("fs"),
async = require("async"),
Instagram = require('instagram-node-lib');
Instagram.set('client_id', /* client key */);
Instagram.set('client_secret', /* client secret */);
fetchTag('cat', 400);
var FB = require('fb');
FB.api('oauth/access_token', {
client_id: process.env.FACEBOOK_APP_ID,
client_secret: process.env.FACEBOOK_SECRET,
grant_type: 'client_credentials'
}, function(res) {
if (!res || res.error) {
console.log('error occurred when getting access token:', res && res.error);
return;
@jesse1981
jesse1981 / gist:5537104
Created May 7, 2013 23:43 — forked from cyberwani/gist:5432824
Prevent a plugin being updated with a Wordpress update
<?php
add_filter( 'http_request_args', 'my_plugin_prevent_update_check', 10, 2 );
function my_plugin_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[$my_plugin] );
unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
$r['body']['plugins'] = serialize( $plugins );
}
@jesse1981
jesse1981 / put-request.php
Created May 7, 2013 23:44 — forked from till/put-request.php
Example of reading PHP input data to array.
<?php
$_PUT = array();
parse_str(file_get_contents('php://input'), $_PUT);
?>