Skip to content

Instantly share code, notes, and snippets.

<?php
/* Here is some generic error handling code, not related to actual sample */
set_error_handler('my_error_handler');
set_exception_handler('my_exception_handler');
function my_exception_handler($e) {
exit('Houston! We have a problem: <br />'.$e);
}
@nickfishman
nickfishman / testGzipKnox.js
Created May 4, 2013 07:49
Proof of concept of streaming a file through zlib and into s3, without storing the entire file in memory. knox-mpu provides support for Amazon's multipart upload, which allows us to stream an arbitrary amount of data without specifying the content-length ahead of time.
/**
* Proof of concept of streaming a file through zlib and into s3,
* without storing the entire file in memory. knox-mpu provides support
* for Amazon's multipart upload, which allows us to stream an arbitrary
* amount of data without specifying the content-length ahead of time.
*/
var knox = require('knox'),
fs = require('fs'),
zlib = require('zlib'),
MultiPartUpload = require('knox-mpu');
@dciccale
dciccale / git_branch.sh
Created May 11, 2013 18:02
Bash script to get the current git branch and last commit
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@JosefJezek
JosefJezek / eps-to-svg.md
Last active March 19, 2024 07:48
EPS to SVG Conversion using Inkscape

EPS to SVG using Inkscape Gittip

Author: Josef Jezek

# Install Inkscape on Ubuntu
sudo apt-get install inkscape
@jakemmarsh
jakemmarsh / controllers.js
Last active May 20, 2019 10:15
AngularJS Service with Controller for access to Google API with Javascript Client (and RequireJS)
define(['angular', 'services'], function (angular) {
'use strict';
return angular.module('myApp.controllers', ['myApp.services'])
.controller('IndexCtrl', ['$scope', 'googleService', function ($scope, googleService) {
$scope.login = function () {
googleService.login().then(function (data) {
// do something with returned data
console.log(data.email);
@edinella
edinella / mongooseUniquenessValidation.js
Last active September 12, 2016 17:42
Mongoose uniqueness validator, case-sensitive or not
// context
var mongoose = require('mongoose');
mongoose.connect('mongodb://...');
/**
* Generates Mongoose uniqueness validator
*
* @param string modelName
* @param string field
* @param boolean caseSensitive
@d3noob
d3noob / .block
Last active November 30, 2019 18:20
Simple d3.js Bullet Chart example
license: mit
@sarahmonster
sarahmonster / db_local.sql
Last active December 19, 2015 03:19
A series of files to include in your git directory in order to automate WordpPress database syncs.
USE DBNAME_LOCAL;
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="siteurl";
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="home";
@toddbluhm
toddbluhm / app.js
Created July 11, 2013 06:09
This is a modified version of the Cloudant reverse-proxy solution for setting up a CORS Couchdb request. The version uses the nano framework instead of request framework which allows for the use of cookie authentication rather than just hardcoded basic auth. This solution was tested using Pouchdb in the browser, reverse-proxied back through a no…
var forward = require('./middleware/forward.js'); //reverse proxy
var nano = require('connect-nano');
// instantiate `app` et al
//After app.use(express.cookieParser());
app.use(nano('https://username.cloudant.com')),
app.use(forward(/\/db\/(.*)/));
// Copyright 2012 Google Inc. All Rights Reserved.
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,