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 / 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);
@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 / web.go
Created September 12, 2013 07:52
just a tutorial followup
package main
import (
//"fmt"
"net/http"
"io/ioutil"
"html/template"
"regexp"
"errors"
"log"
@mose
mose / mail interceptor
Last active December 21, 2015 08:28
mail interceptor in rails
# lib/mailinterceptor.rb
class MailInterceptor
def self.delivering_email(message)
message.to = "dev@example.com"
message.subject = "[#{message.to}] " + message.subject
end
end
# config/initializers/setup_mail.rb