Skip to content

Instantly share code, notes, and snippets.

View roboli's full-sized avatar
🏠
Working from home

Roberto Oliveros roboli

🏠
Working from home
View GitHub Profile
@boschDev
boschDev / UserAvatar.css
Created June 25, 2018 06:20
React Material UI User Avatar
.UserAvatar {
--UserAvatarColor: #000;
--UserAvatarSize: 40px;
position: relative;
border-radius: 100%;
text-align: center;
background-color: var(--UserAvatarColor);
font-size: var(--UserAvatarSize);
height: var(--UserAvatarSize);
width: var(--UserAvatarSize);
@sudodoki
sudodoki / flatten-maps.clj
Last active November 29, 2023 00:26
Flatten nested maps using clojure / clojurescript using compound keys
(defn get-key
[prefix key]
(if (nil? prefix)
key
(str prefix "-" key)))
(defn flatten-map-kvs
([map] (flatten-map-kvs map nil))
([map prefix]
(reduce
(fn [memo [k v]]
@vlucas
vlucas / encryption.js
Last active July 23, 2024 01:24
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (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', Buffer.from(ENCRYPTION_KEY), iv);
@lencioni
lencioni / AsyncComponent.jsx
Created January 8, 2017 17:09
<AsyncComponent> at Airbnb used for Webpack code splitting
// Usage:
//
// function loader() {
// return new Promise((resolve) => {
// if (process.env.LAZY_LOAD) {
// require.ensure([], (require) => {
// resolve(require('./SomeComponent').default);
// });
// }
// });
@dlundy
dlundy / wkhtmltopdf.java
Last active December 4, 2018 07:48
Quickie Java pipe out to wkhtmltopdf to create a pdf from a string with html
public byte[] getPdf(String html) {
byte[] results = null;
try {
// For piping in and out, we need separate args for this for some reason
String[] command = {"/usr/local/bin/wkhtmltopdf", "-", "-"};
ProcessBuilder builder = new ProcessBuilder(command);
// this eats up stderr but prevents us from having to handle it ourselves
builder.redirectErrorStream(false);
Process process = builder.start();