Skip to content

Instantly share code, notes, and snippets.

View richsage's full-sized avatar

Rich Sage richsage

View GitHub Profile
# put on the server
# put in /etc/puppet/custom/plugins/facter/custom_facts.rb
require 'yaml'
if File.exist?("/etc/puppet/custom_facts.yml")
YAML.load_file("/etc/puppet/custom_facts.yml").each do |key, value|
Facter.add(key.to_sym) do
setcode { value }
end
end
@priithaamer
priithaamer / gist:1034070
Created June 19, 2011 11:01
Capistrano task to ask confirmation before deploying to production
task :ask_production_confirmation do
set(:confirmed) do
puts <<-WARN
========================================================================
WARNING: You're about to perform actions on production server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
@phpdude
phpdude / nginx.conf
Last active October 6, 2024 19:22
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@SiriusDely
SiriusDely / push_apns.php
Created May 2, 2012 00:23
Push Notification PHP Script - Apple iOS, Android C2DM, BlackBerry PPG
<?php
// Put your device token here (without spaces):
$deviceToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Put your private key's passphrase here:
$passphrase = 'xxxxxxx';
// Put your alert message here:
$message = 'A push notification has been sent!';
@mathiasverraes
mathiasverraes / phplint.sh
Created July 12, 2012 07:42
Recursive PHP Lint script
#!/bin/bash
for file in `find .`
do
EXTENSION="${file##*.}"
if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ]
then
RESULTS=`php -l $file`
@leviwilson
leviwilson / SomeActivityTest.java
Created August 28, 2012 17:30
Using the ShadowConnectivityManager in Robolectric
public class SomeActivityTest {
SomeActivity activity;
@Before
public void setUp() {
activity = new SomeActivity();
ConnectivityManager connectivityManager = getConnectivityManager();
Robolectric.shadowOf(connectivityManager).setNetworkInfo(TYPE_MOBILE, new NetworkInfo());
@arriolac
arriolac / TopCropImageView.java
Last active March 6, 2025 07:32
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by chris on 7/27/16.
@dky
dky / gist:4595997
Last active December 11, 2015 11:48
Puppet exec code to edit fstab only if acl support doesn't already exist.
exec { "add_fstab_acl":
command => "/bin/sed -i.backup '/srv/s/defaults/defaults,acl/g' /etc/fstab",
unless => "/bin/grep -E '/srv.*ext4.*defaults,acl' /etc/fstab",
path => "/usr/local/bin/:/bin/",
}
<?php
namespace Incenteev\Bundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Adrien Brault <[email protected]>
@dergachev
dergachev / upgrade-git-precise64.sh
Created July 3, 2013 14:28
Installs git 1.7.10 on Ubuntu 12.04 (Precise) using packages from the upcoming 12.10 (Quantal) release. Should work for i386 and amd64.
#
# Installs git 1.7.10 on Ubuntu 12.04 (Precise) using packages from
# the upcoming 12.10 (Quantal) release. Should work for i386 and amd64.
#
# Adapted from http://pastebin.com/TXeMw1CY
#
HOST_ARCH=`dpkg-architecture -qDEB_HOST_ARCH_CPU`
wget http://mirrors.us.kernel.org/ubuntu/pool/main/g/git/git_1.7.10.4-1ubuntu1_${HOST_ARCH}.deb \