Skip to content

Instantly share code, notes, and snippets.

@adamjimenez
adamjimenez / gist:5917897
Created July 3, 2013 13:36
Generate thumbnails from video files using HTML5's video tag and canvas
<?php
//where you want your thumbnails to go
$thumbs_dir = 'uploads/thumbs/';
//this should be an array of video paths
$videos = array();
if( $_POST["name"] ){
// Grab the MIME type and the data with a regex for convenience
if (!preg_match('/data:([^;]*);base64,(.*)/', $_POST['data'], $matches)) {
@stefthoen
stefthoen / tint-mixin.scss
Created September 19, 2013 14:54
Sass tint mixin
// Add percentage of white to a color
@function tint($color, $percent) {
@return mix(white, $color, $percent);
}
// Add percentage of black to a color
@function shade($color, $percent) {
@return mix(black, $color, $percent);
}
<?php
/*
Made by Kudusch (blog.kudusch.de, kudusch.de, @Kudusch)
---------
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
@andrewdc
andrewdc / gulpfile.js
Created April 14, 2014 15:39
Simple Static Site Generator with Gulp
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
rubysass = require('gulp-ruby-sass'),
fileinclude = require('gulp-file-include'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
connect = require('gulp-connect'),
@jish
jish / promise.js
Created October 28, 2014 22:35
An example "always" behavior for ES6 promises. This only works if you do not create / return intermediate promises.
// A thing I want to do
// This flow only involves **one** promise, for example an ajax call
// None of the subsequent `then` or `catch` calls, return new promises.
var explode = false;
var promise = new Promise(function(resolve, reject) {
if (explode) {
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
# Type(<scope>): <subject>
# <body>
# <footer>
# Type should be one of the following:
# * feat (new feature)
# * fix (bug fix)
# * docs (changes to documentation)
@nathansmith
nathansmith / this-is-madness.css
Last active October 6, 2015 10:36
Examples of CSS selector strength.
* {}
tag {}
[attribute] {}
[attribute="value"] {}
.class {}
@jkingsman
jkingsman / github-remove-diff-markers-bookmarklet.js
Last active June 7, 2017 09:02
Remove the '+' and '-' from GitHub diff view; helpful when copying large swaths of code from a diff.
javascript:(function(){for(var elements=document.getElementsByClassName("blob-code-inner"),i=0;i<elements.length;i++)(elements[i].parentNode.classList.contains("blob-code-addition")||elements[i].parentNode.classList.contains("blob-code-deletion"))&&(elements[i].innerHTML=elements[i].innerHTML.substring(1));})();
@giumas
giumas / Logging - SQLite handler
Last active February 15, 2023 02:23
A minimal SQLite handler for the python logging module
from __future__ import absolute_import, division, print_function, unicode_literals
import sqlite3
import logging
import time
__version__ = "0.1.0"
initial_sql = """CREATE TABLE IF NOT EXISTS log(