Skip to content

Instantly share code, notes, and snippets.

🐢
null

Marco DonSchado

🐢
null
Block or report user

Report or block DonSchado

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DonSchado
DonSchado / playground.rb
Last active Nov 6, 2019
ActiveRecord Playground File `irb -r ./playground.rb` (or `pry ...`)
View playground.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'sqlite3'
gem 'activerecord', "~> 6.0.0.rc2"
end
require 'active_record'
@DonSchado
DonSchado / translations.rb
Last active Oct 15, 2019
Railslove Ruby programming exercise A4
View translations.rb
# Railslove Ruby programming exercise A4
#
# To run the following exercise you need to have rspec installed.
# Then inspect the failing specs by running `rspec translations.rb`
#
# This excercise is special, because it's the first one where you're allowed to require active_support. ;-)
#
# (!) The task is to navigate and write into a nested hash via a path represented as `.` separated keys.
#
# (?) Maybe start with the underling algorithm to expand a collection to a "directed graph"
@DonSchado
DonSchado / tty.rb
Last active Apr 20, 2018
Fancy Ruby
View tty.rb
c=[' ',?█].cycle;w="173322172322\n2322232223221322\n23222322262322\n263322232225\n23123322232233\n23222322232233\n2322353643".chars.reduce([]){|r,n|n==$/?r<<n:r<<c.next*n.to_i;r}.join.split($/).map{|c|c.chars.map{|c|c*2}.join<<$/}.map{|r|r*2}.join;loop{$><<"\e[2J\e[1;1H"<<w.chars.map{|t|"\e[38;5;#{rand(230)}m#{t}"}*'';sleep 1}
@DonSchado
DonSchado / mission.rb
Created Dec 20, 2017
Railslove Ruby programming exercise A3
View mission.rb
# Railslove Ruby programming exercise A3
#
# To run the following exercise you need to have rspec installed.
# Then inspect the failing specs by running `rspec mission.rb`
#
# How well did the avengers manage their time on their missions?
# Your task is to group all time entries by mission and then sum the minutes in total per avenger.
# After grouping the entries the expected response looks something like:
#
# {
@DonSchado
DonSchado / subsets.rb
Created Nov 24, 2017
Railslove Ruby programming exercise A2
View subsets.rb
# Railslove Ruby programming exercise A2
#
# To run the following exercise you need to have rspec installed.
# Then inspect the failing specs by running `rspec subset.rb`
#
# The task is to get all possible subsets of a group of Railslovers (without duplicates).
# So return a collection containing a group of each Railslover alone,
# then a group of pairs, then groups of 3, etc...
# The empty group is not considered a valid Railslove group. :)
#
@DonSchado
DonSchado / filter.rb
Created Nov 21, 2017
Railslove Ruby programming exercise A1
View filter.rb
# Railslove Ruby programming exercise A1
#
# To run the following exercise you need to have rspec installed.
# Then watch the output of `rspec filter.rb` and see 3 of 4 failing specs.
#
# The task is to filter a given collection (L#31) for entries that contain unique pairs.
# While filtering return the same structure and keep the ranking.
#
# Write code in the body of the filter method to make the tests pass.
#
@DonSchado
DonSchado / config.ru
Created May 11, 2016
140 character rails application that returns http status 200
View config.ru
require'action_controller/railtie';run Class.new(Rails::Application){config.secret_key_base=?x;routes{root to:->_{[200,{},[]]}}}.initialize!
@DonSchado
DonSchado / notification.js
Last active May 10, 2016 — forked from kangguru/notification.js
Mangopay Notifications
View notification.js
// ==UserScript==
// @name Mangopay Notifications
// @namespace http://tampermonkey.net/
// @version 0.1
// @description simulate mangopay notifications direct from the dashboard
// @author Lars Brillert
// @include /https://dashboard.sandbox.mangopay.com/Users/\d+/WalletTransactions/\d+/
// @grant none
// ==/UserScript==
/* jshint -W097 */
@DonSchado
DonSchado / fast_elasticsearch_importer.rb
Created Nov 24, 2014
the elasticsearch-rails client provides a relatively simple interface for the Elasticsearch Bulk API, which can speed up the indexing
View fast_elasticsearch_importer.rb
# A FASTER IMPORTER
#
# the built-in import is not very efficient.
# It grabs every record, builds the ActiveRecord object
# and calls #as_indexed_json on it.
#
# for large sets of data that spans multiple relations,
# this can take a lot of time to complete.
#
# the elasticsearch-rails client provides a relatively simple interface for
@DonSchado
DonSchado / layer-css
Created Nov 23, 2014
Different depth of nodes will use different colour allowing you to see the size of each element on the page, their margin and their padding. Now you can easily identify inconsistencies.
View layer-css
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
You can’t perform that action at this time.