Skip to content

Instantly share code, notes, and snippets.

View bhrott's full-sized avatar
⚔️
killing zombies

Ben-Hur Santos Ott bhrott

⚔️
killing zombies
View GitHub Profile
@bhrott
bhrott / docker-compose.yml
Created February 18, 2020 11:43
Postgres + Docker-Compose
version: "3"
services:
postgres:
image: postgres:11.2-alpine
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- "5432:5432"
volumes:
@bhrott
bhrott / index.js
Created November 29, 2019 17:55
Sample Nodejs bcrypt
const bcrypt = require("bcrypt")
const SALT_ROUNDS = 10
async function hash(password) {
const salt = await bcrypt.genSalt(SALT_ROUNDS)
const hashed = await bcrypt.hash(password, salt)
return hashed
}
async function compare(password, hashed) {
@bhrott
bhrott / keyboard-view.js
Created August 22, 2019 10:41
React-Native: Scrollview + Keyboard handling
import React, { useEffect, useState } from 'react'
import { Keyboard, TextInput, UIManager, Platform } from 'react-native'
const AndroidKeyboardView = () => {
return null
}
const IOSKeyboardView = props => {
const [keyboardInfo, setKeyboardInfo] = useState(0)
const [keyboardDidShowEvent, setKeyboardDidShowEvent] = useState(null)
@bhrott
bhrott / after_res_hooks.js
Created April 25, 2019 13:46 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@bhrott
bhrott / readme.md
Created October 31, 2018 02:10
Devgrid Test

DevGrid Test

This is a test for devgrid!

@bhrott
bhrott / .gitignore
Created May 8, 2018 19:11
Base Pack Parcel + Jest
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
@bhrott
bhrott / how-to-use.md
Last active May 9, 2018 15:35
Javascript: Stormbreaker Test Lib

Stormbreaker (ultra simple test api for js in the browser)

Instalation

Just add the javascript to your html =).

<script src="stormbreaker.js"></script>
@bhrott
bhrott / KeyboardHelper.cs
Created May 3, 2018 23:51
Xamarin iOS: Handle keyboard with UIScrollView
public class KeyboardHelper
{
private UIViewController _viewController;
private UIScrollView _scrollView;
public KeyboardHelper(UIViewController viewController)
{
this._viewController = viewController;
}
@bhrott
bhrott / KeyboardBindView.swift
Created May 1, 2018 16:44
iOS KeyboardBindView extension
import Foundation
import UIKit
extension UIView {
func bindToKeyboard() {
NotificationCenter.default.addObserver(self, selector: #selector(UIView.keyboardWillChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
}
@objc func keyboardWillChange(_ notification: NSNotification) {
let duration = notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as! Double
@bhrott
bhrott / EventEmitter.swift
Created January 6, 2018 18:01 — forked from brennanMKE/EventEmitter.swift
React Native Event Emitter for RCTEventEmitter in Objective-C and Swift
class EventEmitter
/// Shared Instance.
public static var sharedInstance = EventEmitter()
// ReactNativeEventEmitter is instantiated by React Native with the bridge.
private static var eventEmitter: ReactNativeEventEmitter!
private init() {}