Skip to content

Instantly share code, notes, and snippets.

View magarcia's full-sized avatar
👋
Hey!

Martin Garcia magarcia

👋
Hey!
View GitHub Profile
@magarcia
magarcia / fetchInterception.js
Created June 28, 2019 15:13
Adaptive Media Serving using Service Workers
self.addEventListener('fetch', function(event) {
if (/\.jpg$|.png$|.webp$/.test(event.request.url)) {
const url = event.request.url + `?quality=${getMediaQuality()}`;
event.respondWith(fetch(url));
}
});
import { Component, Input } from '@angular/core';
@Component({
selector: 'example-component',
})
export class ExampleComponent {
public internalVal = null;
constructor() {}
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
interface BroadcastEvent {
key: any;
data?: any;
}
@magarcia
magarcia / Yumml.md
Last active September 3, 2022 02:42
YumML - Yet Another Recipe Metadata Language
layout title description date tags
page
YumML, use YumML, not XML
Yet Another Recipe Metadata Language - you know, for food.
2011-09-21
food yumml

I won't beat around the bush - existing metadata formats for food recipes suck. Alone that would be my typical bold/arrogant claim, so I present my findings on five different formats (RecipeML, Recipe Exchange Markup Language, CookML and RecipeBook XML) to backup that statement, and then my proposed format. There was a sixth format I was looking into - MealMaster - but the recipe structure doesn't seem to be defined anywhere and as far as I know the only program to use it is MealMaster itself.

Keybase proof

I hereby claim:

  • I am magarcia on github.
  • I am magarcia (https://keybase.io/magarcia) on keybase.
  • I have a public key ASDdvBA60w-cr_b7l7UMzhL_8PGwUwpL8_I_loneQDqeDgo

To claim this, I am signing this object:

# load zgen
source "${HOME}/proj/zgen/zgen.zsh"
# check if there's no init script
if ! zgen saved; then
echo "Creating a zgen save"
zgen oh-my-zsh
# plugins
@magarcia
magarcia / Applications.md
Last active February 14, 2019 10:56
List of applications for finally move to Linux with a command line environment
@magarcia
magarcia / torrent-cleaner.sh
Created November 2, 2015 19:31
Clean finished torrents and remove files if has hard link
#!/usr/bin/env bash
function join { local IFS="$1"; shift; echo "$*"; }
REMOTE="transmission-remote --auth osmc:osmc"
DATA=`$REMOTE --list | grep Finished | awk '{print $1'}`
for i in $DATA
do
@magarcia
magarcia / backup.sh
Last active November 2, 2015 19:32
Automated RaspberryPi image backup into a backup.img.gzip
!/bin/bash
# Backup OS to the USB Hard Disk Drive
# Create a filename with timestamp for our current backup (without .img suffix)
ofile="/data/Backups/$(date +%Y-%m-%yT%T)"
# Create final filename, with suffix
ofilefinal=$ofile.img.gz
# Begin the backup process, should take about 1 hour from 8Gb SD card to HDD
@magarcia
magarcia / coffee.vim
Created October 20, 2015 09:19
JsDoc support for CoffeeScript
"" JSDoc / JSDoc Toolkit
if !exists("coffeescript_ignore_javaScriptdoc")
syntax case ignore
syntax region coffeeBlockComment matchgroup=coffeeComment start="###*" end="###" contains=coffeeDocTags,coffeeTodo,@Spell fold
" tags containing a param
syntax match coffeeDocTags contained "@\(alias\|api\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|file\|fires\|kind\|listens\|member\|member[oO]f\|mixes\|module\|name\|namespace\|requires\|template\|throws\|var\|variation\|version\|ngdoc\|scope\|priority\|animations\|restrict\|methodOf\|propertyOf\|eventOf\|eventType\|platform\)\>" nextgroup=coffeeDocParam skipwhite
" tags containing type and param
syntax match coffeeDocTags contained "@\(arg\|argument\|param\|property\|prop\|methodOf\|propertyOf\|eventOf\|eventType\)\>" nextgroup=coffeeDocType skipwhite