Skip to content

Instantly share code, notes, and snippets.

View pnomolos's full-sized avatar

Phil Schalm pnomolos

  • Jane.app
  • British Columbia, BC
  • 05:50 (UTC -12:00)
  • X @pnomolos
View GitHub Profile
### Keybase proof
I hereby claim:
* I am pnomolos on github.
* I am pnomolos (https://keybase.io/pnomolos) on keybase.
* I have a public key ASDGvueD_4X-RZ9Dg6XJcBP8MQfIEp8fROLzbxcYcfweRgo
To claim this, I am signing this object:
@pnomolos
pnomolos / reset_sequences.sql
Created October 29, 2016 03:46
The 'Fixing Sequences' example in the postgres wiki doesn't work for tables named the same between multiple schemas.
-- See https://wiki.postgresql.org/wiki/Fixing_Sequences for instructions on how to use this
SELECT 'SELECT SETVAL(' ||
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
', COALESCE(MAX(' ||quote_ident(C.attname)|| ') + 1, 1), false ) FROM ' ||
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
pg_depend AS D,
pg_class AS T,
pg_attribute AS C,
@pnomolos
pnomolos / Guardfile
Created July 5, 2016 23:33
Really simple resque-pool plugin
require "guard/compat/plugin"
module ::Guard
class ResqueGuard < Plugin
def start
puts "Starting Resque"
@pid = spawn("bin/resque-pool --hot-swap")
Process.detach(@pid)
end
@pnomolos
pnomolos / mutable.rb
Last active May 10, 2016 16:44
dry-types => Mutable Struct
module Dry
module Types
class Struct
# A variation on dry-types Struct that includes property writers
class Mutable < Struct
constructor_type :schema
def self.attributes(new_schema)
super
new_schema.keys.each do |key|
# If you're sending html-only mail (Shame on you! 😆) you can use the following so you get support for
# it { should have_sent_email.matching_html_part(/html-only contents/) }
module Mail
module Matchers
class HasSentEmailMatcher
def matching_html_part(html_part_matcher)
@html_part_matcher = html_part_matcher
self
end
@pnomolos
pnomolos / Gemfile
Last active August 29, 2015 14:17 — forked from solnic/ar_create.rb
Call-tree example for ActiveRecord vs. rom-sql
# A sample Gemfile
source "https://rubygems.org"
gem 'activerecord'
gem 'hotch'
gem 'rom-sql'
gem 'sqlite3'
Attaching to the process with GDB
Populate your .gdbinit and .gdb directories
In ~/.gdbinit:
define session-ruby
source ~/.gdb/ruby
end
@pnomolos
pnomolos / chmod_r.php
Created December 15, 2013 22:28
Recursive chmod for PHP
<?php
function chmod_R($path, $filemode = null, $dirmode = null, $skip_hidden = true) {
foreach (glob($path, GLOB_MARK) as $path) {
if ($skip_hidden && strpos($path, '.') === 0) {
continue;
}
if (is_dir($path)) {
if ($dirmode && !chmod($path, $dirmode)) {
$dirmode_str=decoct($dirmode);
print "Failed applying filemode '$dirmode_str' on directory '$path'\n";
@pnomolos
pnomolos / Foundation_Walker_Nav_Menu.php
Last active December 18, 2015 21:19 — forked from awshout/foundation4-topbar-menu.php
Nav Walker for Wordpress + Foundation 4 for your top nav menu.
<?php
// You'll want to include this file from functions.php, and add both theme support and register_nav_menus calls there
//
// add_theme_support('menus');
// register_nav_menus(array(
// 'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
// 'top-bar-r' => 'Right Top Bar'
// ));
@pnomolos
pnomolos / Type.php
Created March 20, 2013 23:41
Example base Type class for Spot
<?php
namespace Spot;
use Spot\Entity;
class Type implements Type\TypeInterface
{
public static $_loadHandlers = array();
public static $_dumpHandlers = array();
/**