Skip to content

Instantly share code, notes, and snippets.

View alex-cory's full-sized avatar
🔥
🤔

Alex Cory alex-cory

🔥
🤔
View GitHub Profile
@alex-cory
alex-cory / 0_reuse_code.js
Created January 3, 2014 22:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alex-cory
alex-cory / php autoloader #snippet
Last active August 29, 2015 13:56
Example autoloader. #snippet
function autoloader($class)
{
include_once 'classes/' . strtolower($class) . '.php';
}
spl_autoload_register(autoloader);
// http://goo.gl/8xmrcx
// http://goo.gl/bHXxrX
@alex-cory
alex-cory / php debug console #snippet
Created March 5, 2014 07:42
Great for debugging php when using the terminal. You can put little checks in where ever is necessary and easily find your debugging spots to remove them.
# ------------------------------------------------------------------
echo '--- check 1 ---------------------------------------' . "\n";
# DEBUG ------------------------------------------------------------
var_dump($something);
# ------------------------------------------------------------------
echo '---------------------------------------------------' . "\n";
# ------------------------------------------------------------------
@alex-cory
alex-cory / php log #snippet
Created March 5, 2014 07:44
This will show how many seconds it took to load
/**
* Write a line to a log file
*
* @param string $log destination of log file
* @param string $message message to log
* @return void
*/
function writeLog( $log , $message ) {
if (! file_exists( $log ) ) {
@alex-cory
alex-cory / php error reporting #snippet
Created March 5, 2014 08:55
Turns the error reporting on for php.
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
@alex-cory
alex-cory / php array #snippet
Created March 5, 2014 18:59
Just to make it quicker to create an array.
// Array with the Teacher class's data | $teacher is the class instantiated
$teacher_Data = #array(
[
'user_id' => $teacher->user_id,
'user_type' => $teacher->user_type,
'name' => $teacher->first_name . ' ' . $teacher->last_name,
'email_address' => $teacher->email_address
]; #);
@alex-cory
alex-cory / php server test #snippet
Created March 14, 2014 20:11
Tests to see what $_SERVER variables are working. If it Works then it displays: ☺ + output, Otherwise it displays: ⃠ Nada.. Zilch
// < ? php
// ——————————————————————————————————————————————————————————————————————————
# Just a PHP file to put on your local server (as I don't have enough memory)
$indicesServer = array('PHP_SELF',
'argv',
'argc',
'GATEWAY_INTERFACE',
'SERVER_ADDR',
'SERVER_NAME',
@alex-cory
alex-cory / php date #snippet
Created March 17, 2014 02:10
Just in case you forget about your php date formatting!
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
@alex-cory
alex-cory / php debug function #snippet
Created March 17, 2014 09:45
Here my little contribution for a simple yet handy debug function. Stolen from the php documentation. :)
<?php
/**
* dbug (mixed $expression [, mixed $expression [, $... ]])
* Author : dcz
* Feel free to use as you wish at your own risk ;-)
*/
function dbug() {
static $output = '', $doc_root;
$args = func_get_args();
if (!empty($args) && $args[0] === 'print') {
@alex-cory
alex-cory / osascript debug #snippet
Created March 21, 2014 08:32
Little way to debug applescript. Also see: http://goo.gl/ZEFzdc
display dialog "my variable: " & myVar