Skip to content

Instantly share code, notes, and snippets.

View jeffbyrnes's full-sized avatar

Jeff Byrnes jeffbyrnes

View GitHub Profile
@sarim
sarim / repairsqlite.sh
Created September 6, 2013 08:14
Sqlite db repair script
#!/bin/bash
DBSTATUS=$(sqlite3 "$1" "PRAGMA integrity_check")
if [ "$DBSTATUS" == "ok" ] ; then
echo DB ALREADY OK
else
echo FIXING CORRUPT DB
TMPDB=$(mktemp -t sarim)
echo ".mode insert
.dump" | sqlite3 "$1" > $TMPDB
@dperrera
dperrera / gulpfile.js
Last active January 3, 2016 22:19
My gulpfile.js
// ==================================================
// Gulp Variables
// ==================================================
var gulp = require('gulp'),
gutil = require('gulp-util');
// Compass
var compass = require('gulp-compass');
@mgreensmith
mgreensmith / Slack_solarized_themes
Last active March 17, 2025 14:33
Solarized themes for Slack
Solarized
#FDF6E3,#EEE8D5,#93A1A1,#FDF6E3,#EEE8D5,#657B83,#2AA198,#DC322F
Solarized Dark
#073642,#002B36,#B58900,#FDF6E3,#CB4B16,#FDF6E3,#2AA198,#DC322F
KV_KEY = 'forecast-alert-datapoint'
module.exports = (robot) ->
postWeatherAlert = (json, callback) ->
postMessage = callback
now = new Date()
# This function posts an alert about the current forecast data always. It
# doesn't determine if the alert should be posted.
@fjallstrom
fjallstrom / gist:4f238b15a4d54187f742
Last active August 3, 2016 20:24
slacklastfmthingie
<?php
date_default_timezone_set("Europe/Stockholm");
require 'vendor/autoload.php';
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
$client = new Client();
@angstwad
angstwad / dict_merge.py
Last active December 22, 2024 16:02
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
@blalor
blalor / consul_handler.rb
Created July 2, 2015 14:03
Chef report handler for Consul
## chef report handler for Consul
## depends on a chef-client check being registered with the agent
## • pings TTL-style check with ok/warning status on chef run pass/fail
## • stores run report and node attributes in chef/reports/<datacenter>/<consul_node_name>
require "chef/handler"
require "rest_client"
class ConsulHandler < Chef::Handler
attr_reader :config
@technovangelist
technovangelist / datadog-nginx
Last active April 25, 2017 20:35 — forked from gane5h/datadog-nginx
Nginx log parsing with datadog
"""
Thanks to gane5h for the original script. this is a small kludgy tweak to that one.
Custom parser for nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g "/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format time_log '$time_local "$request" S=$status $bytes_sent T=$request_time R=$http_x_forwarded_for';
when starting dd-agent, you can find the collector.log and check if the dogstream initialized successfully
@bmhatfield
bmhatfield / ec2-security-group-rules
Created March 9, 2016 04:15
Output a human-readable & colorized view of your EC2 security group rules
#!/usr/bin/env ruby
require 'aws-sdk'
require 'colorize'
ec2 = Aws::EC2::Resource.new
ec2.security_groups.sort_by{|s| s.group_name }.each do |sg|
puts sg.group_name.underline unless sg.ip_permissions.empty?
sg.ip_permissions.each do |perm|
@eherot
eherot / stale-cookbooks.rb
Created June 6, 2016 20:29
Check which cookbooks haven't been promoted to prod
require 'chef'
require 'chef/knife'
Chef::Knife.new.configure_chef
rest = Chef::ServerAPI.new Chef::Config[:chef_server_url]
cookbooks = rest.get_rest 'cookbooks'
rest.get_rest('environments/prod')['cookbook_versions'].reject do |cb,v|
Gem::Dependency.new('', v).match?('', cookbooks[cb]['versions'].sort_by{|k|k['version']}.first['version'])
end