Skip to content

Instantly share code, notes, and snippets.

View radermacher's full-sized avatar

Richard Radermacher radermacher

View GitHub Profile
@radermacher
radermacher / php_object_to_array.php
Last active September 16, 2015 10:00 — forked from victorbstan/php_object_to_array.php
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);
@radermacher
radermacher / install.sh
Last active August 29, 2015 14:13 — forked from fideloper/install.sh
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@radermacher
radermacher / vhost.sh
Created January 14, 2015 22:08 — forked from fideloper/vhost.py
Create vHost Ubuntu Lamp-Server (bash)
#! /bin/bash
# Run this as sudo!
# I move this file to /usr/local/bin/vhost and run command 'vhost' from anywhere, using sudo.
#
# Show Usage, Output to STDERR
#
function show_usage {
cat <<- _EOF_
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]+)/([^/]*)$ resize.php?size=$1&file=$2

LESS Coding Guidelines

Medium uses a strict subset of LESS for style generation. This subset includes variables and mixins, but nothing else (no nesting, etc.).

Medium's naming conventions are adapted from the work being done in the SUIT CSS framework. Which is to say, it relies on structured class names and meaningful hyphens (i.e., not using hyphens merely to separate words). This is to help work around the current limits of applying CSS to the DOM (i.e., the lack of style encapsulation) and to better communicate the relationships between classes.

Table of contents

<?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

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@radermacher
radermacher / buzz5.js
Created January 15, 2014 01:02 — forked from 19h/buzz5.js
var hash = function (seed) {
seed = seed || 123456789;
var r = function (m_w) {
var m_w = m_w || 123456789;
var m_z = 987654321;
var mask = 0xffffffff;
return function () {
m_z = (36969 * (m_z & 65535) + (m_z >> 16)) & mask;
@radermacher
radermacher / README.md
Last active December 25, 2015 11:59 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007
@radermacher
radermacher / .htaccess
Last active December 23, 2015 00:09 — forked from basbl/.htaccess
block users except facebook bot
AuthName "Realm"
AuthUserFile /path/to/.htpasswd
AuthType Basic
Satisfy Any
<Limit GET POST>
Order Deny,Allow
Deny from all
#https://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper
#-> whois -h whois.radb.net -- '-i origin AS32934' | grep ^route