Skip to content

Instantly share code, notes, and snippets.

View baamenabar's full-sized avatar
:octocat:
yeah, that

B. Agustín Amenábar Larraín baamenabar

:octocat:
yeah, that
View GitHub Profile
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@maroun-baydoun
maroun-baydoun / flatten.ts
Last active March 16, 2021 22:40
Flatten an array of arrays in TypeScript
const flatten = < T = any > (arr: T[]) => {
const reducer = < T = any > (prev: T[], curr: T | T[]) => {
if (curr.constructor !== Array) {
return [...prev, curr];
}
return curr.reduce(reducer, prev);
};
return arr.reduce(reducer, []);
};
@abayer
abayer / Jenkinsfile
Created February 15, 2017 15:17
An example Declarative Pipeline Jenkinsfile for Feb 15 2017 demo
// A Declarative Pipeline is defined within a 'pipeline' block.
pipeline {
// agent defines where the pipeline will run.
agent {
// This also could have been 'agent any' - that has the same meaning.
label ""
// Other possible built-in agent types are 'agent none', for not running the
// top-level on any agent (which results in you needing to specify agents on
// each stage and do explicit checkouts of scm in those stages), 'docker',
const fileHash = crypto.createHash('md5').update(fileContents).digest('hex');
@adamterlson
adamterlson / Propsal.md
Last active October 24, 2021 16:59
Lightning talk proposal for the Reactive 2016 Conference: Reconceptualizing react applications as a function

Lightning talk proposal for the Reactive 2016 Conference. Here's a handy retweet link

If you want to hear this talk, or if you just want to support me, please star ⭐ the Gist!

When I started writing React apps, I approached components as if they were “just the V in MVC!” Seriously, we’ve all heard it.

I have found this to be an inferior way of thinking about and building React applications. It makes people treat React as a drop-in replacement for something like a Backbone or Angular 1.x View. In other words, people treat it like a glorified template system with partials and don’t harness the power of its functional paradigms.

This talk is about a functional way to write and conceptualize entire React applications.

@mattboon
mattboon / webfont-localstorage.js
Last active June 26, 2016 02:09
webfont-localstorage.js
function supportsWoff2() {
"use strict";
/*global FontFace*/
// Source: https://github.com/filamentgroup/woff2-feature-test
if (!window.FontFace) {
return false;
} else {
var f = new FontFace('t', 'url("data:application/font-woff2,") format("woff2")', {});
f.load();
return f.status === 'loading';
@domenic
domenic / 0-github-actions.md
Last active April 8, 2024 23:35
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@nikoskip
nikoskip / gist:2336cde7ec864a5ffcb9
Created August 13, 2014 19:18
Obtener tamaño contenedor final de acuerdo a items con distintas medidas
<?php
/**
* Útil cuando se necesita calcular el tamaño de un paquete a enviar en el cual
* dentro van N productos con distintas medidas.
*
* Con este algoritmo se puede obtener el tamaño de la caja contenedora final necesaria.
*/
$dimensiones = array(0, 0, 0); // Largo, alto, ancho
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 22, 2024 01:47
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k