Skip to content

Instantly share code, notes, and snippets.

Avatar

Antoine Niek zapo

View GitHub Profile
@zapo
zapo / chat.js
Created Oct 20, 2018
WebRTC channel communication sample (same browser signaling through localStorage)
View chat.js
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);
View keybase.md

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:

View travis-rebuild
#!/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 Jun 25, 2015
MuleSoft Contributor Agreement Acceptance by Antoine Niek
View affirmation
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 Aug 29, 2015
Podio tasks sync with todotxt
View todotxt-podio.rb
#!/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 Jul 30, 2014
Validations test helper
View validations.rb
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,
View ability.js.coffee
# 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 Aug 29, 2015
dupable.rb
View 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|
View time_zone_model.rb
class TimeZoneModel
class ZoneProxy
attr_reader :target
def initialize target
@target = target
end
def name
@target.tzinfo.identifier
You can’t perform that action at this time.