Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
idle computing

B okbel

💭
idle computing
View GitHub Profile
@okbel
okbel / generate-icons.sh
Created Jul 8, 2019
Generates icons given a PNG
View generate-icons.sh
#!bin/sh
# Exit the script on any command with non 0 return code
set -e
npx sharp -i ./content/images/icon.png -o ./static/icons/favicon-16x16.png resize 16
npx sharp -i ./content/images/icon.png -o ./static/icons/favicon-32x32.png resize 32
npx sharp -i ./content/images/icon.png -o ./static/icons/favicon-96x96.png resize 96
npx sharp -i ./content/images/icon.png -o ./static/icons/icon-512x512.png resize 512
npx sharp -i ./content/images/icon.png -o ./static/icons/icon-384x384.png resize 384
@okbel
okbel / ahre.js
Last active Mar 18, 2018
Sabado 3AM
View ahre.js
// Stato - State managment - Since javascript is non-reactive
function createStore(reducer, initialState) {
var store = {};
store.state = initialState;
store.listeners = [];
function subscribe(listener) {
store.listeners.push(listener);
}
@okbel
okbel / File1.png
Last active Mar 8, 2018
Pride Reaction Plugin - Creando un plugin para Talk
View component.js
import React from 'react';
class Component extends React.Component {
constructor() {
super();
this.state = {
data: [],
};
}
View importer.js
import {client as clientPlugins} from 'pluginsConfig';
function importer () {
let context,
importedFiles;
function buildContext() {
/**
* buildContext creates the context for the plugins
* require.context(<path>, true, <regexp>
View gist:fb2cba26ca0b7c4aad7ba071816718e8
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/bel/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
View immutablejs.md

InmutableJS

InmutableJS is a library from Facebook that provides a series of inmutable data structures. They are always immutable. The reference to them can change but the data inside of them cannot which means you can build predictable and reliable state models. And it becomes really easy to manage your application state. Immutable.js

More about Immutable Data and React React.js Conf 2015 - Immutable Data and React - YouTube

Why ImmutableJS?

  • Immutable Data is faster
  • Tracking mutation and Maintaining state is difficult
  • Encourages you to think differently about how data flows through your application
@okbel
okbel / get-middle.clj
Last active Sep 9, 2016
Daily Kata # 1 - Get Middle
View get-middle.clj
(defn get-middle [x]
(if (odd? (count x))
(subs x (Math/floor (/ (count x) 2.0)) (+ (Math/floor (/ (count x) 2.0)) 1))
(subs x (- (/ (count x) 2.0) 1)(+ (/ (count x) 2.0) 1))
))
;; Better
(defn is-even [s] (= 0 (mod (count s) 2)))
(defn mid [s] (int (Math/ceil (/ (count s) 2))))
View gist:60569e218211baf3c4d643d3eb529820
var s = "JavaScript syntax highlighting";
alert(s);
```javascript
componentDidMount() {
  const contNode = this.refs.cont;
  // Do stuff!
}
```
You can’t perform that action at this time.