Skip to content

Instantly share code, notes, and snippets.

View denisdefreyne's full-sized avatar

Denis Defreyne denisdefreyne

View GitHub Profile
@jseppi
jseppi / Rules
Last active July 4, 2016 06:59 — forked from bburton/Rules
Default Rules and nanoc.yaml for the nanoc static site generator. The included config.rb is useful for setting up Compass configuration properties if using Compass.
#!/usr/bin/env ruby
# This Rules file is an attempt at a near zero configuration for the common
# use cases when creating a simple site with nanoc. It's meant to have
# better defaults so new users don't have to configure it much if at all.
# For the most part, it copies all files from the content folder to the
# output folder with the same name. It has the following features:
#
# * Certain predefined page extensions such as html, haml, md, markdown and
# textile are routed to "clean" URI's (see below regarding Item identifiers).
@datanoise
datanoise / crystal-tags.cr
Last active March 5, 2021 03:24
ctags for crystal language
require "compiler/crystal/**"
require "option_parser"
include Crystal
class ToCtagsVisitor < Visitor
@filename : String
@lines : Array(String)
@io : IO
@opts : Generator

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@pixeltrix
pixeltrix / time_vs_datatime.md
Last active April 30, 2026 00:16
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@baweaver
baweaver / fizzbuzz_ultragolf.rb
Last active August 29, 2015 14:23
Ox0dea had a bit of fun, and I wanted to know how he did it.
# Original from Ox0dea - http://irclog.whitequark.org/ruby/2015-06-29#13259662;
# Yes, it produces FizzBuzz
_=$$/$$;__=_-_;@_=_+_;$_=@_+_;$__=@_+$_;$-_=$__*$_;@__=''<<$-_*($__+$_)+@_;$___=''<<$-_*$__-$__<<$-_*($__+@_)<<@__<<@__;@___=''<<$-_*$__-$_*$_<<$-_*($__+$_)-$_<<@__<<@__;(___=->____{$.+=_;____<<($.%$-_==__ ?$___+@___:$.%$_==__ ?$___:$.%$__==__ ?@___:$.);$.<($__*@_)**@_?___[____]:____})[[]]
# Wtf!? Let's disect it then
_ = $$ / $$ # PID / PID or 1
__ = _ - _ # 1 - 1 or 0
@_ = _ + _ # 1 + 1 or 2
@keplersj
keplersj / logged.rs
Created July 25, 2015 21:00
Gist demonstrating the ability to run Crystal code from Rust.
#[link(name = "logger")]
extern {
fn CrystalLog(text: *const u8);
}
fn log(text: &'static str) {
unsafe{ CrystalLog(text.as_bytes().as_ptr()) };
}
fn main() {
@benoist
benoist / Guardfile
Last active November 8, 2015 11:22
Crystal guard file
# gem install guard
# gem install guard-process
guard 'process', :name => 'Spec', :command => 'crystal spec' do
watch(/spec\/(.*).cr$/)
watch(/src\/(.*).cr$/)
end
guard 'process', :name => 'Build', :command => 'crystal build app.cr' do
watch(/src\/(.*).cr$/)
@porras
porras / Dockerfile
Created March 20, 2017 13:00
Dockerfile and wrapper script for a nanoc project
FROM ruby:2.4
ADD Gemfile /opt/
ADD Gemfile.lock /opt/
WORKDIR /opt
RUN bundle install
CMD bundle exec nanoc -v
@raganwald
raganwald / sequence.es6
Last active June 18, 2017 09:31
Generating sequences using iterators and without integers or arrays
/////////////////////////////////////////////////////////////////////////////////
// Generating "A Sequence Problem" using iterators, without integers or arrays //
// See http://raganwald.com/2017/06/04/sequences.html //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Generic things useful for working with interables and iterators //
/////////////////////////////////////////////////////////////////////
// 1. These operations produce repeatable iterables.