Skip to content

Instantly share code, notes, and snippets.

@mithereal
mithereal / Site.Plug.Bot.Seo
Last active June 23, 2017 18:35
route bots to a custom route so we can seed them with seo friendly content via plug
defmodule Site.Plug.Bot.Seo do
import Plug.Conn
@doc """
This plug will route bots to a custom route so we can seed them with seo friendly content
requires (add to mix): {:ua_inspector, "~> 0.13" }
"""
@url "/to_url"
def init(options), do: options
@mithereal
mithereal / verify.php
Last active February 2, 2017 22:06
test filezilla fites in filezilla.xml for validity
<?php
//this will test and validate your filezilla exported sites ie filezilla.xml file run this in the dir filezilla.xml is ie
//'php verify.php filezilla.xml' or
//'php verify.php filezilla.xml verify' to validate ftp details
//an html file called filezilla_status will contain the ftp info
$xml_file = $argv[1];
if(isset($argv[1] && $argv[1] == "verify")){
$test_ftp = true;
#!/bin/bash
## This script will observe a directory and compress/optimize .png and .jpg files
## Created to optimize incoming images on ubuntu / aws server
## jpegoptim, jpgcompress, pngquant and inotify-tools
## 2016 Jason Clark ([email protected])
DIRECTORY_TO_OBSERVE="/var/www/html/image/cache"
@mithereal
mithereal / QuickGit.php
Last active July 1, 2016 22:03 — forked from lukeocodes/QuickGit.php
Current git version.
<?php
class QuickGit {
private $version;
function __construct() {
if(function_exists('exec')) {
exec('git describe --always',$version_mini_hash,$error);
if($error == 0 ){
exec('git rev-list HEAD | wc -l',$version_number);
exec('git log -1',$line);
@mithereal
mithereal / smartd.conf
Created February 7, 2016 18:59
smartmon settings
# Sample configuration file for smartd. See man smartd.conf.
# Home page is: http://smartmontools.sourceforge.net
# $Id: smartd.conf 3651 2012-10-18 15:11:36Z samm2 $
# smartd will re-read the configuration file if it receives a HUP
# signal
# The file gives a list of devices to monitor using smartd, with one
@mithereal
mithereal / index.html
Created December 13, 2015 20:47
Search Github Cards via React.js
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js" data-semver="2.1.4" data-require="jquery@*"></script>
<script data-require="moment.js@*" data-semver="2.10.2" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
@mithereal
mithereal / Git-precommit-hook-mysqldump
Last active April 14, 2021 00:12
Git pre-commit hook for MySQL database backup ( remote mysqldump + Git push )
#!/bin/bash -e
# -e means exit if any command fails
DBHOST=address.to.your.server
DBUSER=username
DBPASS=password # do this in a more secure fashion
DBNAME=DBNAME
GITREPO=/where/is/your/repo
DUMP=$GITREPO/where/you/store/dumps
NEW=$DUMP/schema.sql
OLD=$NEW.old
#!/bin/bash
while sleep 55
do
players_list=$(gdbus call --session --dest org.freedesktop.DBus \
--object-path / --method org.freedesktop.DBus.ListNames | \
awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[\[\]()\x27]/, ""); print $1; }')
for player in $players_list
do
state=$(gdbus call --session \
@mithereal
mithereal / backup-github.sh
Last active August 29, 2015 14:26 — forked from bjtitus/backup-github.sh
A shell script to backup your Github organization's repos.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
GHBU_API=${GHBU_API-"https://api.github.com"} # base URI for the GitHub API
GHBU_GITHOST=${GHBU_GITHOST-"<CHANGE-ME>.github.com"} # the GitHub hostname (see comments)
# I recommend using an API token so it is easily trackable and removable.
# Note that you MUST have SSH keys for a user with the access to all repos set up
@mithereal
mithereal / mysqli2boss.php
Last active August 29, 2015 14:24
This will convert your mysqli schema to chicago boss base app, create models, controllers, and views based on the schema
#!/usr/bin/php -q
<?php
### This will convert your mysql schema to chicago boss base app, create models, controllers, and views based on the schema
### place under the app root ex /appname/mysqlitoboss.php
### run from cli ex./mysqlitoboss.php or php -f mysqlitoboss.php
/* Define STDIN in case if it is not already defined by PHP for some reason */