Skip to content

Instantly share code, notes, and snippets.

@hiphopsmurf
hiphopsmurf / haproxy.cfg
Created January 9, 2018 22:17 — forked from T0MM0R/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@hiphopsmurf
hiphopsmurf / mysql-create-db-user.sh
Created January 2, 2018 23:08 — forked from MagePsycho/mysql-create-db-user.sh
Bash Script: Create MySQL Database & User
#!/bin/bash
#
# Script to create MySQL db + user
#
# @author Raj KB <[email protected]>
# @website http://www.magepsycho.com
# @version 0.1.0
################################################################################
@hiphopsmurf
hiphopsmurf / .maintenance
Created December 29, 2017 08:45 — forked from mikemanger/.maintenance
Example WordPress .maintenance file. maintenance.php is optional but useful for styling the message the public will see (it is also used when updating WordPress conponments), drop it in your wp-content folder.
<?php
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr( $cookie, 'wordpress_logged_in_' ) ) {
$loggedin = true;
}
}
return $loggedin;
}
@hiphopsmurf
hiphopsmurf / README.md
Created November 23, 2017 03:05 — forked from steveosoule/README.md
jQuery.getScript Cached

jquery.getScriptCached.js

jQuery's $.getScript function is a quick and easy way to include external JavaScript files into a website. However, its default implimentation will not cache the script file for the client.

The following information describes how you can itilize cached versions of $.getScript

Usage

  1. Include jquery, if it's not already.
@hiphopsmurf
hiphopsmurf / jquery.getScript.js
Created November 23, 2017 03:02 — forked from tmilewski/jquery.getScript.js
Replace the normal jQuery getScript function with one that supports debugging and which references the script files as external resources rather than inline. Helps with debugging in IE.
// Helps with IE debugging.
jQuery.extend({
getScript: function(url, callback) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
var done = false; // Handle Script loading
script.src = url;
script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
@hiphopsmurf
hiphopsmurf / SaveAs-UTF8.py
Created November 5, 2017 00:18 — forked from ptim/SaveAs-UTF8.py
ST3 super simple plugin: Save the current file with encoding UTF8, then close.
import sublime, sublime_plugin
'''
A response to: http://stackoverflow.com/questions/19831757/how-to-create-macro-in-sublime-text-3-with-saveas-and-close-file-command
Save the current file with encoding UTF8, then close.
To trigger the command with 'Command Option Shift 8',
add the following to your Sublime Text > Preferences > Keybindings - User
@hiphopsmurf
hiphopsmurf / gist:dc1c2bae643819f88e90891ae37203bc
Created March 8, 2017 18:02 — forked from jimkutter/gist:1370525
List of US States in a PHP array
<?php
array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
@hiphopsmurf
hiphopsmurf / luhn.java
Created February 24, 2017 01:33 — forked from mdp/luhn.java
Luhn algorithm (mod10) in Java
/**
* Luhn Class is an implementation of the Luhn algorithm that checks validity of a credit card number.
*
* @author <a href="http://www.chriswareham.demon.co.uk/software/Luhn.java">Chris Wareham</a>
* @version Checks whether a string of digits is a valid credit card number according to the Luhn algorithm. 1. Starting with the second to last digit and
* moving left, double the value of all the alternating digits. For any digits that thus become 10 or more, add their digits together. For example,
* 1111 becomes 2121, while 8763 becomes 7733 (from (1+6)7(1+2)3). 2. Add all these digits together. For example, 1111 becomes 2121, then 2+1+2+1 is
* 6; while 8763 becomes 7733, then 7+7+3+3 is 20. 3. If the total ends in 0 (put another way, if the total modulus 10 is 0), then the number is valid
* according to the Luhn formula, else it is not valid. So, 1111 is not valid (as shown above, it comes out to 6), while 8763 is valid (as shown
* above, it comes ou
@hiphopsmurf
hiphopsmurf / README.md
Created January 18, 2017 17:50 — forked from foosel/README.md
OctoPrint Filetab plugin & configuration instructions

Moving the "Files" component from the sidebar to the tab section

  1. Create .octoprint/plugins/filetab and .octoprint/plugins/filetab/templates
  2. Copy __init__.py to .octoprint/plugins/filetab
  3. Copy filetab_tab.jinja2 to .octoprint/plugins/filetab/templates
  4. Modify .octoprint/plugins/config.yaml to include files in the disabled values for sidebar (see example)
  5. Optional: Adjust the order for tab if you want the "Files" tab to be placed somewhere else than after the regular tab components (see example)
  6. Restart OctoPrint, verify in the log that it discovered the plugin
@hiphopsmurf
hiphopsmurf / replace-wp-dashboard.php
Created January 17, 2017 18:56 — forked from wpscholar/replace-wp-dashboard.php
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/