Skip to content

Instantly share code, notes, and snippets.

View audionerd's full-sized avatar

Eric Skogen audionerd

View GitHub Profile
-- Tested on PostgreSQL 15.1.
-- https://gist.github.com/srfrog/ef8c9a3a4282b865fb93f429d671d63b
-- https://github.com/paralleldrive/cuid2 56c54483bd7d5dd12343211c14588265e00f0887
CREATE SEQUENCE IF NOT EXISTS "cuid2_seq";
CREATE OR REPLACE FUNCTION _counter() RETURNS VARCHAR AS $$
DECLARE
val bigint;
BEGIN
@mattdesl
mattdesl / modules.md
Last active August 16, 2022 10:14
my favourite modules.
@pcreux
pcreux / 000_postgresql_fancy_datatypes
Last active March 18, 2022 16:51
Postgresql fancy datatypes with Rails / ActiveRecord. Run it with `rake`!
# Postgresql fancy datatypes!
* array
* hstore (=~ hash)
* json
* jsonb
Philippe Creux - [@pcreux](http://twitter.com/pcreux)
@stereoscott
stereoscott / copy_attachments.rb
Created April 6, 2014 21:56
Paperclip Copy Attachments
module Paperclip
module CopyAttachments
def copy_attachments_from(source_obj, source_bucket = nil, destination_bucket = nil)
self.class.attachment_definitions.keys.each do |attachment_name|
source_attachment = source_obj.send(attachment_name)
next if source_attachment.blank?
destination_attachment = self.send(attachment_name)
connection = destination_attachment.send(:connection)
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@andresf
andresf / active_model_errors_extension.rb
Last active April 28, 2017 17:37
Expose more information about validation errors in Rails
module ActiveModel
class Errors
def error_types
@_error_types ||= Hash.new { |hash, key| hash[key] = [] }
end
def add_with_save_names(attribute, message = nil, options = {})
message ||= :invalid
message = message.call if message.is_a?(Proc)
error_types[attribute] << message
@flenter
flenter / wercker.yml
Last active December 25, 2015 14:39
wercker.yml for php with a yui compressor step
box: wercker/php
# Build definition
build:
# The steps that will be executed on build
steps:
# A custom script s tep, name value is used in the UI
# and the code value contains the command that get executed
- script:
name: echo php information
code: |
@mcdavis
mcdavis / readme.md
Created August 22, 2013 23:57
Sonos for Hubot

Sonos for Hubot

screenshot

Requirements

  • Hubot
  • HUBOT_SONOS_HOST - an export set to an IP for a single sonos speaker. If grouped, it needs to be the main speaker in the group.
  • The bot has to be running somewhere where it can access your sonos speakers.
@spro
spro / why_spool.sh
Created April 18, 2013 21:44
Follow _why's SPOOL in real time.
#!/bin/sh
# Read _why's SPOOL in real time.
# Requires `lp` and a printer.
BASEURL=http://whytheluckystiff.net
if [ ! -d SPOOL ]; then
mkdir SPOOL
fi
@fujimogn
fujimogn / Guardfile
Created December 5, 2012 02:08
livereload for wordless gem
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
# wordless
guard :shell do
# sass & less
watch(%r{^wp-content/themes/(\w+)/theme/assets/(.+)\.(s[ac]ss|less|css)$}){|m|
`rm -rf wp-content/themes/#{m[1]}/tmp/* && wordless clean && wordless compile`
}