Skip to content

Instantly share code, notes, and snippets.

View zapo's full-sized avatar

Antoine Niek zapo

  • Optable
  • Montreal
View GitHub Profile
@zapo
zapo / PostgreSQL_index_naming.rst
Created March 12, 2021 19:28 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@zapo
zapo / chat.js
Created October 20, 2018 22:33
WebRTC channel communication sample (same browser signaling through localStorage)
const connection = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] });
connection.onicecandidate = (e) => {
if (e.candidate) {
localStorage.setItem('candidate', JSON.stringify(e.candidate));
}
};
connection.oniceconnectionstatechange = (e) => {
console.log(connection.iceConnectionState);

Keybase proof

I hereby claim:

  • I am zapo on github.
  • I am zapo (https://keybase.io/zapo) on keybase.
  • I have a public key ASCgQBKsRiEbgt4eVyNEcWM3z0k8f945UREIgtxBH4reyQo

To claim this, I am signing this object:

#!/usr/bin/env bash
## -*- sh-basic-offset: 2 -*-
set -o errexit -o nounset -o pipefail
BASENAME=$(basename "$0")
BASEURL="https://api.travis-ci.com"
eval "$(docopts -A args -V - -h - : "$@" <<EOF
Usage:
@zapo
zapo / affirmation
Created June 25, 2015 13:54
MuleSoft Contributor Agreement Acceptance by Antoine Niek
I, Antoine Niek, have read and do accept the MuleSoft Contributor Agreement
at http://www.mulesoft.org/legal/contributor-agreement.html
Accepted on Thu Jun 25 2015 09:53:58 GMT-0400 (EDT)
@zapo
zapo / todotxt-podio.rb
Last active August 29, 2015 14:22
Podio tasks sync with todotxt
#!/usr/bin/env ruby
require 'rubygems'
require 'ostruct'
require 'yaml'
require 'active_support'
require 'active_support/core_ext'
require 'podio'
def usage
STDOUT.puts " Usage: #{ENV['TODO_SH']} podio <option>"
@zapo
zapo / validations.rb
Created July 30, 2014 14:11
Validations test helper
module Helpers
module Validations
private
def assert_valid_url url
assert_match URI::regexp(%w(http https)), url, "\"#{url}\" isn't a valid URL"
end
def assert_validated_presence object, attribute, success_val = "not blank", expected_msg = :blank
assert_validated object, attribute,
# plagiarism of https://github.com/runemadsen/cancan-backbone/blob/master/cancan-backbone.js
# without backbone dependency
class exports.Rule
constructor: (rule) ->
@actions = rule.actions
@conditions = rule.conditions ? {}
@subjects = rule.subjects
@can = !!rule.can
@zapo
zapo / dupable.rb
Last active August 29, 2015 13:58
dupable.rb
module Concerns
module Dupable
def duplicate
# copy self with attributes only, includes belongs_to associations
duplicate = self.dup
# copy all has_many associations...
# reject through target associations, we only want to duplicate the association models
self.class.reflect_on_all_associations(:has_many).select { |a| a.through_reflection.nil? }.each do |assoc|
class TimeZoneModel
class ZoneProxy
attr_reader :target
def initialize target
@target = target
end
def name
@target.tzinfo.identifier