Skip to content

Instantly share code, notes, and snippets.

@olsgreen
olsgreen / jquery.table-sorter.js
Last active December 31, 2015 07:59
Simple jQuery Table Sorter
/**
* Simple jQuery Table Sorter
*/
(function($){
$(document).ready(function(){
// Table Sorter
$('table.sortable').each(function () {
@olsgreen
olsgreen / ghost.sh
Created December 15, 2013 11:01
CentOS Ghost Init Script.Requires daemonize to run.
#!/bin/sh
#
# ghost - this script starts and stops the ghost npm daemon
#
# chkconfig: - 85 15
# description: Ghost - just another blog
# processname: ghost
# pidfile: /var/run/ghost.pid
# Source function library.
@olsgreen
olsgreen / supervisord.conf
Created December 24, 2013 13:35
Supervisord Program Example
[program:myqueue]
command=php artisan queue:listen --env=your_environment
directory=/path/to/laravel
stdout_logfile=/path/to/laravel/app/storage/logs/myqueue_supervisord.log
redirect_stderr=true
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@olsgreen
olsgreen / password-complexity.js
Created January 30, 2014 11:25
jQuery Password Complexity Meter
/**
* jQuery Password Complexity Meter
*/
(function ($) {
$(document).ready(function () {
$('.check-complexity').complexify({minimumChars:6, strengthScaleFactor:0.3}, function(valid, complexity){
$('.password-complexity > .progress-bar').css('width', complexity + '%');
@olsgreen
olsgreen / gist:fe87c4394f6fb3c19bd7
Last active August 29, 2015 14:23
Concrete 5.7.x Multiple File Selection
// Wire the trigger to show the file manager dialog
$('#addImageBtn').click(function () {
// Launch the dialog
ConcreteFileManager.launchDialog(function (data) {
// Parse the callback data to get more file detail
ConcreteFileManager.getFileDetails(data.fID, function(r) {
// Loop over each file and do whatever you want with it
@olsgreen
olsgreen / mysql_backup.php
Created September 24, 2016 17:10
mysqli version of David Walsh's PHP MySQL backup script
/* backup the db OR just a table
* See original: https://davidwalsh.name/backup-mysql-database-php
*/
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysqli_connect($host,$user,$pass,$name);
//get all of the tables
if($tables == '*')
@olsgreen
olsgreen / sphp.sh
Created November 15, 2016 09:41 — forked from w00fz/sphp.sh
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@olsgreen
olsgreen / strip-tags.php
Last active April 29, 2018 07:02
Strip all tags from an HTML fragment except selected tags and their attributes.
<?php
/*
* Strip all tags from an HTML fragment except selected tags and their attributes.
*
* $content = 'Hello world. <script>alert("XSS");</script>';
* $content .= But you can still click on this <a href="http://gog.gl" onclick="alert(\'XSS\')">link</a>';
*
* cleanHtml($content, $whitelist = ['a' => ['href']])
*
@olsgreen
olsgreen / tyre_sizes.json
Last active March 30, 2018 20:13
Common Tyre \ Tire Sizes JSON
{
"10": ["165/70"],
"12": ["155/80"],
"13": [
"155/80",
"175/70",
"175/80",
"185/60",
"185/70",
"185/80",