This file contains 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
/** | |
* A functional JavaScript library -- composition, currying, polyfills and performance. | |
* | |
* Copyright Lansana Camara, 2016 | |
* @license MIT | |
*/ | |
This file contains 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 JSON<T extends {new(...args: any[]): {}}>(ctor: T) { | |
function toSnakeCase(prop: string): string { | |
return prop.replace(/[A-Z]/g, (prop: string): string => { | |
return `_${prop.toLowerCase()}`; | |
}); | |
} | |
return class extends ctor { | |
constructor(...args: any[]) { | |
let cfg = args.shift(); |
This file contains 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
// USAGE: | |
// | |
// When you attach the infiniteScroll directive to an element, it will emit the infiniteScrollAction | |
// @Output() event every time the user has scrolled to the bottom of the element. Your loadMoreArticles | |
// function can make an HTTP call and append the results to the articles list, for example. In doing this, | |
// you effectively increase the height of the element and thus begin the process of the infiniteScroll directive | |
// again, over and over until the element height stops increasing. | |
// | |
// <div class="container" infiniteScroll (infiniteScrollAction)="loadMoreArticles()"> | |
// <div class="article" *ngFor="let article of articles"> |
This file contains 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
#!/usr/bin/env bash | |
###################################################################################### | |
# USAGE: bash bash/replace-line.sh "replace this line" "to this line" in-this-file.txt | |
###################################################################################### | |
function escapeSlashes { | |
sed 's/\//\\\//g' | |
} |
This file contains 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 hmac | |
import ( | |
"crypto/hmac" | |
"crypto/sha256" | |
"crypto/sha512" | |
"encoding/base64" | |
"encoding/hex" | |
"hash" | |
) |
This file contains 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 hmac | |
import ( | |
"crypto/sha256" | |
"crypto/sha512" | |
"testing" | |
) | |
func TestValidateCustomHashSuccess(t *testing.T) { | |
key := []byte("123456") |
This file contains 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
batch(items: any[], count: number, interval: number, iteratee: (item: any, index: number) => void) { | |
const len = items ? items.length : 0; | |
// If the count is gte the total amount, just loop through and add | |
// them all and don't bother batching. | |
if (count >= len) { | |
for (let i = 0; i < len; i++) { | |
iteratee(items[i], i); | |
} |
This file contains 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 middleware | |
import ( | |
"net/http" | |
"strconv" | |
"time" | |
"core/http/jsonapi" | |
"core/http/router" | |
"domain" |
This file contains 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
// Found on some article, forgot which. It visualizes mandelbrot set. | |
// TODO: make faster | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<script> | |
(() => { | |
// Create Canvas | |
const myCanvas = document.createElement('canvas'); |