Skip to content

Instantly share code, notes, and snippets.

View groman-me's full-sized avatar

Roman Gusev groman-me

View GitHub Profile
@groman-me
groman-me / save_restore_dependencies.sql
Created March 19, 2020 17:44 — forked from mateuszwenus/save_restore_dependencies.sql
PostgreSQL: How to handle table and view dependencies
create table deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
deps_view_name varchar(255),
deps_ddl_to_run text
);
create or replace function deps_save_and_drop_dependencies(p_view_schema varchar, p_view_name varchar) returns void as
$$
@groman-me
groman-me / postgres_queries_and_commands.sql
Created January 15, 2020 14:44 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@groman-me
groman-me / base.rb
Created October 22, 2015 13:43 — forked from fxposter/base.rb
Default Rails template
# rails new app_name -d mysql --skip-bundle -m path/to/this/template.rb
comment_lines 'Gemfile', "gem 'turbolinks'"
comment_lines 'Gemfile', "gem 'jbuilder'"
comment_lines 'Gemfile', "gem 'sass-rails'"
comment_lines 'Gemfile', "gem 'coffee-rails'"
comment_lines 'Gemfile', "gem 'uglifier'"
comment_lines 'Gemfile', "gem 'sdoc'"
gsub_file 'Gemfile', "gem 'mysql2'", "gem 'mysql2', '~> 0.3.20'"
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'sqlite3'
GEMFILE
system 'bundle'
<html>
<head>
<title>Line graph over time with multiple data points using SVG and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
body {
font-family: "Helvetica Neue", Helvetica;
}
/* tell the SVG path to be a thin blue line without any area fill */

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@groman-me
groman-me / gist:1990236
Created March 7, 2012 01:13
English-y to_hash
def to_hash
@reports.map(&:to_hash).reduce({}, :merge)
end