Skip to content

Instantly share code, notes, and snippets.

View shadowbq's full-sized avatar
👔
Doing Things

shadowbq shadowbq

👔
Doing Things
View GitHub Profile
anonymous
anonymous / untrusted-lvl5-solution.js
Created May 4, 2015 13:30
Solution to level 5 in Untrusted: http://alex.nisnevich.com/untrusted/
/******************
* minesweeper.js *
******************
*
* So much for Asimov's Laws. They're actually trying to kill
* you now. Not to be alarmist, but the floor is littered
* with mines. Rushing for the exit blindly may be unwise.
* I need you alive, after all.
*
* If only there was some way you could track the positions
@groesser3
groesser3 / lifo_fifo.rb
Created November 5, 2010 07:05
simple LIFO, FIFO functions in ruby
require "test/unit"
class Array
def fifo
verbrauch = inject(0) {|sum, el| sum+=el.abs if el < 0; sum }
res = select{|el| el > 0}.inject([]) do |result, el|
if el > verbrauch
result << (el - verbrauch)
verbrauch = 0
else
@cehoffman
cehoffman / .gitignore
Created April 27, 2012 18:50
Program to remove an IP Address from SSHGuard's blacklist
build/
@f440
f440 / config.ru
Created December 20, 2013 07:43
forwardable
require 'sinatra/base'
require 'forwardable'
class I18n
def self.t(s); "I18n.t(#{s})"; end
def self.l(s); "I18n.l(#{s})"; end
end
class App < Sinatra::Base
extend Forwardable
@danielevans
danielevans / gist:1011309
Created June 6, 2011 23:01
A create admin rake task using the highline gem
namespace :admin do
desc "creates and admin user"
task :create => :environment do
line = HighLine.new # a command line lib that uses erb? Bizarre.
line.say "<%= color('Creating a new administrative user', BOLD) %>"
email = line.ask("Email: ")
pass = line.ask("Password: " ) { |q| q.echo = "*" }
admin = Admin.new(:email => email, :password => pass)
@morhekil
morhekil / LICENSE
Last active January 22, 2017 22:12
Implementation of deep symbolization of keys for Ruby hashes
The MIT License (MIT)
Copyright (c) 2015 Oleg Ivanov http://github.com/morhekil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"
@mikesmullin
mikesmullin / tcpflow-1.4.4_wrapper.coffee
Last active November 8, 2017 11:42
wrapper for tcpflow which enhances its stdout output to include easily parsed timestamp format, incl. milliseconds, tz offset, and packaged in flat json one-object-per-row ideal for mapreducing on
#!/usr/bin/env coffee
#
# install on ubuntu:
# sudo apt-get install automake autoconf libpcap-dev zlib1g-dev libboost-dev libcairo2-dev
#
# cd /tmp/
# git clone --recursive -b tcpflow-1.4.4 git@github.com:simsong/tcpflow.git tcpflow/
# cd tcpflow/
#
# sh bootstrap.sh
@shadowbq
shadowbq / vmkernel_prep.sh
Last active March 11, 2018 22:42
AskUbuntu SO #966585 - Post Kernel Upgrade
#!/usr/bin/env bash
# Must be run as root / sudo
# Reference: https://askubuntu.com/questions/966585/ubuntu-17-10-upgrade-broke-vmware-workstation-12-5
if [ $(dpkg-query -W -f='${Status}' linux-headers-generic 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Kernel Headers Package Missing"
echo "apt-get install linux-headers-generic";
exit 1
fi
@f440
f440 / evernote2txt.rb
Created April 20, 2014 14:32
Evernote xml (enex) to txt
#!/usr/bin/env ruby
#-*- encoding: utf-8 -*-
# http://blog.evernote.com/tech/2013/08/08/evernote-export-format-enex/
require 'nokogiri'
require 'date'
require 'ostruct'
class Note < OpenStruct; end