Skip to content

Instantly share code, notes, and snippets.

View brickpop's full-sized avatar

Jør∂¡ brickpop

View GitHub Profile
@brickpop
brickpop / README-gcloud-backup-scripts.md
Last active June 7, 2017 15:27
GCloud Backup script
@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 / 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 / 1-server-setup.sh
Last active May 23, 2018 18:41
Debian Jessie Server setup
#!/bin/bash
# Vanilla Debian Jessie Setup
sudo su -
# DEBIAN JESSIE SETUP SCRIPT
# -------------------------------------------------------------------------
# VARIABLES
@brickpop
brickpop / index.js
Last active May 5, 2017 11:08
Build ng-admin with Webpack
// CSS
require('../node_modules/ng-admin/build/ng-admin.min.css');
// ALL IN ONE
require('ng-admin/build/ng-admin-only.min');
// JS
// var angular = require('angular/angular.min.js');
require('angular-ui-bootstrap/dist/ui-bootstrap-tpls.js');
require('angular-bootstrap/ui-bootstrap.min');
@brickpop
brickpop / index.js
Created July 27, 2016 18:07
Mailing with images attached
import config from 'config';
import { sendMail } from './mailer';
export function sendValidationEmail(recipientEmail, userId, validationToken){
let htmlContent, txtContent, title;
title = "Welcome to Right Side Coffee"
htmlContent = `<html><head><style> body { font-family: monospace; }</style></head><body>
<p>Welcome to Right Side Coffee,</p>
<p>To activate your account, click on <a href="${config.SERVER_URL}/en/confirm/${userId}/${validationToken}">the link here</a>.</p>
@brickpop
brickpop / .babelrc
Last active July 27, 2016 18:00
Development Config Files
{
"presets": [
"es2015",
"react",
"stage-1"
],
"plugins": [
"transform-decorators-legacy"
],
"compact": true
@brickpop
brickpop / push.android.js
Last active September 13, 2016 22:34
NodeJS Push Notification Routines
var config = require('../config.js');
var gcm = require("node-gcm");
var gcmConnection = new gcm.Sender(config.GCM_KEY);
global.Promise = require('bluebird');
var zip = require('lodash/zip');
var feedbackHandlers = [];
function send(pushTokens, message, payload, expiry, unreadCounter){
return new Promise((resolve, reject) => {
@brickpop
brickpop / gulpfile.js
Last active July 27, 2016 16:59
Gulp iOS/Android icon/splash generator
var gulp = require('gulp');
// ICONS
gulp.task('icons', function() {
var lwip = require('lwip');
// Default
lwip.open('resources/icon.png', function(err, image){
if(err) return console.error(err);
image.batch().cover(57, 57).writeFile('resources/ios/icon/icon.png', 'png', {transparency: 'auto'}, function(){if(err)console.error(err);});
@brickpop
brickpop / apn-pem-convert.sh
Last active July 27, 2016 17:02
iOS APN certificate conversion
#!/bin/bash
# CREATE CERTS
echo "Android: http://dev.tapjoy.com/faq/how-to-find-sender-id-and-api-key-for-gcm/"
echo "iOS: http://quickblox.com/developers/How_to_create_APNS_certificates"
# EXTRACT P12 > PEM
openssl pkcs12 -in apn-push-prod.p12 -out apn-push-prod.pem -nodes -clcerts