Skip to content

Instantly share code, notes, and snippets.

View mihaiserban's full-sized avatar
💭
👨🏻‍💻✨

Mihai Serban mihaiserban

💭
👨🏻‍💻✨
View GitHub Profile
@mihaiserban
mihaiserban / image-react.js
Last active May 17, 2019 09:06
React image fallback - in case src fails try to load a placeholder instead
import React from "react";
import PropTypes from "prop-types";
class Image extends React.Component {
constructor(props) {
super(props);
this.state = { src: props.src };
}
componentWillReceiveProps(nextProps) {
@mihaiserban
mihaiserban / encryption.js
Created October 29, 2018 22:01 — forked from vlucas/encryption.js
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);
@mihaiserban
mihaiserban / aws.js
Created November 2, 2018 14:28
AWS SNS handle SES bounce/complaints
const express = require("express");
const router = express.Router();
const User = require("../models/user");
const AWS = require("aws-sdk");
AWS.config.update({
accessKeyId: process.env.accessKeyId,
secretAccessKey: process.env.secretAccessKey,
region: "us-east-1"
});
@mihaiserban
mihaiserban / button.js
Last active December 3, 2018 11:40
Button example v2
/* global window */
import React from "react";
import classNames from "classnames";
const Button = ({
dark,
light,
disabled = false,
onPressed,
width = 200,
@mihaiserban
mihaiserban / payments.js
Created December 7, 2018 18:40
braintree payments stream search transactions
router.get('/payments', verifyJWT_MW, function(req, res) {
try {
let transactions = [];
const stream = Braintree.gateway.transaction.search(function(search) {
search.customerId().is(req.user.account.braintreeCustomerId);
});
stream.on('ready', function() {
console.log(stream.searchResponse.length());
@mihaiserban
mihaiserban / sync_fork.md
Created March 1, 2019 11:42
Sync a github repo from the original fork
  1. Clone your favorite project:

git clone https://github.com/teleporthq/teleport-code-generators.git

  1. Add remonte branch:

git remote add --track master teleporthq https://github.com/teleporthq/teleport-code-generators.git

  1. Verify if the remote was added:
@mihaiserban
mihaiserban / .ebignore
Created March 15, 2019 21:25
deploy Next.JS on AWS Elastic Beanstalk using YARN as package manager
node_modules
@mihaiserban
mihaiserban / custom_scrollbar.css
Created April 1, 2019 10:58
custom scrollbar ::-webkit-scrollbar
/* total width */
::-webkit-scrollbar {
width: 14px;
}
::-webkit-scrollbar-track {
box-shadow: inset 0 0 14px 14px transparent;
border: solid 4px transparent;
}
@mihaiserban
mihaiserban / printer.cfg
Last active April 27, 2024 22:58
Klipper Ender 5 Plus stock printer config
# This file contains pin mappings for the Creality Ender 5 Plus.
# Ender 5 Plus stock uses a Creality v2.2 board, similar to CR-20 Pro.
# To use this config, the firmware should be compiled for the AVR atmega2560.
# See the example.cfg file for a description of available parameters.
[stepper_x]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
Calibrate probe
PROBE_CALIBRATE
TESTZ Z=-.1
ACCEPT
SAVE_CONFIG
SET_GCODE_OFFSET Z=+.010