Skip to content

Instantly share code, notes, and snippets.

View MagneticMule's full-sized avatar
🏠
Working from home

Thomas D. Sweeney MagneticMule

🏠
Working from home
  • Seventh Stage
  • Nottingham
View GitHub Profile
@MagneticMule
MagneticMule / ssh-copy+id
Created March 23, 2015 22:47
Copy sah key to remote host
ssh-copy-id 'user@remotehost' # Automatically installs your public key to the remote host (this is included in the openssh package)
@MagneticMule
MagneticMule / login_redirect.php
Last active August 29, 2015 14:28
Redirect to login in Wordpress
// Redirect users who arent logged in...
function login_redirect() {
// Current Page
global $pagenow;
// Check to see if user in not logged in and not on the login page
if(!is_user_logged_in() && $pagenow != 'wp-login.php')
// If user is, Redirect to Login form.
auth_redirect();
@MagneticMule
MagneticMule / ironrouter-waiton.js
Created November 5, 2015 17:37 — forked from herrhelms/ironrouter-waiton.js
how to wait on multiple subscriptions with iron:router and make it available as data in your template...
--- <yourproject.js> ---
SubscriptionOne = new Meteor.Collection('subscription1');
SubscriptionTwo = new Meteor.Collection('subscription2');
if(Meteor.isClient) {
// iron:router route
Router.route('/', {
onBeforeAction:function() {
// .. any onBeforeAction
def is_number(s):
"""Test if the passed string contains a number @ position 0"""
try:
float(s)
return True
except ValueError:
return False
def hash(s):
"""returns an MD5 hash of the passed string s
We have to encode the passed string as ascii """
hash = ''
if s is not None:
hash = hashlib.md5(s.encode('ascii', 'ignore')).hexdigest()
return hash
def read_file(file_name):
"""reads a file in to memory,
first checking the user has access rights to the file"""
try:
fp = open(file_name, 'r')
except IOError as e:
if e.errno == errno.EACCES:
return False
raise
else:
$ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t jwilder/nginx-proxy
@MagneticMule
MagneticMule / .gitignore
Created January 31, 2016 14:46 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
/**
* menu-scroll.js
*
* "Locks" the menu div when it reaches the top of the page. Relies on the class .fixed to the menu bar div
*.fixed {
* position: fixed
* top: 0;
* left: 0;
*}
*/
@MagneticMule
MagneticMule / phpdebugon.sh
Last active November 16, 2017 17:03
Enables echoing php errors to the browser
echo "php_flag display_errors 1" > .htaccess