Skip to content

Instantly share code, notes, and snippets.

View chmouel's full-sized avatar
🤨
Kuberneting

Chmouel Boudjnah chmouel

🤨
Kuberneting
View GitHub Profile
@chmouel
chmouel / openshift-v3-cleanup.sh
Last active August 29, 2015 14:17
OpenShift v3 cleanup resources
#!/bin/bash
for i in replicationController pod services route imagerepository buildconfig deploymentconfig service;do
for j in $(osc get $i|awk '{print $1}'|egrep -v '(POD|NAME|CONTROLLER)');do
osc delete $i $j
done
done
id: hello-openshift
kind: Pod
apiVersion: v1beta2
labels:
name: hello-openshift
desiredState:
manifest:
version: v1beta1
id: hello-openshift
#!/usr/bin/python
import json
import sys
import yaml
ydict = yaml.load(sys.stdin.read())
print(json.dumps(ydict))
function mystock () {
local totalstock=NUMBEROFSTOCKYOUHAVE
local companystock=STOCKQUOTE
local yahoobase=http://download.finance.yahoo.com/d/quotes.csv?s
local yahooconv="${yahoobase}=USDEUR=X&f=l1"
local stockprice=$(curl -s "${yahoobase}=${companystock}&f=l1"|tr -d '^M')
local total=$[ $stockprice * $totalstock ]
local divided=$[ total / 4 ]
local eur=$(curl -s $yahooconv)
for i in $(find . -name '*.json');do python -c 'import sys,json,yaml;print(yaml.safe_dump(json.loads(sys.stdin.read()), default_flow_style=False))' < $i > ${i/json/yaml};done
@chmouel
chmouel / lwn-login.sh
Created November 9, 2015 10:44
Login to LWN
#!/usr/bin/env bash
LWN_USERNAME=USERNAME
LWN_PASSWORD='PASSWORD'
LWN_LOGIN_PAGE=http://lwn.net/login
LWN_PDF=/tmp/LWN-`date +%d-%m-%Y`.pdf
CURL_AGENT="login to lwn"
CURL_COOKIEJAR=/tmp/.lwncookies
@chmouel
chmouel / screenshot-and-upload-to-google-drive.sh
Last active February 1, 2016 15:21
Upload directly to google drive the current screenshot, bind it to a keyboard shortcut (and pbcopy the output url) for ultimate effectiveness
#!/bin/bash
# Install gdrive: https://github.com/prasmussen/gdrive (in /usr/local/bin here)
# do a drive list and get a folder where you will upload the screenshot
gdrive_container="0B7bJ57bKfWfBY1RsMVF5OVA3TEk"
filename=$(date "+%F__%H-%M-%S-$RANDOM.png")
save_to="/tmp/$filename"
screencapture -i "$save_to"
@chmouel
chmouel / openshift-ceph-rbd.yaml
Created November 30, 2015 15:18
OpenShift with RBD
---
kind: "Template"
apiVersion: "v1"
metadata:
name: "quickstart-keyvalue-application"
annotations:
description: "This is an example of a Ruby and MySQL application on OpenShift 3"
iconClass: "icon-ruby"
tags: "instant-app,ruby,mysql"
labels:
# -*- coding: utf-8 -*-
# Calcule des workout + times pour un groupe de differente VMA
# Les vma par default vons de 13 a 20 (a configurer dans la variable VMA)
# La variable WORKOUT est la variable des travaux a faire,
# c'est une array avec comme valeur :
# [times, percentage, distance, repos]
# times sont le nombre de repetition
# percentage sont le percentate a laquelle vous avez la VMA
# repos et le temp de repo pour cette repetition
function oca () {
if [[ $1 == "sync" ]];then
mkdir -p ~/.kube/
scp master:/etc/origin/master/admin.kubeconfig ~/.kube/
fi
oc --config=$HOME/.kube/admin.kubeconfig $@
}
compdef _oc oca