Skip to content

Instantly share code, notes, and snippets.


Aitor García Rey aitor

View GitHub Profile
vierarb / Dockerfile
Created Aug 14, 2017
Docker configuration
View Dockerfile
FROM ruby:2.4.1
RUN apt-get update -qq && apt-get install -y build-essential
# for postgres
RUN apt-get install -y libpq-dev
# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev
View mercator.js
// license: BSD3
const WEBMERCATOR_R = 6378137.0;
class Mercator {
static project(lon, lat) {
var x = DIAMETER * lon/360.0;
var sinlat = Math.sin(lat * Math.PI/180.0);
var y = DIAMETER *Math.log((1+sinlat)/(1-sinlat)) / (4*Math.PI);
return { x, y };
mankind / rails-jsonb-queries
Last active Jun 11, 2021
Ruby on Rails-5 postgresql-9.6 jsonb queries
View rails-jsonb-queries
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
View Help with Rake best

I have been carrying this Rakefile around between projects, that uses another file which reopens the FlogTask class and adds an attr_accessor to it, which the task definition in the Rakefile then uses.

This works but, as you can readily tell, it's less than ideal. In particular, the Rakefile defines multiple tasks which are the same for each project; the only change is usually the Flog threshold value.

What I want to be able to do is:

  1. Subclass a tool's standard Rake task (e.g., FlogTask). The subclass' #initialize method would then set up our standard settings as is presently done in the Rakefile;
  2. Define namespaced Rake tasks (in, e.g., lib/tasks/custom_flog.rake) that use those subclasses rather than the tool's standard Rake task; reducing boilerplate and possibility of copy/paste errors;
  3. Have those tasks be available in
annalee /
Last active May 20, 2021
A sample code of conduct for social slack teams.

[SLACKNAME] Code of Conduct



The current admins are:

  • [NAMES]
ericclemmons /
Last active Jun 10, 2021
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

 <summary>Summary Goes Here</summary>
glarrain /
Last active Mar 26, 2021 — forked from jonyt/connect_heroku_to_amazon_rds
How to connect a Heroku application to an Amazon RDS PostgreSQL instance, forcing SSL and certificate chain verification

1 - Download the RDS certificates (root plus region-specific intermediate ones) bundle:

wget -O config/rds-combined-ca-bundle.pem

2 - Add config/rds-combined-ca-bundle.pem to the repository and redeploy to Heroku.

3 - Update the DATABASE_URL env var:

ramiroaznar / index.html
Last active May 6, 2017
How to add a formula, histogram & category widget to a dashboard using deepinsights.js
View index.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Deep-Insights.js | Highest Mountains</title>
<link rel="shortcut icon" href="" />
<meta name=viewport content="width=device-width initial-scale=1">
<link rel="stylesheet" href="" />
<script src=""></script>
<style type="text/css">
# usage:
# I've been using this ffmpeg command to take recordings made with ecamm's Call Recorder for Skype and uploading them
# to YouTube for transcription. I found that YouTube would only transcribe one of the audio channels which
# was often my own voice, which made it less than useful, to put it mildly. Once the channels are combined YouTube will
# transcribe both sides of the conversation. I also found that it was useful to adjust the volumes of the tracks.
ffmpeg -i $1 -filter_complex "[0:a:0]volume=0.781250[a1];[0:a:1]volume=0.781250[a2]; [a1][a2]amerge[out]" -map 0:v -map "[out]" -c:v copy -shortest $2
arfon /
Last active May 2, 2021
BigQuery Examples for blog post

How many times shouldn't it happen...


SELECT count(*)
FROM (SELECT id, repo_name, path
        FROM [bigquery-public-data:github_repos.sample_files]
      ) AS F