Skip to content

Instantly share code, notes, and snippets.

View lukehedger's full-sized avatar
🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)

Luke Hedger lukehedger

🍵
(ू˃̣̣̣̣̣̣︿˂̣̣̣̣̣̣ ू)
View GitHub Profile
@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
@cmlewis
cmlewis / Rotate Videos using ffmpeg
Last active October 9, 2022 22:00
Rotate videos 90 or 180 degrees using ffmpeg
Rotate videos 90 or 180 degrees using ffmpeg.
@caike
caike / node.md
Last active August 1, 2022 03:57
post about Node.js, non-blocking I/O and the event loop

#Node.js and the Event Loop

Node.js is a framework for writing server-side JavaScript applications. It is built on top of the V8 JavaScript runtime and uses an event-driven, non-blocking I/O model that makes it perfectly suited for data-intensive real-time applications.

This blog post will describe what non-blocking I/O means and how working with the event loop can help your applications be more efficient.

##The Restaurant

"This [non-blocking I/O] model simplifies access to slow resources in a scalable way that is intuitive to JavaScript programmers and easy to learn for everyone else." - Node Up and Running.

@trueadm
trueadm / adopt-syntax.js
Last active November 27, 2021 03:32
Adding a the "adopt" keyword to the JSX syntax
// I'm suggesting we add a new "adopt X from <Y />" syntax to the JSX language
// it would de-sugar to render prop children, but look and read better than
// what we currently have. For example:
// 1.
// this sugar
function MyComponent(props) {
adopt foo from <Bar />;
return <div>{foo}</div>;
}
@thejmazz
thejmazz / .babelrc
Created February 16, 2016 18:17
async/await with webpack+babel
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@pfeilbr
pfeilbr / index.jsx
Created September 12, 2020 12:17
react tsx/jsk cdk app
// pseudocode
const { ReactCDK, App, Stack } = require('@aws-cdk/react')
const Bucket = require('@aws-cdk/react/s3')
const { CloudFrontDistribution, Origins, DefaultOrigin } = require('@aws-cdk/react/cloudfront')
const { Api, Resource, Integration } = require('@aws-cdk/react/apigateway')
const Lambda = require('@aws-cdk/react/lambda')
const EchoLambda = (
<Lambda>
{
@nolash
nolash / gist:62e6c872ec126594359d20cbe26cd3aa
Last active September 6, 2020 21:46
solidity contract disassembly interpretation

contract

pragma solidity ^0.4.11;

contract Simple {
	bytes32 public v;
	function set(bytes32 _v) {
		v = _v;
	}
@anthonysterling
anthonysterling / Vagrantfile
Last active April 29, 2020 15:28
Handy Vagrantfile for IE testing with Vagrant.
# Usage: IE={box} vagrant up
#
# Eg. IE=XPIE6 vagrant up
boxes = {
"XPIE6" => "http://aka.ms/vagrant-xp-ie6",
"XPIE8" => "http://aka.ms/vagrant-xp-ie8",
"VistaIE7" => "http://aka.ms/vagrant-vista-ie7",
"Win7IE8" => "http://aka.ms/vagrant-win7-ie8",
"Win7IE9" => "http://aka.ms/vagrant-win7-ie9",
@markdalgleish
markdalgleish / MyComponent.js
Created September 11, 2015 05:39
CSS Modules + ReactCSSTransitionGroup in React 0.14
import transitions from './transitions.css';
export default () => (
<ReactCSSTransitionGroup transitionName={transitions}>
{ ... }
</ReactCSSTransitionGroup>
);