Skip to content

Instantly share code, notes, and snippets.

@mcharo
mcharo / wwdc.js
Last active December 18, 2015 13:29
(function() {
var sessions = document.getElementsByClassName("session");
var hd = [];
var sd = [];
var pdf = [];
for (var i = 0; i < sessions.length; i++) {
var session = sessions[i];
var sessionid = session.getAttribute("id");
sessionid = sessionid.substring(0, sessionid.indexOf("-"));
var title = session.getElementsByClassName("title")[0].innerText;

Keybase proof

I hereby claim:

  • I am mcharo on github.
  • I am mcharo (https://keybase.io/mcharo) on keybase.
  • I have a public key whose fingerprint is 8FBD 486F F08B 6CD5 B078 5087 752C 61E8 4E73 C713

To claim this, I am signing this object:

@mcharo
mcharo / Get-SaltKeys.ps1
Last active October 31, 2016 02:30
Get salt minion keys via saltapi
# Disable SSL validation
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
# Get saltapi credentials
$SaltApiCredential = Get-Credential
$user = $SaltApiCredential.UserName
$pass = $SaltApiCredential.GetNetworkCredential().Password
# Log in to saltapi
Invoke-RestMethod -Uri https://salt:7443/login -Method Post -Body @{username=$user;password=$pass;eauth='pam'} -SessionVariable session
@mcharo
mcharo / playbackRate.bookmarklets
Last active April 24, 2018 19:17
Video playback rate bookmarklets
//1.0:
javascript:(function()%7Bvar%20v%3Ddocument.getElementsByTagName(%22video%22)%5B0%5D%3Bif%20(typeof%20v%20!%3D%3D%20'undefined'%20%26%26%20v.currentTime%20%3E%200)%20%7Bv.playbackRate%20%3D%201%3Bconsole.log(%22playbackRate%20%3D%20%22%20%2B%20v.playbackRate)%3B%7D%7D)()
//+0.1:
javascript:(function()%7Bvar%20v%3Ddocument.getElementsByTagName(%22video%22)%5B0%5D%3Bif%20(typeof%20v%20!%3D%3D%20'undefined'%20%26%26%20v.currentTime%20%3E%200)%20%7Bvar%20pb%20%3D%20v.playbackRate%20%2B%20.1%3Bpb%20%3D%20pb.toFixed(1)%3Bv.playbackRate%20%3D%20pb%3Bconsole.log(%22playbackRate%20%3D%20%22%20%2B%20v.playbackRate)%3B%7D%7D)()
//-0.1:
javascript:(function()%7Bvar%20v%3Ddocument.getElementsByTagName(%22video%22)%5B0%5D%3Bif%20(typeof%20v%20!%3D%3D%20'undefined'%20%26%26%20v.currentTime%20%3E%200)%20%7Bvar%20pb%20%3D%20v.playbackRate%20-%20.1%3Bpb%20%3D%20pb.toFixed(1)%3Bv.playbackRate%20%3D%20pb%3Bconsole.log(%22playbackRate%20%3D%20%22%20%2B%20v.playbackRate)%3B%7D%7D)()
@mcharo
mcharo / triplet.cpp
Created August 14, 2017 01:35
Triplet compare
vector < int > solve(int a0, int a1, int a2, int b0, int b1, int b2){
std::vector<int> score(2, 0);
int clarity = a0 - b0;
int originality = a1 - b1;
int difficulty = a2 - b2;
if (clarity > 0) {
score[0]++;
}
else if (clarity < 0) {
score[1]++;
@mcharo
mcharo / Get-PinvokeMethod.ps1
Last active September 3, 2019 22:49
PowerShell Reflection
function Get-NativeMethods
{
[CmdletBinding()]
param(
[switch]$Unsafe
)
$Type = 'Microsoft.Win32.NativeMethods'
if ($Unsafe)
{
$Type = 'Microsoft.Win32.UnsafeNativeMethods'
@mcharo
mcharo / hyperkube.sh
Created April 14, 2019 20:18
minikube + hyperkit
#!/bin/sh
# install minikube
brew cask install minikube
# install and modify permission on hyperkit driver
brew install hyperkit docker-machine-driver-hyperkit
sudo chown root:wheel /usr/local/bin/docker-machine-driver-hyperkit
sudo chmod u+s /usr/local/bin/docker-machine-driver-hyperkit
@mcharo
mcharo / hello-node.sh
Last active April 15, 2019 02:21
minikube tests
# create hello-node deployment
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node
# create loadbalancer service to expose hello-node pods on external network
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
# open browser to service
minikube service hello-node
# scale number of pods behind service to 3
@mcharo
mcharo / xhyve_ubuntu.sh
Last active April 19, 2019 02:21
Ubuntu on xhyve
# build xhyve
git clone https://github.com/mist64/xhyve
cd xhyve
make
# dump ubuntu iso to ./xhyve/ubuntu
mkdir ubuntu
cd ubuntu
wget http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-server-amd64.iso
dd if=/dev/zero bs=2k count=1 of=/tmp/tmp.iso
@mcharo
mcharo / azdeploy.go
Last active February 7, 2023 20:30
Go CLI Playground
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"