Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mose's full-sized avatar

Mose mose

View GitHub Profile
<?php
foreach($data as $key => $row) {
$categories = array($row['Category']);
foreach($row as $h => $v) {
if (substr($h, 0, 3) == 'pr:') {
$cat = substr($h, 3);
if ($v != '') {
$categories[] = $cat;
}
unset($data[$key][$h]);
Verifying my Blockstack ID is secured with the address 1NusJpR4yVaWZPVMqtXdp7p2Xy2magjbV5 https://explorer.blockstack.org/address/1NusJpR4yVaWZPVMqtXdp7p2Xy2magjbV5
@mose
mose / k8sandbox-remote.md
Last active January 19, 2018 14:37
kubesandbox remote access

As I was testing around with https://bitnami.com/stack/kubernetes-sandbox I wanted to remotely access it

First find the token, by getting on the server, which is configured to trust any local user to be cluster admin with kubectl

TOKEN=$(kubectl get secrets -n kube-system | grep default-token | awk '{print $2}')
kubectl describe secret $TOKEN -n kube-system | grep token:

Now give that default user the cluster admin role

kubectl create clusterrolebinding admin-role --clusterrole=cluster-admin --serviceaccount=kube-system:default
@mose
mose / kubesandbox-trick
Last active January 3, 2018 10:30
note about fixing auth problem with bitnami kubesandbox
# on the kubesandbox VM
# sudo apt-get install apache2-utils
NEWHASH=$(echo -n `htpasswd -nb <user> <password>` | base64)
kubectl edit secret basic-auth --namespace=kube-system
# replace data.auth with $NEWHASH
module.exports = (robot) ->
robot.router.post "/#{robot.name}/capture/:feed", (req, res) ->
filepath = path.join process.env.FILE_BRAIN_PATH, "#{req.params.feed}"
payload = req.body
fs.appendFileSync filepath, "\n---------------------\n#{moment().utc().format()}\n\n"
fs.appendFileSync filepath, JSON.stringify(req.body, null, 2), 'utf-8'
res.setHeader 'content-type', 'text/plain'
res.status(200).end ''
require 'json'
file = ARGV[0]
unless file
puts "Usage: ruby #{$0} <json filename of the export>"
exit
end
unless File.exist? file
@mose
mose / Dokku Intro
Last active August 29, 2015 14:05
dokku presentation using shellplay
?##/ Hello
\e[1;32mHello\e[0m
- I'm mose, SysAdmin at \e[1;34mFaria Systems\e[0m
- \e[1;34mDevops\e[0m duties
= helping developers to deploy their apps

Keybase proof

I hereby claim:

  • I am mose on github.
  • I am mose (https://keybase.io/mose) on keybase.
  • I have a public key whose fingerprint is 3449 95C9 B897 D7F3 053F 64CD 0DEF 40EC 5741 40CA

To claim this, I am signing this object:

@mose
mose / command.js
Last active October 24, 2018 13:30
Backtick bookmarklet for transforming unix timestamp to human date.
var unix_timestamp = window.prompt("Input a timestamp (ie. 1392879315)", "");
var date = new Date(unix_timestamp*1000);
var utcDate = date.getUTCFullYear() + '-' + (date.getUTCMonth()+1) + '-' + date.getUTCDate() + ' ' + date.getUTCHours() + ':' + date.getUTCMinutes() + ':' + date.getUTCSeconds();
var localDate = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
window.alert("\nUTC: "+utcDate+"\nLocal: "+localDate);