Skip to content

Instantly share code, notes, and snippets.

View TimelockController.json
[
{
"inputs": [
{
"internalType": "uint256",
"name": "minDelay",
"type": "uint256"
},
{
"internalType": "address[]",
View id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArlNte/eRXh5rFRFbKzqIb15Vir2gyyLCu1Lfq5oLGCNS4XFTN9zZTJLFg+g3iY4K5x7omKK/+D+fRvcHRT0T8/pt2zfHpmNV7qZDkwiJSBEyO2o/51/BM/4Pfd03jrYlt3MTwYL8s0BqFAztRJEhg3oqIbFZDYRTCjGelwQ4NCbGAjQPuXkZIF60LuyorH02BjNBwaWAJxcK9FDz9rF8aXM7L59AoZZNDpPJp8HjX6LtwrQvQoSQ7RcwrTCa6RR6JOPh8KraqhYkZLwa2Wo2AU3YESo+RdzMaUaEFy98NeVTpQbGI5lXVdrFjPj5RyT9iyLsm/zNn7nKpLFPL58eFQ== mverzilli@mscebba.manas.com.ar
@mverzilli
mverzilli / gist:1105181
Created Jul 25, 2011
Context aware entities in Entity Framework
View gist:1105181
public partial class CountryShardedDatabase
{
public static CountryShardedDatabase FromCountry(string country)
{
var db = new CountryShardedDatabase(string.Format("name={0}", ConfigurationManager.ConnectionStrings[country].Name));
db.Country = country;
db.ObjectMaterialized += new System.Data.Objects.ObjectMaterializedEventHandler(db_ObjectMaterialized);
return db;
@mverzilli
mverzilli / interf.cr
Last active Jul 19, 2017
Using modules as interfaces in Crystal
View interf.cr
module Foo
abstract def foo_sth
end
class SomeFoo
include Foo
end
class Bar
def initialize(@foo : Foo)
@mverzilli
mverzilli / circle.yml
Created Jun 15, 2016
CircleCI for Crystal Projects
View circle.yml
# Include this file in your project's root folder to integrate with CircleCI.
# Replace 0.18.0 with the Crystal version you're using.
dependencies:
cache_directories:
- "crystal-0.18.0-1"
pre:
- if [[ ! -e crystal-0.18.0-1 ]]; then wget https://github.com/crystal-lang/crystal/releases/download/0.18.0/crystal-0.18.0-1-linux-x86_64.tar.gz && tar xvfz crystal-0.18.0-1-linux-x86_64.tar.gz; fi
test:
pre:
- crystal-0.18.0-1/bin/crystal deps
@mverzilli
mverzilli / how_we_build_crystal_the_executable.md
Last active Apr 9, 2017
How we build `crystal`, the executable
View how_we_build_crystal_the_executable.md

How we build crystal, the executable

Note: most of this article is simply an incomplete natural language narration of what Crystal's Makefile specifies. If you, like me, feel a bit intimidated by Make, you may find this article more welcoming than venturing into the code by yourself and figuring things out from scratch.

At the root level of crystal-lang/crystal there's a Makefile that triggers the build process. The default task in that Makefile is crystal. That task checks whether there's a .build/crystal executable. To build the executable, you first need its dependencies (DEPS) and the source code (SOURCES).

With the dependencies built and the list of source code files, we are ready to compile Crystal, by running a previous version of the compiler that sits at bin/crystal. The new compiler will be written to .build/crystal.

View gist:3112e642f5c2f9eb2d171cfeb75f09e3
def get()
if 2 > 1
{"String", {"foo" => "bar"}}
else
nil
end
end
x = get
case x; when {String, Hash}; p typeof(x); end
@mverzilli
mverzilli / piedoom.cr
Last active Sep 16, 2016
piedoom's problem
View piedoom.cr
require "json"
class Blog
JSON.mapping({
name: {type: String},
likes: {type: Int32},
following: {type: Int32},
default_post_format: {type: String},
})
end
@mverzilli
mverzilli / kmanas.cr
Created Mar 7, 2016
Crystal implementation of Kmeans for a poll @ Manas,
View kmanas.cr
require "csv"
MINIMUM_DISTANCE = 0.85
SIMILARITY_LOW_BOUND = 0.30
SIMILARITY_HIGH_BOUND = 0.60
BIT_DICTIONARY = ["1a", "1b", "1c", "1d", "2a", "2b", "2c", "2d", "3a", "3b", "4a", "4b", "4c", "5a", "5b", "5c", "5d", "6a", "6b", "6c", "7a", "7b", "7c", "8a", "8b", "8c", "9a", "9b", "9c", "9d", "9e", "9f", "9g", "10a", "10b", "10c", "10d", "11a", "11b", "12a", "12b", "12c", "13a", "13b", "13c", "13d"]
RANDOM = Random.new 23
@mverzilli
mverzilli / tdd_diary.rb
Last active Jan 4, 2016
Diary of the development of a new feature using TDD
View tdd_diary.rb
# Day 1, 12:00pm
# In facility_xml_generator_spec.rb, which tests the entry point for the feature I'm adding,
# I wrote a Given-When-Expect structured natural language description of my understanding of what it means for the feature to be there.
# The only piece of code so far is the construction of the SUT and a tentative name for the method that provides the
# functionality without any params.
describe 'Coded Types generation' do
it '' do
# Given that CSD codedType semantics are added to an RM's single option field by adding the metadata below to it:
# CSDType => 'codedType', codingSchema => 'foo'