Skip to content

Instantly share code, notes, and snippets.

afuchs

  • New York, NY
Block or report user

Report or block afuchs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@afuchs
afuchs / API.md
Created Mar 23, 2016 — forked from iros/API.md
Documenting your REST API
View API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

View setup-statsd.sh
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
View aviaryCustomSave.js
var editor = new Aviary.Feather({
// config
onSaveButtonClicked: function() {
// 1. start custom spinner and disable editor
editor.getImageData(function(data) { // `data` contains a base64 encoding of the image
// 2. POST `data` to your own server
// 3. stop custom spinner and enable or close the editor
});
return false; // prevents editor from following defautl save behavior
}
View uploadPhotoToS3.js
var AWS = require('aws-sdk');
var fs = require('fs');
var uuid = require('node-uuid');
var UPLOAD_BUCKET = '';
var AWS_KEY_ID = '';
var AWS_ACCESS_KEY = '';
AWS.config.update({
accessKeyId: AWS_KEY_ID,
View express-ssl.js
// 1. Generate SSL cert
// > openssl genrsa -out privatekey.pem 1024
// > openssl req -new -key privatekey.pem -out certrequest.csr
// > openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
// 2. Set up your express server
var https = require('https');
var fs = require('fs');
var express = require('express');
var app = express();
View loadScript.js
function loadScript(src, callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
if (callback) {
script.onreadystatechange = script.onload = function() {
callback();
};
}
View jsbin.Iribaqa.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.js"></script>
<style>
View gist:4254088
--3a246045b5354407babd5bedb7d27a74
Content-Disposition: form-data; name="version"
0.3
--3a246045b5354407babd5bedb7d27a74
Content-Disposition: form-data; name="calltype"
renderActionList
--3a246045b5354407babd5bedb7d27a74
Content-Disposition: form-data; name="backgroundcolor"
View winston-stacktrace.js
var logger = require('winston');
// override winston.logger.log to add stacktrace along errors included
// 4 ways to include some errors in a log:
// - logger.warn('message', myError)
// - logger.warn('message', [myError1, myError2])
// - logger.warn('message', { error: myError })
// - logger.warn('message', { errors: [myError1, myError2] })
(function(logger) {
var _log = logger.log;
You can’t perform that action at this time.