Skip to content

Instantly share code, notes, and snippets.

View redzumi's full-sized avatar
:electron:
BBK

Evgeny Bykovskikh redzumi

:electron:
BBK
  • Moscow, Russia
View GitHub Profile
const maybe = (params: RequestInit) => ({ ...params });
const reduce = (acc: RequestInit, curr: RequestInit) => ({ ...acc, ...curr });
const set = (...params: RequestInit[]) => params.reduce(reduce, {});
const headers = (data: HeadersInit): RequestInit => ({ headers: data });
const json = (fn: Promise<Response>) => fn.then(res => res.json());
const post = (): RequestInit => ({ method: 'post' });
const body = (data: string): RequestInit => ({ body: data });
const content = (type: string) => ({ 'Content-Type': type });
@redzumi
redzumi / tls-generate.sh
Created March 2, 2019 23:44
TLS Certificates
# Notice: app port should be correct, ex. 587
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out tls_cert.crt -keyout tls_key.key
openssl rsa -in tls_key.key -text > tls_key.pem
openssl x509 -inform PEM -in tls_cert.crt > tls_cert.pem
# and dont forget about chmod
# chmod 400 /root/certs/tls_key.key
@redzumi
redzumi / colourz.js
Created October 28, 2016 20:26
Average color of image.
export default class Colourz {
constructor() {
}
//TODO async/await
getAverageColorRGB(url, callback) {
try {
this.getImageBase64(url, (err, imgBase64) => {
if(err) return callback(err);
//new image