Skip to content

Instantly share code, notes, and snippets.

View AndrewDavid's full-sized avatar
🌭
Making dumb content

Andrew-David J. AndrewDavid

🌭
Making dumb content
View GitHub Profile
@tylerhall
tylerhall / strong-passwords.php
Created August 12, 2010 21:38
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@victorbstan
victorbstan / php_object_to_array.php
Created December 17, 2010 04:18
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);
@drewjoh
drewjoh / example.php
Last active January 11, 2021 18:06 — forked from mloberg/example.php
A Simple Postmark PHP Class with Attachments
<?php
require("postmark.php");
$postmark = new Postmark("your-api-key","from-email","optional-reply-to-address");
$result = $postmark->to("reciver@example.com")
->subject("Email Subject")
->plain_message("This is a plain text message.")
->attachment('File.pdf', base64_encode(file_get_contents('sample.pdf')), 'application/pdf')
@gre
gre / easing.js
Last active June 27, 2024 15:37
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@flarb
flarb / AssetGPULoader.cs
Created July 22, 2012 19:06
Unity3d GPU Pre-loader
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class AssetGPULoader : MonoBehaviour {
public Camera activeCamera;
RenderTexture _rt;
@mbostock
mbostock / .block
Last active July 18, 2024 02:14
Gradient Along Stroke
license: gpl-3.0
@drawcode
drawcode / WebWindow.cs
Created January 22, 2013 18:11
Unity WebWindow (browser within unity editor window, helpful for tools that require a web view or more beyond basic controls).
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
public class WebWindow : EditorWindow {
static Rect windowRect = new Rect(100,100,800,600);
static BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
static StringComparison ignoreCase = StringComparison.CurrentCultureIgnoreCase;
@chriskoch
chriskoch / getter-setter-traits.php
Created February 13, 2013 10:47
Using PHP 5.4 traits as getter and setter helper
<?php
trait Getters
{
/**
* calls Class::$name()
*
* @param string $name the name of a requested property
* @return mixed the result
*/
@ThrivingKings
ThrivingKings / Sess-io.js
Last active December 17, 2015 02:09
Using localStorage, Sess-io will check against a stored expiration stamp and force the user to log-out once the session has expired
// Sess-io by @ThrivingKings
// http://thrivingkings.com/read/Sess-iojs-handles-session-expiration-in-pure-JavaScript
// Date fix for good ole IE8
if (!Date.now) {
Date.now = function() {
return new Date().valueOf();
}
}
@ThrivingKings
ThrivingKings / Retinaizer.css
Created August 1, 2013 20:21
Use JavaScript and CSS to quickly upgrade your images for Retina displays (Retinaizer)
div {
background: url('/img/background.jpg');
}
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
div {
background-image: url('/img/background@2x.jpg');
background-size: 100px 100px;
// This should match the dimensions of the original resolution image