Skip to content

Instantly share code, notes, and snippets.

View raspo's full-sized avatar
🔥
Deleting code

Tommaso Ferrari raspo

🔥
Deleting code
View GitHub Profile
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Tommaso Ferrari",
"label": "Frontend Architect at Sysdig",
"image": "",
"email": "[email protected]",
"phone": "(213)605-0312",
"url": "",
"summary": "Frontend engineer with a passion for (good) user interfaces. I love working on products, and working alongside designers.",
@raspo
raspo / factorio.service
Last active May 22, 2017 16:26
Factorio Server Service - /etc/systemd/system/factorio.service
[Unit]
Description=Factorio Server
After=network.target
[Service]
User=factorio
Group=factorio
# We will store a pid file in your ${WRITE_DIR}/server.pid
# Adjust if you change the write dir of your server
@raspo
raspo / test.js
Last active May 24, 2016 00:56
Flatten Array
import { flatten } from 'utils';
describe('flatten', () => {
it('flatten', () => {
expect(flatten([])).toEqual([]);
expect(flatten([[], []])).toEqual([]);
expect(flatten([[1, 2, [3]], 4])).toEqual([1, 2, 3, 4]);
expect(flatten([[1, 2, 3], [4, [5, 6, [7, [8]]]], 9])).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
});
@raspo
raspo / Javascript snippets.md
Last active August 29, 2015 14:02
Javascript snippets examples

countdown.js

Takes a target date and shows a countdown on the page.

Even though this is a super simple script that serves a super simple purpose, I wanted to have some fun, making it more complicated than necessary. ;)

The script uses the javascript module pattern.

It gets initialized by passing a string representation of the date, following the mm/dd/yyyy format.

(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
@raspo
raspo / jQuery Plugin template.js
Last active January 1, 2016 14:49
A starting template for building jquery plugins
/* global jQuery: true*/
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;
(function($, window, document, undefined) {
'use strict';
// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
@raspo
raspo / gist:8039397
Created December 19, 2013 13:52
Some basic styling from my .bash_profile
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
@raspo
raspo / validate JSON
Created July 23, 2013 10:21
Simple and easy way to validate a JSON string. Will need json2.js for cross-browser support.
function isValidJson(json){
try {
JSON.parse(json);
return true;
} catch (e) {
return false;
}
}
// usage
@raspo
raspo / mixin
Created June 13, 2013 21:29
Easy media queries in sass
@mixin respond-to($media) {
@if $media == small {
@media only screen and (max-width: 420px) { @content }
}
@else if $media == medium {
@media only screen and (max-width: 768px) { @content }
}
@else if $media == large {
@media only screen and (max-width: 980px) { @content }
}
@raspo
raspo / gist:4222587
Created December 6, 2012 07:41
Get parameter from querystring
function getQueryParam( param ) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for( var i = 0; i < vars.length; i++ ){
var pair = vars[i].split('=');
if( decodeURIComponent( pair[0] ) == param ){
return decodeURIComponent(pair[1]);
}
}
}