Skip to content

Instantly share code, notes, and snippets.

View brickpop's full-sized avatar

Jør∂¡ brickpop

View GitHub Profile
@brickpop
brickpop / express-coroutine.js
Last active December 9, 2016 18:29
Coroutines example
var Promise = require('bluebird');
module.exports = function wrap(genFn) {
const promisedFunc = Promise.coroutine(genFn);
return (req, res, next) => {
promisedFunc(req, res, next).catch(next);
}
};
@brickpop
brickpop / service-worker.js
Created October 17, 2016 11:14
Simple cache service worker
var CACHE_NAME = 'tvrbo-cache';
var filesToCache = [
'./bundle.js'
];
self.addEventListener('install', function(event) {
event.waitUntil(caches.open(CACHE_NAME).then(function(cache) {
return cache.addAll(filesToCache);
}));
});
@brickpop
brickpop / README-gcloud-backup-scripts.md
Last active June 7, 2017 15:27
GCloud Backup script
@brickpop
brickpop / agnoster.zsh-theme
Created November 6, 2016 23:01
Customized ZSH Theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@brickpop
brickpop / config-default.js
Last active November 16, 2016 16:30
Example of a dev/production/env config system for NodeJS
// These are de default settings
// They may be overriden by the values in cofig-production.js if NODE_ENV=production
// They may also be averriden if an environment variable with the same name is set
// WARNING: Do not include this file directly. Use config.js instead
module.exports = {
DEBUG: true,
COMPONENT_NAME: 'PROJECT API',
HTTP_PORT: 8000,
@brickpop
brickpop / sha-digest.js
Created November 16, 2016 19:17
Password digest for NodeJS
var crypto = require('crypto');
function digestPwd(password){
var shasum = crypto.createHash('sha1');
shasum.update(password);
return shasum.digest('hex');
}
module.exports = digestPwd;
@brickpop
brickpop / nginx-proxy.conf
Last active December 13, 2024 14:22
Example of an nginx virtual host with a selective cached reverse proxy
# TO DO
# - Replace '9000' with your local port
#
# - Run certbot to geherate a certificate for domain-name.com and uncoment the HTTPS section below
# $ certbot certonly --webroot -w /var/www/certbot -d www.domain-name.com -d domain-name.com
upstream app-server {
ip_hash;
server: localhost:9000;
# server: localhost:9001; # used if clustering is available
@brickpop
brickpop / fcm-ios-react-native.txt
Last active February 1, 2017 23:48
FCM for iOS HowTo
# Extra info:
# https://firebase.google.com/docs/ios/setup
react-native init Twins
cd Twins
react-native run-ios
yarn add react-native-fcm
react-native link react-native-fcm
@brickpop
brickpop / ng-admin-uploader.js
Last active May 17, 2017 08:54
NG Admin Custom upload directive
app.directive('uploader', ['$http', '$q', 'notification', '$state', function ($http, $q, notification, $state) {
return {
restrict: 'E',
scope: {
prefix: '&',
suffix: '&'
},
link: function ($scope) {
$scope.uploaded = false;
@brickpop
brickpop / eth-address-generator.js
Created July 6, 2017 00:31
Ethereum utilities
// Generate a private key => address from a passphrase
const passphrase = process.argv[2];
if(!passphrase) {
console.log("Usage: node app 'your-passphrase-here'");
process.exit();
}
const EthUtil = require("ethereumjs-util")
const Web3 = require('web3')