Skip to content

Instantly share code, notes, and snippets.

Avatar

Laura Paredes vierarb

View GitHub Profile
@vierarb
vierarb / text_to_json
Created May 26, 2020
Postgres: convert text to array of JSONs by regular expression
View text_to_json
CREATE OR REPLACE FUNCTION text_to_json(text text, regex varchar) RETURNS json[] AS $$
DECLARE
chunk text;
res json[];
BEGIN
FOREACH chunk IN array regexp_split_to_array(text, regex)
LOOP
IF TRIM(chunk) <> '' THEN
BEGIN
res := res || chunk::json;
@vierarb
vierarb / tictactoe.rb
Last active May 27, 2020
[TicTacToe] The game
View tictactoe.rb
class TicTacToe
def initialize
@player1 = Player.new(1, 'X')
@player2 = Player.new(2, 'O')
@players = [@player1, @player2]
@winner = false
@board = Board.new
end
def play
@vierarb
vierarb / .rubocop.yml
Created Mar 20, 2018
Proposed rubocop configuration for dmates
View .rubocop.yml
inherit_from:
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.3
Include:
- '**/Gemfile'
- '**/Rakefile'
- '**/config.ru'
Exclude:
@vierarb
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
@vierarb
vierarb / Dvorak_ES.keylayout
Last active Aug 29, 2015
Dvorak keylayout with custom spanish disposition
View Dvorak_ES.keylayout
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!-- Fri, 24 Feb 2006 Generated from KCHR: "Dvorak" -->
<!-- Author: Laura Paredes <laura@wearepeople.io>-->
<!--Last edited by Ukelele version 2.2.8 on 2014-12-21 at 09:58 (CET)-->
<keyboard group="0" id="16300" name="Dvorak ES" maxout="1">
<layouts>
<layout first="0" last="0" modifiers="commonModifiers" mapSet="ANSI"/>
</layouts>
<modifierMap id="commonModifiers" defaultIndex="0">
View Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
@vierarb
vierarb / .rubocop-todo.yml
Last active Aug 29, 2015
Rubocop config file proposal
View .rubocop-todo.yml
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-23 19:26:33 +0100 using RuboCop version 0.29.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Lint/Void:
Enabled: false
@vierarb
vierarb / foursquare_place.rb
Last active Aug 29, 2015
Foursquare Places
View foursquare_place.rb
class FoursquarePlace
include Cacheable
ATTRIBUTES = %i(pid name street city country latitude longitude icon
categories)
def initialize(attrs = {})
@connection = FoursquareConnector.new
_initialize_attributes!(attrs)
@vierarb
vierarb / redis.rb
Last active Aug 29, 2015
Redis Storage
View redis.rb
$redis = Redis.new(host: 'localhost', port: 6379, db: 1)
@vierarb
vierarb / gist:9b1986a78d14f5dae60d
Created May 23, 2014
Polar Area chart with d3js
View gist:9b1986a78d14f5dae60d
var width = 750;
var height = 500;
var radius = 200;
var strokeColor = "#999";
var strokeOpacity = 0.75;
var labelMargin = radius + 20;
var concentric = [];
for(var i = 1; i <= 10; i++) {
concentric.push((radius * i) / 10);