Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
hashbrowncipher / gist:1370430
Created November 16, 2011 15:50
SHA1 example
$ echo -n "" | sha1sum
da39a3ee5e6b4b0d3255bfef95601890afd80709 -
$ echo -n "Hello" | sha1sum
f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 -
$ echo -n "Goodbye" | sha1sum
b5b29c53e3c71cb9c6581ab053d7758fab8ca24d -
$ echo -n "Jim" | sha1sum
7627f9952b9c378edc494c5751804403e5973074 -
$ echo -n "Jam" | sha1sum
9d0eb3ad554bcf741ec708559e3ce1993f0df9f1 -
@hashbrowncipher
hashbrowncipher / gist:1370707
Created November 16, 2011 17:16
SSH Key Management
$ ssh server
The authenticity of host 'server (10.0.0.10)' can't be established.
RSA key fingerprint is 07:d1:fa:09:0d:a4:01:c5:a8:61:bf:a0:b1:fa:d1:33.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server' (RSA) to the list of known hosts.
"2014-10-28T17:06:16.595708-0700"
"2014-10-28T17:07:16.596618-0700"
"2014-10-28T17:08:16.597161-0700"
"2014-10-28T17:09:16.597742-0700"
"2014-10-28T17:10:16.598256-0700"
"2014-10-28T17:11:16.598547-0700"
"2014-10-28T17:12:16.598998-0700"
"2014-10-28T17:13:16.600600-0700"
"2014-10-28T17:14:16.601909-0700"
"2014-10-28T17:15:16.602993-0700"
// ==UserScript==
// @name JIRA Issue Change Notifier
// @include https://jira.example.com/browse/*
// ==/UserScript==
var checkInterval = 5000;
var issueKey = JIRA.Issue.getIssueKey();
var updatedDate = new Date(jQuery('span#updated-date time')[0].dateTime).getTime()
var isIssueUpdated = function() {
@hashbrowncipher
hashbrowncipher / pid_ns
Last active August 29, 2015 14:10
Wraps running a process under a PID namespace.
#include <errno.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char * argv[]) {
if (argc < 2) {
@hashbrowncipher
hashbrowncipher / send-test-sensu-alert
Created January 19, 2015 20:38
a script written by @solarkennedy at Yelp to test sensu alerts
#!/bin/bash
cat <<EOF >/tmp/test-sensu-alert.json
{
"name": "test_alert_for_${USER}",
"interval": 0,
"alert_after": 0,
"realert_every": "1",
"runbook": "y/unknown",
"annotation": "unknown",
redis 127.0.0.1:6379> LRANGE "history:dev4-devb.dev.yelpcorp.com:test_alert_for_josnyder" 0 -1
1) "1"
2) "0"
redis 127.0.0.1:6379> get "execution:dev4-devb.dev.yelpcorp.com:test_alert_for_josnyder"
"1421702124"
@hashbrowncipher
hashbrowncipher / gist:5d31b00478a8ab704ed2
Created January 20, 2015 18:03
conversation between rob_ and josnyder in #sensu
2015-01-19 12:02:46 josnyder hi rob_, t0m
2015-01-19 12:03:19 josnyder i indeed overlooked that we should be using a sensu agent socket to send messages
2015-01-19 12:05:46 josnyder rob_: I'm specifically thinking of a use case where a job gets scheduled over a chronos cluster and sends results to sensu
2015-01-19 12:06:39 josnyder so any of 100s of machines could run the job, and then want to report the same client/check pair to the sensu aggregator
2015-01-19 12:06:52 rob_ josnyder: hey :)
2015-01-19 12:07:29 rob_ josnyder: sounds like you could just send it to a sensu-agent somewhere then, right?
2015-01-19 12:07:38 josnyder yeah, each of the nodes will have a sensu agent
2015-01-19 12:07:40 rob_ could even have a few sensu agents running and load balance them :)
2015-01-19 12:07:44 josnyder yep
2015-01-19 12:07:58 josnyder but there's no guarantee that the job will be scheduled or run correctly
@hashbrowncipher
hashbrowncipher / success_wrapper
Created January 21, 2015 17:19
a wrapper for touch(1)ing a file when a job succeeds, developed at Yelp
#!/bin/bash
set -eu
name="$1"
shift
"$@"
touch "/var/lib/success_wrapper/${name}"
#include <fcntl.h>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define BLOCK_SIZE 1024 * 1024