Skip to content

Instantly share code, notes, and snippets.

@mallendeo
mallendeo / longshadow.scss
Last active February 5, 2016 18:56
SCSS mixin for make long shadows easier
@function makelongshadow($color) {
$val: ();
@for $i from 1 through 100 {
$val: append($val, append(#{$i}px #{($i)}px 0, darken($color, 15%)), comma);
/* Uncomment the following two lines for expanded shadow */
/* $val: append($val, append(#{$i}px #{($i * 2)}px 0, darken($color, 15%)), comma);
$val: append($val, append(#{$i * 2}px #{$i}px 0, darken($color, 15%)), comma); */
}
@return $val;
}
@mallendeo
mallendeo / start-end-week.js
Created February 9, 2014 18:22
Get start and end of week with Momentjs
// include jquery, momentjs
$(function () {
var m = moment();
m.lang('es'); // week start on monday
var start = m.startOf('week').format('DD'),
end = m.endOf('week').format('DD'),
month = m.endOf('week').format('MMMM'),
afterMonth = start > end ? ' de '+m.startOf('week').format('MMMM') : '',
@mallendeo
mallendeo / clock.js
Created February 9, 2014 18:24
Simple Momentjs clock
// include jquery, momentjs
$(function () {
var m = moment();
var updateClock = function(){
var hour = m.hour() < 10 ? '0'+m.hour() : m.hour(),
minute = m.minute() < 10 ? '0'+m.minute() : m.minute();
$('#clock').text(hour+':'+minute);
}
updateClock();
setInterval(updateClock, 60000);
@mallendeo
mallendeo / gist:36d7d1b16a60061f8442
Created December 16, 2014 17:32
Image sequence to webm with audio
ffmpeg -i sequence_1%04d.png -i audio.wav -map 0:0 -map 1:0 output.webm
// sequence_100001.png ...
@mallendeo
mallendeo / toutf8.ts
Last active February 27, 2023 22:29
Convert iso-8859-1 to utf-8 in nodejs
import iconv from 'iconv'
export const convertToUTF8 = <T extends any>(body: T, fromEncoding = 'iso-8859-1'): T => {
const ic = new iconv.Iconv(fromEncoding, 'utf-8')
const buf = ic.convert(JSON.stringify(body))
return JSON.parse(buf.toString('utf-8'))
}
@mallendeo
mallendeo / sketch.applescript
Last active October 1, 2015 04:07
Open Sketch after expiration date
# This is for educational purposes only
# If you use Sketch a lot or for work you should buy it instead
# If you save this as Sketch.app it'll reopen itself
set username to long user name of (system info)
set pw to the text returned of (display dialog "Enter your password:" default answer "" with hidden answer)
set currDate to (do shell script "date +\"%m%d%H%M%y\"")
do shell script "date 0101120013" user name username password pw with administrator privileges
@mallendeo
mallendeo / parse.js
Last active August 29, 2015 14:23
Parse external DOM with js
function getParsedDOM(url, callback) {
var request = new XMLHttpRequest()
request.open('GET', url, true)
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
var parser = new DOMParser();
var doc = parser.parseFromString(this.response, "text/html");
return callback(doc)
}
@mallendeo
mallendeo / requirements.txt
Created September 12, 2015 18:45
Get the best audio from a YouTube video
youtube-dl==2015.9.9
CherryPy==3.8.0
Routes==2.2
@mallendeo
mallendeo / compile_ffmpeg.sh
Last active October 29, 2015 19:00
Compile FFmpeg with aac support
git clone https://github.com/FFmpeg/FFmpeg --depth=1
cd FFmpeg
./configure --disable-everything --disable-doc --disable-yasm \
--disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm \
--disable-devices --disable-pthreads --disable-w32threads \
--disable-network --disable-hwaccels --disable-parsers --disable-bsfs \
--disable-debug --disable-protocols --disable-indevs --disable-outdevs \
--enable-protocol=file --enable-gpl --enable-nonfree \
--enable-demuxer=mov --enable-muxer=ipod
@mallendeo
mallendeo / index.js
Last active October 1, 2015 03:57
Get Youtube download URLs
var request = require('./request')
var vm = require('vm')
var parseString = require('xml2js').parseString
var url = 'https://www.youtube.com/watch?v=si81bIoZRJQ'
var html = ''
request(url).then(function(body) {
html = body
var player = body.match(/html5player-([\w\d\-]+)\\\/html5player(.*?).js/g)