Skip to content

Instantly share code, notes, and snippets.

View neocoder's full-sized avatar

Aliaksei Ladyha neocoder

View GitHub Profile
@indieisaconcept
indieisaconcept / gist:936dbf33cfc844d87968
Last active February 2, 2023 19:58
browserify + watchify + viny-transform + multiple bundles
// this setup assumes you are using gulp-config for file.src & file.dest
// but can be adapted to vanilla easily.
'use strict';
var transform = require('vinyl-transform'),
browserify = require('browserify'),
watchify = require('watchify'),
// consider using gulp-load-plugins
app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", req.headers.origin);
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Content-Length");
if (req.method == 'OPTIONS') {
return res.send(200);
}
@stilist
stilist / gist:cd7fdfabbf9ec5ed89b7
Created July 3, 2014 21:46
Installing OpenCV on OS X (using Homebrew)

Based on http://jjyap.wordpress.com/2014/02/21/installing-opencv-2-4-8-on-mac-osx-with-python-support/

  1. edit .bashrc or .bash_profile to include: export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.7/site-packages/:$PATH"
  2. brew update
  3. brew tap homebrew/science
  4. brew install opencv
  5. cd /Library/Python/2.7/site-packages/
  6. ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
  7. ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so
@magnetik
magnetik / php-cli.php
Created June 20, 2012 12:14
Php command line parser
function parseArguments()
{
array_shift($argv);
$out = array();
foreach($argv as $arg)
{
if(substr($arg, 0, 2) == '--')
{
$eqPos = strpos($arg, '=');
if($eqPos === false)
@olvado
olvado / getAverageColourAsRGB.js
Created June 27, 2011 10:19
Get the average colour of an image in javascript using getImageData in CANVAS
function getAverageColourAsRGB (img) {
var canvas = document.createElement('canvas'),
context = canvas.getContext && canvas.getContext('2d'),
rgb = {r:102,g:102,b:102}, // Set a base colour as a fallback for non-compliant browsers
pixelInterval = 5, // Rather than inspect every single pixel in the image inspect every 5th pixel
count = 0,
i = -4,
data, length;
// return the base colour for non-compliant browsers