Skip to content

Instantly share code, notes, and snippets.

View cimmanon's full-sized avatar

cimmanon

View GitHub Profile
@cimmanon
cimmanon / psql.md
Created May 2, 2017 17:22
PostgreSQL cheat sheet for MySQL users

I use PostgreSQL via the psql client. If you use a different client (eg. pgAdmin, etc.), I don't know how much will translate over.

One nice difference between psql and mysql (cli) is that if you press CTRL+C, it won't exit the client.

User administration

Login as superuser (via shell)

psql -U postgres
@cimmanon
cimmanon / flexbox.scss
Last active January 14, 2025 18:21 — forked from anonymous/Flexbox mixins
This collection of Sass mixins to cover all 3 flexbox specifications that have been implemented. More information can be found here: https://gist.github.com/cimmanon/727c9d558b374d27c5b6
@import "compass/css3/shared";
// NOTE:
// All mixins for the 2009 spec have been written assuming they'll be fed property values that
// correspond to the standard spec. Some mixins can be fed values from the 2009 spec, but don't
// rely on it. The `legacy-order` mixin will increment the value fed to it because the 2009
// `box-ordinal-group` property begins indexing at 1, while the modern `order` property begins
// indexing at 0.
// if `true`, the 2009 properties will be emitted as part of the normal mixin call
@cimmanon
cimmanon / SassMeister-input.scss
Created June 22, 2014 15:49
Generated by SassMeister.com.
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
.selector-class {
& &__element {
background: red;
}
}
@cimmanon
cimmanon / readme.md
Last active March 1, 2018 18:13
Heist Attribute Splices explained with examples

There aren't any good guides for using AttrSplices from Heist. The tutorial from the Snap website fails to show how to bind them, and the only public code I can find that uses them is Digestive Functors Heist.

How does it work?

type AttrSplice m = Text -> RuntimeSplice m [(Text, Text)]

The AttrSplice type signature says that it takes a Text and returns a Monad containing a list of tuples of Text. The first argument would only be used if you're planning on using it as a point of comparison within the template, as shown in the Attribute Splices Tutorial (n.b. the type signature listed here is slightly different, this might reflect an older version of Heist):

CREATE TABLE order_history (
order_id INT NOT NULL,
date_added TIMESTAMPTZ NOT NULL DEFAULT now(),
status TEXT NOT NULL,
PRIMARY KEY (order_id, date_added)
);
CREATE TABLE history_allowed_pattern (
old TEXT NOT NULL,

CSS Flexbox: Specification Unification

The flexbox module has been kicking around for quite some time. There are 3 different specifications that have been implemented in the major browsers. This is an overview of how to cover all of them. If you're interested in how to use flexbox, there are many fine articles out there (some have been linked below).

Browsers

  • Chrome 21 (prefixed)
  • Opera 12.1 (unprefixed)
@cimmanon
cimmanon / trigger.sql
Last active March 5, 2017 02:02
Example trigger for ensuring that history states are inserted in the proper order. Ever needed to make sure that an order is filled before it gets shipped? This is how you would do it in the database.
CREATE TABLE history_allowed_pattern (
old TEXT NOT NULL,
new TEXT NOT NULL,
UNIQUE (old, new)
);
INSERT INTO history_allowed_pattern
(old, new)
VALUES
@cimmanon
cimmanon / diagnostics.sql
Last active December 18, 2016 15:20
PostgreSQL function for doing diagnostics on unfamiliar tables
begin;
/*----------------------------------------------------------------------------------------------------*\
| Functions for generating statistics
\*----------------------------------------------------------------------------------------------------*/
create or replace function rel_column_count(schema_name text, table_name text, column_name text, column_type text) returns table
( not_null_count bigint
, distinct_count bigint
, min_length int
@cimmanon
cimmanon / SassMeister-input.scss
Created February 1, 2016 22:44
Generated by SassMeister.com.
// ----
// Sass (v3.4.20)
// Compass (v1.0.3)
// ----
.foo {
bar: index((width: 10px, height: 20px), (height 20px));
}
@cimmanon
cimmanon / SassMeister-input.scss
Created February 25, 2016 23:47
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
.foo {
outline: #90b2e9 solid 1px;
outline: #90B2E9 solid 1px;
}