Skip to content

Instantly share code, notes, and snippets.

# added to .git-hooks/pre_commit/debugger.rb
module Overcommit::Hook::PreCommit
# Check for Debugger
class Debugger < Base
def run
keywords = config['keywords']
result = execute(command, args: [keywords.join('|')] + applicable_files)
unless result.stdout.empty?
extract_messages(
@wacko
wacko / pre-commit
Last active September 16, 2020 22:57
Git hook to avoid commit debug lines (binding.pry console.log debugger...)
#!/usr/bin/env ruby
# Validates that you don't commit forbidden keywords to the repo
# You can skip this checking with 'git commit --no-verify'
exit 0 if ARGV.include?('--no-verify')
# Update this list with your own forbidden keywords
KEYWORDS = %w(binding.pry console.log debugger)
def red(text) "\033[31m#{text}\033[0m"; end
@errzey
errzey / llist_db_move.py
Created September 23, 2011 17:20
An interesting technique for creating a linked list like structure using SQL with minimal overhead.

I wrote this a long time ago as a proof-of-concept for a vaporware project. Recently I have had the need to something which seems easy at a high-level standpoint, but is actually quite hard to implement.

The original purpose for this concept was to easily maintain a strict order of data held within the rows, while still having the option to reorder the rows in an efficient manner (one table, no joins, no special embedded scripts etc).

A little insight into what I was doing: I once worked on a network security team for a tier-1 ISP. A coworker and myself had already written some really nice code to deal with the thousands (yes, thousands) of firewalls we dealt with on a daily basis. We created an API which generated abstracted structures of firewall configurations; by abstracting I mean creating a singular data-structure which represented rules, and rule-sets (a nice side-effect of this method was we could morph one firewall syntax structure to another. E.g., juniper filters -> netscreen rules. Needless to s

@janko
janko / 1-activerecord.rb
Last active June 13, 2023 20:00
INSERTing 50,000 records into a database in ActiveRecord, Arel, SQL, activerecord-import and Sequel.
require "active_record"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Migration.class_eval do
create_table(:records) do |t|
t.string :column
end
end
data = 50_000.times.map { |i| Hash[column: "Column #{i}"] }
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@josephspurrier
josephspurrier / values_pointers.go
Last active April 25, 2024 06:24
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value