Skip to content

Instantly share code, notes, and snippets.

Avatar
😷

Conor Broderick conr

😷
View GitHub Profile
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View quick_sort.rb
# Quick Sort - Runtime: Average O(n log(n)), Worst O(n^2), Memory O(log(n))
def quick_sort(arr, left, right)
index = partition(arr, left, right)
if left > index - 1
quick_sort(arr, left, index - 1)
end
if index < right
quick_sort(arr, index, right)
end
@conr
conr / search.rb
Created Jan 21, 2018
Search in rotated sorted array
View search.rb
def search(nums, target)
if nums.length == 0
return -1
end
low, high = 0, nums.length-1
while low <= high
mid = (high+low)/2
if nums[mid] == target
return mid
View elementary_sorting_algorithms.rb
# NOTES
# Worst case O(N^2)
#
# Selection Sort
# Best, Avg, Worst O(N^2) TC
# Worst SC O(1)
def selection_sort(arr)
for i in 0...(arr.length-1)
View client_go_counter_example.go
package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@conr
conr / config.rb
Last active Dec 7, 2017
RoR Prometheus config.ru
View config.rb
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'rack'
require 'prometheus/middleware/collector'
require 'prometheus/middleware/exporter'
use Rack::Deflater
use Prometheus::Middleware::Collector
use Prometheus::Middleware::Exporter
@conr
conr / generate_dummy_scrape_configs.py
Last active Dec 6, 2017
Little script I use for appending a tonne of dummy scrape configs to the end of a prometheus.yml configuration file.
View generate_dummy_scrape_configs.py
from jinja2 import Template
file = open('prometheus.yml', 'a')
templ = Template(u'''\
- job_name: {{ name }}
metrics_path: /export
params:
command: [check_load]
static_configs:
@conr
conr / del-prometheus.sh
Last active Oct 20, 2017
Removes Prometheus Ansible Demo from target machine
View del-prometheus.sh
#!/bin/bash
apt-get remove --purge grafana
directories=(/opt/prometheus /etc/prometheus /var/log/prometheus /var/lib/prometheus /var/lib/pushgateway /var/lib/alertmanager /var/lib/node_exporter)
for i in "${directories[@]}"
do
:
rm -rf $i
@conr
conr / init.coffee
Last active Sep 21, 2017
Atom packages.json for syncing across different machines.
View init.coffee
# initialization file (not found)
View follow_target_followers.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from InstagramAPI import InstagramAPI
from time import sleep
import random
import pdb
import requests
# Get target account's Instagram ID