Skip to content

Instantly share code, notes, and snippets.

@mckelvey
mckelvey / master-git-ignore
Created November 21, 2010 17:10
This is my best case .gitignore file.
# Services #
############
*.sassc
.sass-cache
# Generic #
###########
/log/*
/tmp/*
/pids/*
# GET /entries/:hashtag/receiver
# POST /entries/:hashtag/receiver.json
def receiver
if request.method == 'GET' and !params['hub.challenge'].blank? and params['hub.mode'] == 'subscribe'
if !params['hub.verify_token'].blank?
game = Game.find_by_token(params['hub.verify_token'])
if !game.nil? and game.hashtag == params[:hashtag]
render :status => 200, :text => params['hub.challenge']
else
InstagaMe::Log.rails "bad token match for #{params['hub.verify_token']}; returning status 406"
@mckelvey
mckelvey / public.application.public_notifier.php
Created July 20, 2012 18:15
PublicNotifier (LiveWhale Application Module)
<?php
$_LW->REGISTERED_APPS['public_notifier']=array(
'title'=>'PublicNotifier',
'handlers' => array('onAfterPublicSubmission')
);
class LiveWhaleApplicationPublicNotifier {
// These two arrays are for including the users and/or groups that
@mckelvey
mckelvey / ISO-8895-15 to UTF-8
Created September 14, 2012 23:11
Character Conversion
function convertCharset($contents) {
iconv_set_encoding("internal_encoding", "ISO-8859-15");
iconv_set_encoding("output_encoding", "ISO-8859-1");
ob_start("ob_iconv_handler");
echo $contents;
$contents = ob_get_clean();
$contents = strtr($contents, array(
"\x80" => "e",
"\x81" => " ",
"\x82" => "'",
@mckelvey
mckelvey / file structure notes
Created September 28, 2012 00:40
Login Updates
\livewhale (backend)
\client
\modules
\login_updates
\private.application.login_updates.php (contents below)
\styles
\login_updates.css (contents below)
\core
...
@mckelvey
mckelvey / login_updates.css
Last active December 24, 2015 12:59
This application allows you to insert custom content underneath the login screen. Be sure to add accompanying CSS styles if needed.
/**
* Basic Login Updates Styles
* by White Whale Web Services
* http://whitewhale.net
* When using this file, place it in a /styles sub-folder of the module folder
* containing the above PHP file so that it can be found by the module code.
**/
/* Card Styles */
@mckelvey
mckelvey / private.application.hide_comments.php
Last active December 28, 2015 03:59
Place this file inside a new hide_comments folder in your backend livewhale/clients/modules folder.
<?php
/* Hide Comments
This application hides the Comments checkbox on all editors in
the LiveWhale backend management interface, except for admins. */
$_LW->REGISTERED_APPS['hide_comments']=array( // register this application
'title'=>'Hide Comments', // the module name
'handlers'=>array('onOutput')
@mckelvey
mckelvey / public.application.private_things_stay_private.php
Created December 16, 2013 22:12
One example code block... do remember to not have whitespace either before the opening <?php or after the closing ?>.
<?php
$_LW->REGISTERED_APPS['private_things_stay_private']=array( // register this application
'title' => 'Private Things Stay Private',
'handlers' => array('onLoad', 'onWidgetLoad'),
);
class LiveWhaleApplicationPrivateThingsStayPrivate {
protected $private_allowed = array(
@mckelvey
mckelvey / brightness.php
Created January 17, 2014 00:19
Image filtering methods.
<?php
// ref: http://www.phpied.com/image-fun-with-php-part-2/
// ref: http://www.php.net/manual/en/function.imagefilter.php
require('./image.php');
$value = (int) $_GET['value'];
$image = imagecreatefromjpeg($imagefile);
header("Content-type: image/jpeg");
@mckelvey
mckelvey / apache-livewhale.conf
Last active June 7, 2019 09:19
This is a fail2ban filter to protect against malicious use of an injection/vulnerability scanner (that might also be slamming your server with useless requests).
# Fail2Ban configuration file
#
# Intended to assist in protecting LiveWhale from malicious use
# of injection and vulnerabilty scanners such as:
#
# Acunetix Web Vulnerabilty Scanner
# Unknown Scanner (dubbed KIDC below)
# Unknown Scanner (dubbed RIPE below)
#
# Note: if you use penetration software for testing, add the server ip