Skip to content

Instantly share code, notes, and snippets.

@s14k51
s14k51 / react-binding-this.md
Created June 18, 2017 15:26 — forked from markerikson/react-binding-this.md
React ES6 classes, function binding, and `this`

[6:34 PM] marekweb: I started using ES6 classes for my React components because ES6 is the new hotness and all that, but I'm realizing that I can't actually name any advantages, and I have to bind methods manually. So why use classes over React.createClass?
[6:34 PM] acemarke: a few reasons
[6:35 PM] acemarke: first, classes are an official part of the language
[6:35 PM] acemarke: second, that means that tooling understands the syntax
[6:35 PM] acemarke: third, createClass is eventually going to be deprecated
[6:36 PM] acemarke: there's various solutions to the method binding issue
[6:36 PM] acemarke: the suggested one is to use the "class properties" syntax, which isn't yet final, but I think may have recently hit stage 3
[6:37 PM] acemarke: ah... no, looks like it's still stage 2. Object spread hit stage 3, that's what I was thinking of
[6:37 PM] acemarke: that said, class properties are well supported in Babel, and used in tools like create-react-app
[

@s14k51
s14k51 / encryption.js
Created September 4, 2017 02:45 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv);
@s14k51
s14k51 / moP.js
Created November 23, 2017 02:24
moP.js
import moment from 'moment';
const log = console.log;
let date1 = moment().format();
let mom = moment();
// log(moment('2017-11-21', 'YYYY-MM-DD').toISOString())
// log(moment().format())
// log(typeof date1);
// log(date1);
// Object.keys(
@s14k51
s14k51 / coverage.sh
Created January 26, 2018 04:01 — forked from novemberborn/coverage.sh
Code Coverage with Babel, Istanbul & NYC
#!/bin/bash
set -e
# Shell script to compute code coverage even after the Babel transforms have
# been applied.
# Clear previous coverage.
rm -rf coverage
# Generate test coverage based on however `npm test` performs the tests.
@s14k51
s14k51 / es6-debugging-in-vscode.md
Created January 27, 2018 17:41 — forked from dchowitz/es6-debugging-in-vscode.md
Debugging ES6 in VS Code

Debugging ES6 in VS Code

My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.

What doesn't work

My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for attaching (instead of launch) to `babel-node

@s14k51
s14k51 / dev_signed_cert.sh
Created September 20, 2019 00:35 — forked from dobesv/dev_signed_cert.sh
Script to create (1) a local certificate authority, (2) a host certificate signed by that authority for the hostname of your choice
#!/usr/bin/env bash
#
# Usage: dev_signed_cert.sh HOSTNAME
#
# Creates a CA cert and then generates an SSL certificate signed by that CA for the
# given hostname.
#
# After running this, add the generated dev_cert_ca.cert.pem to the trusted root
# authorities in your browser / client system.
#
@s14k51
s14k51 / node_nginx_ssl.md
Created September 24, 2019 00:16 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@s14k51
s14k51 / image.resize.in.github.flavored.markdown.md
Created November 9, 2019 01:07 — forked from uupaa/image.resize.in.github.flavored.markdown.md
image resize in github flavored markdown.

Image source

https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png

Try resize it!

  • ![](https://gyazo.com/eb5c5741b6a9a16c692170a41a49c858.png | width=100)
@s14k51
s14k51 / openapi.yaml
Created August 24, 2020 06:19 — forked from LM1LC3N7/openapi.yaml
OpenAPI version 3.0 for Swagger Editor & Swagger UI - Exemple
#### INFOS ####
openapi: "3.0.0"
info:
version: <PROJET VERSION>
title: <PROJET NAME>
description: >-
Multiline description allowed.
<br/>
<br/>
Lines jumps using `<br/>` are also possibles and Markdown
@s14k51
s14k51 / orthodoxc++.md
Created August 30, 2023 05:50 — forked from bkaradzic/orthodoxc++.md
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?