Skip to content

Instantly share code, notes, and snippets.

View david-martin's full-sized avatar

David Martin david-martin

View GitHub Profile
@david-martin
david-martin / gist:1363666
Created November 14, 2011 10:14 — forked from feedhenry-gists/gist:1015194
Local Storage Call
// Save
$fh.data({
"act": "save",
"key": "foo",
"val": "bar"
}, function () {
// save success
}, function (code) {
// save failed
} );
@david-martin
david-martin / application.js
Created August 1, 2013 08:39
Adding connect.static() to hostapp in application.js
var nodeapp = require("fh-nodeapp");
var _ = require('underscore');
var util = require('util');
var connect = require('fh-connect');
nodeapp.HostApp.init();
nodeapp.HostApp.serveApp(require('main.js'), function (err, server) {
// determine where the first route is defined on the middleware stack
var firstRouteIndex;
var firstRoute = _(server.stack).find(function (item, index) {
@david-martin
david-martin / gist:7481449
Created November 15, 2013 09:12
fh.init callbacks
$fh.init({}, function () {
// init ok
}, function (code, res) {
alert(res.error);
})
@david-martin
david-martin / index.js
Created June 3, 2014 14:22
Using fhc, migrate all fh2 apps to fh3
#!/usr/bin/env node
var fh = require('fh-fhc');
var async = require('async');
// Init fhc
fh.fhc.load(function (err) {
if (err) return console.error(err);
// Target my domain and login
fh.target(['https://testing.feedhenry.me','me@example.com','password'], function(err, ok) {
if (err) return console.error(err);
#!/bin/bash
#
# This script will mount /Users in the boot2docker VM using NFS (instead of the
# default vboxsf). It's probably not a good idea to run it while there are
# Docker containers running in boot2docker.
#
# Usage: sudo ./boot2docker-use-nfs.sh
#
@david-martin
david-martin / .bashrc
Created July 23, 2015 12:04
dtop: docker status for all running containers
function dtop() {
CONTAINER_IDS=$(docker ps | awk '{print $NF}' | grep -v NAMES)
printf "Running 'docker stats' for:\n$CONTAINER_IDS\n..."
docker stats $CONTAINER_IDS
}
@david-martin
david-martin / env.diff
Created October 12, 2016 15:36
Added a new env from the 'Environment Variables' screen of a Cloud App, then pushed the env var. The result was the new env var added to the cloud app dc, but the removed of the 2 REDIS env vars
diff nodejs-cloudappdefaz2zl_env_before.txt nodejs-cloudappdefaz2zl_env_after.txt
1a2
> test1=test1
3c4
< FH_EMAIL=rhmap-admin@example.com
---
> FH_EMAIL=supercore@example.com
30,31d30
< FH_REDIS_PORT=6379
< FH_REDIS_HOST=redis-1476286123337z2zl
Ensure Docker >=v1.10.3 is installed
Ensure fhc is installed from this branch
​npm i -g git://github.com/feedhenry/fh-fhc.git#workshop
Ensure 'oc' is installed
(Linux) curl -O http://192.168.1.247:8080/oc-linux.tar.gz
(Mac) curl -O http://192.168.1.247:8080/oc-mac.tar.gz
Clone these public repos into the same folder (preferably ~/work/)
feedhenry/fh-core-openshift-templates#master
feedhenry/fh-mbaas-openshift-templates#master
feedhenry/fh-cup#master
bytes = null;
// look for the Base64 encoded part of the line to decode
// both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes
for (String part : keyLine.split(" ")) {
if (part.startsWith("AAAA")) {
bytes = Base64.decodeBase64(part);
break;
}
}
if (bytes == null) throw new IllegalArgumentException("no Base64 part to decode");
@david-martin
david-martin / buildconfig.yaml
Last active November 22, 2016 13:33
Kubernetes & OpenShift resources
apiVersion: v1
kind: BuildConfig
metadata:
name: nodejsexample
namespace: nodejsexample
selfLink: /oapi/v1/namespaces/nodejsexample/buildconfigs/nodejsexample
uid: cce45238-b0b6-11e6-89c0-0abb8905d551
resourceVersion: '23124054'
creationTimestamp: '2016-11-22T13:23:04Z'
labels: