Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
yeah, that

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

:octocat:
yeah, that
View GitHub Profile
@DawidMyslak
DawidMyslak / vue.md
Last active Apr 16, 2021
Vue.js and Vuex - best practices for managing your state
View vue.md

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

Modyfing 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 Mar 16, 2021
Flatten an array of arrays in TypeScript
View flatten.ts
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 Feb 15, 2017
An example Declarative Pipeline Jenkinsfile for Feb 15 2017 demo
View Jenkinsfile
// 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',
View md5-hash-in-node.js
const fileHash = crypto.createHash('md5').update(fileContents).digest('hex');
@adamterlson
adamterlson / Propsal.md
Last active Oct 2, 2019
Lightning talk proposal for the Reactive 2016 Conference: Reconceptualizing react applications as a function
View Propsal.md

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 Jun 26, 2016
webfont-localstorage.js
View 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 Apr 6, 2021
Auto-deploying built products to gh-pages with Travis
View 0-github-actions.md

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 Aug 13, 2014
Obtener tamaño contenedor final de acuerdo a items con distintas medidas
View gist:2336cde7ec864a5ffcb9
<?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 Mar 16, 2021
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
View sm-annotated.html
<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 Apr 18, 2021
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel10k

Powerlevel10k