This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| /* | |
| - image path should be relative | |
| - taken from http://placehold.it/100x100 | |
| */ | |
| background-image: url('./100x100.png'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "syscall" | |
| "unsafe" | |
| ) | |
| var ( | |
| kernel32 = syscall.NewLazyDLL("kernel32.dll") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var nodeExternals = require('webpack-node-externals') | |
| module.exports = { | |
| entry: './src/index.js', | |
| target: 'web', | |
| resolve: { | |
| extensions: ['', '.js'] | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import $ from 'jquery' | |
| var MyLib = { | |
| doSomething() { | |
| // ... | |
| } | |
| } | |
| export default MyLib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($) { | |
| var MyLib = { | |
| doSomething() { | |
| // ... | |
| } | |
| } | |
| // amd/umd mumbo jumbo | |
| // simplified for the sake of brevity | |
| if (typeof window !== 'undefined') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function binToDecimal (n) { | |
| var i = s = 0, h | |
| while (h = n[i]) { | |
| s += (1 << n.length - ++i) * h | |
| } | |
| return s | |
| } |
NewerOlder