Skip to content

Instantly share code, notes, and snippets.

@chmac
chmac / wp-cron.sh
Created May 2, 2012 10:49 — forked from fcingolani/wp-cron.sh
Bash Script to execute wp-cron.php on a Multisite Wordpress installation, extracting database info from wp-config.php.
#!/bin/bash
# Script inspired by https://gist.github.com/1025598
#### WARNING ####
#### Please be careful with this script. The use of eval $(find) is dangerous.
#### If a user can upload a file called wp-config.php anywhere onto your site,
#### they can probably execute arbitrary commands via this script.
#### You have been warned. GPL, no warranty.
# Inspired by http://stackoverflow.com/questions/7586995/read-variables-from-wp-config-php
@chmac
chmac / replication-delay.sh
Created February 12, 2014 12:48
Script called from monit to check replication delay
#!/bin/bash
# Specify the threshold over which an error should be flagged
# Defaults to 60, but can be passed like ./script threshold
if [ -z $1 ]
then
threshold=60
else
threshold="$1"
if [[ $threshold != +([0-9]) ]]
@chmac
chmac / example.coffee
Last active August 29, 2015 14:01
Filtered results in Meteor
# Server
Meteor.publish 'foo', (searchQuery) ->
return Foo.find
bar: searchQuery
# Client
Meteor.subscribe 'foo', Session.get 'searchQuery'
# {#each foo} in your template and then to update:
Session.set 'searchQuery', 'some new query'
@chmac
chmac / heroku-pets.yaml.json
Last active August 29, 2015 14:08
heroku-pets.yaml JSONified
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "PetStore on Heroku"
},
"host": "petstore-api.herokuapp.com",
"basePath": "/pet",
"paths": {
"/": {
@chmac
chmac / bootstrap.yml
Last active September 4, 2015 12:40
Ansible bootstrapping
---
# A simple playbook to add the ansible dependencies and the foo user.
# The site.yml playbook can then lock down permission (deny root login) and so
# on, so long as this playbook has been run. The site.yml playbook will only
# work once this has been run, so it should be safe.
# Half of this file is commented out because I never got round to fixing the
# issue that some machines need an initial user of root and some ubuntu.
@chmac
chmac / README.md
Last active December 14, 2015 14:36
Meteor version in UI

Goals

Show the user a version string which identifies the version of the client code they are running. We don't need to know what version the database or server is running, so any kind of collection or method approach would fail because it will automatically update all clients. We want something hard coded into the client code, yet generated dynamically at build (deploy) time.

Solution

We create a template called version which we include in a remote corner of the UI. As part of our deployment process we put the last git commit hash into that file.

Notes

@chmac
chmac / security-update-notifier.sh
Created February 14, 2017 20:37
Bash script to generate an email when security updates are pending on Ubuntu
#!/bin/bash
# Grab the pending updates like 4;2
updates=$(/usr/lib/update-notifier/apt-check 2>&1)
# If there are no pending updates, exit now
if [ $updates == "0;0" ]
then
exit
fi
@chmac
chmac / high_load_to_email.sh
Created February 14, 2017 20:40
Utility script to send output of ps to an email during high load (needs to be called from something like monit)
#!/bin/bash
echo "$(/bin/ps auxww)$(/usr/bin/top -bn1)" | /usr/bin/mail -s "HOST high load psauxww" EMAIL
@chmac
chmac / run.sh
Created June 15, 2018 14:20
Fix Mono No certificates found error on MacOS
#!/bin/sh
# The error was:
# No certificates found, you can install some with one of these commands:
# cert-sync /etc/ssl/certs/ca-certificates.crt #for Debian based systems
# cert-sync /etc/pki/tls/certs/ca-bundle.crt #for RedHat derivatives
# Read more: http://www.mono-project.com/docs/about-mono/releases/3.12.0/#cert-sync
# From here: http://www.mono-project.com/docs/about-mono/releases/4.8.0/#tls-12-support
# The fix was:
@chmac
chmac / keybase.md
Created December 5, 2018 08:52
keybase.md

Keybase proof

I hereby claim:

  • I am chmac on github.
  • I am chmac (https://keybase.io/chmac) on keybase.
  • I have a public key ASBlXrckkl_qm4RO6yRmMJKdg3soGBOoL32P2C_jxvMS_wo

To claim this, I am signing this object: