Skip to content

Instantly share code, notes, and snippets.

View siennathesane's full-sized avatar
☹️
tickle the code, make it laugh

Sienna siennathesane

☹️
tickle the code, make it laugh
View GitHub Profile
@siennathesane
siennathesane / takegur.go
Created September 30, 2015 16:04
Downloads all the wallpapers from the Imgur main gallery.
package main
/*
Made with <3 from picturesarenice and emi8ly.
*/
import (
"encoding/json"
"fmt"
"github.com/cheggaaa/pb"
#Getting the services and checking their states.
Get-Service VMwareSTS,VMwareIdentityMgmtService,VMwareCertificateService,VMwareKdcService,VMwareDirectoryService | foreach {$_.DisplayName, $_.Status} | Write-Host
#Setting variable.
$sso = [VMwareSTS,VMwareIdentityMgmtService,VMwareCertificateService,VMwareKdcService,VMwareDirectoryService]
#Shutdown/Start services in the proper order
foreach ($service in $sso) {
try
{
@siennathesane
siennathesane / thereaping.go
Created October 14, 2015 16:52
Function used to reap all child process...also known as...child reaper...
func ChildReaper() (exits []Exit, err error) {
//start the loop to reap any abandonded children.
for {
var (
status syscall.WaitStatus
usage syscall.Rusage
)
// make the `wait4` call and check for errors. if the error equals
// ECHILD (no child process), return empty exit status.
# git objects for manipulation.
objects = {'tags': [], 'commits': [], }
def pull_git():
"""
Pulls the current revision and saves it as a JSON object.
:return:
"""
print("reading git objects.")
for objhex in repo:
@siennathesane
siennathesane / k8s-deploy.sh
Last active November 25, 2015 16:20
Local automated Kubernetes installation via Docker.
#! /bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
wget -qO- https://get.docker.com/ | sh
usermod -aG docker `whoami`
@siennathesane
siennathesane / subprocess-logging.py
Created December 2, 2015 03:33
Send subprocess output to a logger.
class LogPipe(threading.Thread):
"""
Piping subprocess output to a logger.
"""
def __init__(self, level):
"""
Setup the object with a logger and a loglevel and start the thread
"""
threading.Thread.__init__(self)
self.daemon = False
from requests import get
from shutil import rmtree
from subprocess import Popen, PIPE, STDOUT
from os.path import isdir
from os import listdir, chdir, mkdir, fdopen, pipe, close
from sys import stdout
from time import sleep
import logging
@siennathesane
siennathesane / arrays.cpp
Created December 2, 2015 22:19
Print array positions.
#include <iostream>
int main() {
int i;
int foo[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
for(i = 0; i < sizeof(foo)/sizeof(foo[0]); i++)
{
if(foo[i] == 0)
{
printf("Number 0 is at array position %i\n", i);
@siennathesane
siennathesane / slack.py
Created January 20, 2016 23:34
Easy incoming webhook for Slack, named Hal.
class Slack(object):
"""
The Slack object for posting messages.
"""
def __init__(self):
self.webhook = ""
self.username = "Hal"
self.icon_url = "http://i.imgur.com/hnDhvFB.jpg"
@siennathesane
siennathesane / aggregate.go
Created February 2, 2016 16:31
Log aggregation
func LogCapture(idx int, c chan string, client *http.Client, url string, lc string, wg *sync.WaitGroup) {
defer wg.Done()
wg.Add(idx)
LogUrl := fmt.Sprintf("%s/%s/log", url, lc)
request, err := http.NewRequest("GET", LogUrl, nil)
if err != nil {
log.Errorf("Error making new request: %s", err)
}
request.Header.Set("X-Powered-By", "logrhythmic")