Skip to content

Instantly share code, notes, and snippets.

@alepeino
alepeino / deferred.js
Created July 21, 2018 21:30
deferred (simple Promise implementation)
// https://gist.github.com/fernandezpablo85/d020ea0efada7f5d4ab746f803ce723c
class deferred {
thens = []
then (fn) {
this.thens.push(fn)
return this
}
@alepeino
alepeino / webpack.config.dev.js
Created December 26, 2017 20:54
CRA Eject + SASS + Tailwind + PurgeCSS
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
@alepeino
alepeino / lumo-build
Last active December 5, 2017 16:00
calvin --debug build
lumo -c src:~/.m2/repository/org/clojure/tools.analyzer.jvm/0.7.0/tools.analyzer.jvm-0.7.0.jar:~/.m2/repository/com/cognitect/transit-cljs/0.8.239/transit-cljs-0.8.239.jar:~/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar:~/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar:~/.m2/repository/org/clojure/clojurescript/1.9.89/clojurescript-1.9.89.jar:~/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20150505-021ed5b3/google-closure-library-third-party-0.0-20150505-021ed5b3.jar:~/.m2/repository/com/google/javascript/closure-compiler/v20160315/closure-compiler-v20160315.jar:~/.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar:~/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20151016-61277aea/google-closure-library-third-party-0.0-20151016-61277aea.jar:~/.m2/repository/com/google/javascript/closure-compiler-externs/v20150505/closure-compiler-externs-v20150505.jar:~/.m2/repository/com/google/guava/guava/17.
// https://vuejs.org/v2/guide/components.html#DOM-Template-Parsing-Caveats
const originalRender = ReactDOM.render
const components = { }
function renderElement (e, i) {
return e.tagName
? React.createElement(
components[e.localName] || e.localName,
Array.from(e.attributes).reduce((r, n) => { r[n.localName] = eval(n.nodeValue); return r; }, { key: i }),
<?php
namespace App;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Pagination\LengthAwarePaginator;
trait ResponsableQuery
{
@alepeino
alepeino / macros.clj
Last active November 24, 2017 17:44
clj macros
(defmacro compact [& args]
(assert (and (every? symbol? args)
(every? (comp var? resolve) args))
"Each of the arguments must be a defined symbol")
(zipmap (map keyword args) args))
@alepeino
alepeino / index.html
Last active March 9, 2017 19:34
Vue test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://unpkg.com/vue"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.0/vue.min.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/vue.resource/1.2.1/vue-resource.min.js"></script> -->
function quicksort(arr, comp0) {
if (arr.length <= 1) {
return arr;
}
const comp = comp0 ? comp0 : (a, b) => parseInt(a) - parseInt(b);
const pivot = arr[0];
const higher = [];
const lower = [];
@alepeino
alepeino / index.js
Last active March 1, 2017 18:22
Request animation frame Zoom
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")