Skip to content

Instantly share code, notes, and snippets.

View ianthekid's full-sized avatar

Ian Ray ianthekid

View GitHub Profile
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@treyhunner
treyhunner / findpi
Created December 30, 2012 19:28
Script for finding Raspberry Pi computers on the network. The scripts searches for MAC addresses starting with `b8:27:eb:` (the Ethernet port on the Pi) and `80:1f:02` (Edimax wifi USB dongle).
#!/bin/sh
if which nmap > /dev/null ; then
echo "Running nmap as root\n"
IP_RANGE=$(ip addr | grep "inet " | awk '{ print $2}' | grep -v 127.0.0)
sudo nmap -sP $IP_RANGE | grep -B2 -i 'b8:27:eb\|80:1f:02'
else
if which arp-scan > /dev/null ; then
echo "Running arp-scan as root\n"
sudo arp-scan --interface=eth0 --localnet | grep 'b8:27:eb\|80:1f:02'
else
@mrazzari
mrazzari / multisite_delete_revisions.php
Last active November 9, 2024 00:45
WP - Multisite delete revisions
<pre><?php
// WordPress Multisite - Delete all revisions from all posts in a netword.
// Quick hack by @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/multisite_delete_revisions.php
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@michaelcarwile
michaelcarwile / functions.php
Created August 15, 2014 12:06
Gravity Forms Submit Button Add CSS Class
<?php
//* Copy below this line */
add_filter( 'gform_submit_button', 'form_submit_button', 10, 2 );
function form_submit_button($button, $form) {
return '<input type="submit" class="button custom-class-here" id="gform_submit_button_' . $form['id'] . '" value="' . $form['button']['text'] . '">';
}
@eriteric
eriteric / movegfjstofooter.php
Last active December 27, 2024 20:31
Load gravity forms JS in footer
// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );
// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
$content = 'document.addEventListener( "DOMContentLoaded", function() { ';
return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );
@brev
brev / git-overwrite-branch.sh
Created May 14, 2015 21:27
Git overwrite branch with another branch
# overwrite master with contents of seotweaks branch (seotweaks > master)
git checkout seotweaks # source name
git merge -s ours master # target name
git checkout master # target name
git merge seotweaks # source name
@eladnava
eladnava / mongodb-s3-backup.sh
Last active September 13, 2024 11:42
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@gnovaro
gnovaro / lamp_setup.sh
Last active July 19, 2019 14:33
PHP Lamp Setup Nginx + PHP 7.3
#!/bin/bash
# One Click LAMP Server Installer (Ubuntu/Debian) - Roskus
# @author Gustavo Novaro
# @version 3.3.1
# @url https://gist.github.com/gnovaro/5295150774be1794028c15c83313c16e
# Run: sudo ./lamp_setup.sh
###############################################
#Servidor Web http
apt-get install -y nginx
@PetrGlad
PetrGlad / darktable-export.sh
Last active October 20, 2024 02:47
Darktable batch export example
# Some docs imly source can be a directory, but it does not work actually.
# Below is a workaround
for p in a-source-folder/*
do
# Note that uppercase JPG suffix is not recognized so adding "jpg" to output file name.
darktable-cli --width 3000 --height 3000 --hq true $p $(dirname $p)-export/$(basename ${p%.JPG}.jpg);
done