Skip to content

Instantly share code, notes, and snippets.

View tobsn's full-sized avatar

Tobsn tobsn

  • US/EU/SEA
View GitHub Profile
@mattzuba
mattzuba / 01_httpd_phpfpm.config
Last active December 20, 2022 19:53
Apache 2.4 / PHP-FPM 5.5 on Amazon Elastic Beanstalk
packages:
yum:
php55-fpm: []
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/26_phpfpm_config.sh":
mode: "000755"
owner: root
group: root
content: |
@nmcgann
nmcgann / install-cluster-client.config
Created January 13, 2016 09:10
AWS Elastic Beanstalk .ebextensions config to install Elasticache memcached cluster client (PHP 5.6)
files:
"/home/ec2-user/install-cluster-client.sh":
mode: "000744"
owner: root
group: root
content: |
#!/bin/bash
#hide old ini
if [ -a /etc/php.d/50-memcached.ini ]
then
@stagas
stagas / how-to-run-apache-and-node.js-together-the-right-way.markdown
Created December 24, 2010 14:45
How to run Apache and Node.js together (the right way)

Step 1

Get a VPS that offers 2 or more IP addresses.

Step 2

From the WHM cPanel, find the menu item Service Configuration, select Apache Configuration and then click on Reserved IPs Editor.

Step 3

@dragolabs
dragolabs / nginx-vbulletn.conf
Created August 2, 2013 04:06
nginx config for vbulletin 5 forum. And read the comments in config.php: // ****** Base URLs ****** // The following settings all deal with the url of your forum. // If set incorrectly your site/software will not function correctly. // These urls should NOT include a trailing slash <------- !!! // This is the url and web path of your root vBulle…
server {
listen 80;
server_name forum.example.com;
root /var/www/example_forum/;
index index.php;
access_log /var/log/nginx/forum.example.access.log main;
error_log /var/log/nginx/forum.example.error.log;
@JeffreyWay
JeffreyWay / snippet.xml
Created September 13, 2012 20:23
Laravel Resource - Sublime Text 2 Snippet
<snippet>
<content><![CDATA[
// ${1} Resource
Route::get('${1}s', array('as' => '${1}s', 'uses' => '${1}s@index'));
Route::get('${1}s/(:any)', array('as' => '${1}', 'uses' => '${1}s@show'));
Route::get('${1}s/new', array('as' => 'new_${1}', 'uses' => '${1}s@new'));
Route::get('${1}s/(:any)edit', array('as' => 'edit_${1}', 'uses' => '${1}s@edit'));
Route::post('${1}s', '${1}s@create');
Route::put('${1}s/(:any)', '${1}s@update');
Route::delete('${1}s/(:any)', '${1}s@destroy');
@richthegeek
richthegeek / cache_filter.php
Created March 8, 2012 16:24
Variable microcaching with Laravel
<?php
Route::filter('cache', function($response = NULL) {
$cname = 'response-' . Str::slug(URI::full());
if (!$response) {
return Cache::get($cname);
}
else if ($response->status == 200) {
$ctime = floor(pow(current(sys_getloadavg()) + 1, 5)); # cache for between 1 and 32 minutes
Cache::put($cname, $response, $ctime);
@mwesten
mwesten / auth.php
Created February 23, 2012 13:09
Laravel 3 Auth Controller
<?php
class Auth_Controller extends Base_Controller {
public $restful = true;
public function __construct() {
$this->filter( 'before', 'guest' )->except( array( 'logout', 'validate' ) );
// Note: We may not always require CSRF on login for system based logins so ignore it here.
$this->filter( 'before', 'csrf' )->on( 'post' )->except( array( 'login' ) );
}
@aaronhoffman
aaronhoffman / aws-sns-event-template-with-actual-ses-deliverynotification-sns-message
Last active January 15, 2019 19:04
Lambda function to process a Amazon SES Delivery Notification message from a SNS Topic into a DynamoDB Table
{
"Records": [
{
"EventSource":"aws:sns",
"EventVersion":"1.0",
"EventSubscriptionArn":"arn:aws:sns:us-west-2:xxxx:xxxx",
"Sns": {
"Type":"Notification",
"MessageId":"88B1B251-2E92-4FC3-BFAA-E3BBD0BAB10A",
"TopicArn":"arn:aws:sns:us-west-2:881222951025:survey-tool-ses-delivery",
@tobsn
tobsn / jquery.loader.js
Created December 10, 2010 19:50
there are many problems when you act as third party that offers a javascript file and you want to use jquery - this solved all of my problems. the little function checks if jquery is already embedded, includes it and waits until its loaded if its missing
(function(j,q,u,e,r,y,R,o,x){try{o=jQuery;if(o&&(!R||(R&&o.fn.jquery==R))){x=true}}catch(er){}if(!x||(R&&o.fn.jquery!=R)){(q=j.createElement(q)).type='text/javascript';if(r){q.async=true}q.src='//ajax.googleapis.com/ajax/libs/jquery/'+(R||1)+'/jquery.min.js';u=j.getElementsByTagName(u)[0];q.onload=q.onreadystatechange=(function(){if(!e&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){e=true;x=jQuery;jQuery.noConflict(true)(function(){y(x)});q.onload=q.onreadystatechange=null;u.removeChild(q)}});u.appendChild(q)}else{y(o)}})(document,'script','head',false,false,(function($){$(function(){
/* code goes here */
console.log($.fn.jquery);
})}));
// readable:
(function (j, q, u, e, r, y, R, o, x ) {
// IE8 undefined crash fix
try {
@creationix
creationix / inspect.js
Created December 23, 2010 06:51
a custom object inspector to help me understand JavaScript
function escapeString(string) {
string = string.replace(/\\/g, "\\\\").
replace(/\n/g, "\\n").
replace(/\r/g, "\\r").
replace(/\t/g, "\\t");
if (string.indexOf("'") < 0) {
return "'" + string + "'";
}
string = string.replace(/"/g, "\\\"");
return '"' + string + '"';