Skip to content

Instantly share code, notes, and snippets.

View guilhermehn's full-sized avatar

Guilherme Nagatomo guilhermehn

  • PagSeguro
  • Brasil, São Paulo
View GitHub Profile
@guilhermehn
guilhermehn / fn-classnames.js
Created June 9, 2019 23:32
classnames package in four lines with Ramda
import { when, is, map, filter, compose, nth, flatten, pipe, join } from 'ramda';
const isValueTruthy = compose(Boolean, nth(1));
const getTruthyKeys = compose(map(nth(0)), filter(isValueTruthy), Object.entries);
const classnames = (...args) => pipe(flatten, filter(Boolean), map(when(is(Object), getTruthyKeys)), flatten, join(' '))(args);
console.log(classnames('foo', 'bar', ['baz', ['deep', [[{ nested: true , falseNested: false }]]]], '', false, { foobar: true, no: false }));
@guilhermehn
guilhermehn / index.css
Created April 24, 2018 11:23
url-loader example
body {
/*
- image path should be relative
- taken from http://placehold.it/100x100
*/
background-image: url('./100x100.png');
}
@guilhermehn
guilhermehn / Remove all git tags
Created March 12, 2017 16:37 — forked from okunishinishi/Remove all git tags
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@guilhermehn
guilhermehn / win32.go
Created June 23, 2016 20:27 — forked from nathan-osman/win32.go
Simple Windows GUI application written in Go
package main
import (
"log"
"syscall"
"unsafe"
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
var nodeExternals = require('webpack-node-externals')
module.exports = {
entry: './src/index.js',
target: 'web',
resolve: {
extensions: ['', '.js']
},
module.exports = {
// Your lib main file.
entry: './src/index.js',
// Where your lib will be used.
// Can be "web", "webworker", "node",
// "async-node", "node-webkit", "electron"
// If you use webpack everywhere you'll
// be fine with "node" most of the time
target: 'node',
import $ from 'jquery'
var MyLib = {
doSomething() {
// ...
}
}
export default MyLib
(function($) {
var MyLib = {
doSomething() {
// ...
}
}
// amd/umd mumbo jumbo
// simplified for the sake of brevity
if (typeof window !== 'undefined') {
function getRgba (ctx, x, y) {
var colors = ['r', 'g', 'b', 'a']
, result = {}
, data = ctx.getImageData(x, y, 1, 1)
data.forEach(function (c, i) {
result[colors[i]] = c
})
return result
@guilhermehn
guilhermehn / gist:10417176
Created April 10, 2014 19:56
Binary to Decimal
function binToDecimal (n) {
var i = s = 0, h
while (h = n[i]) {
s += (1 << n.length - ++i) * h
}
return s
}