Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DavidWells's full-sized avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@creativecoder
creativecoder / Git Notes.md
Created April 17, 2014 23:25
git version control notes

Git Version Control

  • Understanding git
    • Anatomy of git
      • HEAD
        • Think of it as the snapshot of your last commit
        • Pointer to the current branch reference, which is the last commit you made or the last commit that was checked out
      • Index
  • Snapshot of your next commit
@allfro
allfro / bring_back_windows
Created June 12, 2014 00:29
Bring all out of bounds Mac windows back in bounds
on run {input, parameters}
tell application "Finder"
set _bounds to get bounds of window of desktop
end tell
tell application "System Events"
set ids to (unix id of processes whose name is equal to "java")
repeat with _id in ids
tell (first process whose unix id is equal to _id)
@pdewouters
pdewouters / gist:1680885
Created January 26, 2012 03:56
display plugin download count from wordpress.org repository
function wpc_get_plugin_dl_count(){
$payload = array(
'action' => 'plugin_information',
'request' => serialize(
(object)array(
'slug' => 'pinterest-rss-widget',
'fields' => array('description' => true)
)
)
);
@aprakasa
aprakasa / gist:4264372
Created December 12, 2012 02:34
Using transients on a single loop inside WordPress
<?php
/**
* Using transients on a single loop inside WordPress
*
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
$loop = get_transient( 'loop' );
if ( false === $loop ) {
// Show the last 100 tweets from the custom post type tweets.
@jacopotarantino
jacopotarantino / twerkify.js
Created October 12, 2015 14:59
Twerkify - Make your website twerk.
(function () {
'use strict'
/**
* @module Twerkify
* @description Thank you for twerking. Use at your own risk.
*/
console.log('Thank you for twerking')
var json_request
@KoryNunn
KoryNunn / gist:5194180
Last active December 15, 2015 03:29
Simple closest element.
function closest(target, selector){
while(target && target.parentNode && Array.prototype.slice.apply(target.parentNode.querySelectorAll(selector)).indexOf(target)<0){
target = target.parentNode;
}
return target === document ? null : target;
}
@ijin
ijin / slack.js
Last active January 19, 2016 00:12
aws lambda function to post slack
var aws = require('aws-sdk');
var kms = new aws.KMS({ region: 'us-east-1' });
var encrypted_slack_hook = 'CiD0R0tv46w7LNpO0GlZpLfZk2O0Oy66IF83rG6olDY7yBK0AQEBAgB49EdL\nb+OsOyzaTtBpWaS32ZNjtDsuuiBfN6xuqJQ2O8gAAACLMIGIBgkqhkiG9w0B\nBwagezB5AgEAMHQGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMWk63DEyG\ne+3v8STHAgEQgEfYBkRk3roZCsirvAsWbPhGN15PqfGA58M/Vh3ZqHFFCkf9\nceSWkIii4SZz3tlpHu3AXjk3x2AWTCMmVTX2EUkawF5sTNsNZA==\n';
//console.log('Loading function');
exports.handler = function(event, context) {
console.log('Received event:', JSON.stringify(event, null, 2));
var p = {CiphertextBlob: new Buffer(encrypted_slack_hook, 'base64')};
@allanlei
allanlei / notifySlack.js
Created August 31, 2015 03:14
AWS Lambda Slack notification via SNS events
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/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';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
exports.handler = function(event, context) {
(event.Records || []).forEach(function (rec) {
@tylr
tylr / server.js
Last active January 19, 2016 00:15
Running Ember FastBoot in AWS Lambda
var path = require('path');
var FastBootServer = require('./lib/models/server');
var outputPath = 'fastboot-dist';
var appName = 'dummy';
var server = new FastBootServer({
appFile: findAppFile(outputPath, appName),
vendorFile: findVendorFile(outputPath),
htmlFile: findHTMLFile(outputPath)
});
@nam178
nam178 / AwsLambdaDemo.js
Last active January 19, 2016 00:16
Demonstration on how to send email with AWS Lambda + SES
var myPersonalEmailAddress = 'nam@catapultsports.com';
var aws = require('aws-sdk');
var ses = new aws.SES({apiVersion: '2010-12-01'});
exports.handler = function(event, context) {
if (false == !!event.ClientName)
{
context.fail('Missing clientName');
return;