Skip to content

Instantly share code, notes, and snippets.

View clementf's full-sized avatar

Clément Férey clementf

View GitHub Profile
@clementf
clementf / Markdium-crystal.cr
Created July 18, 2019 20:59
Markdium-Iterator, how to handle paginated APIs in Crystal, with lazy loading
class Tracks
include Iterator(Spotify::Track)
end
@clementf
clementf / Markdium-crystal.cr
Created July 18, 2019 20:59
Markdium-Iterator, how to handle paginated APIs in Crystal, with lazy loading
Playlist.new(playlist_id).tracks.each { |track|
puts "Track name is #{track.name}"
end
@clementf
clementf / Markdium-crystal.cr
Created July 18, 2019 20:59
Markdium-Iterator, how to handle paginated APIs in Crystal, with lazy loading
Spotify::Tracks.new(playlist_id).each { |track| puts track.name }
@clementf
clementf / Markdium-crystal.cr
Last active July 19, 2019 06:41
Markdium-Iterator, how to handle paginated APIs in Crystal, with lazy loading
module Spotify
class Tracks
# Iterator provides useful methods such as: each, select, reject, uniq etc...
include Iterator(Spotify::Track)
# @playlist_id in constructor allows for instanciation of instance var
# reducing boilerplate needed if you'd write this in ruby.
def initialize(@playlist_id : String)
@index = 0
@total_size = -1
# Download iterm
# install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
#create code folder
mkdir -p code/dotfiles
@clementf
clementf / server-setup.sh
Last active May 13, 2018 12:48
Useful commands to get a machine up and running quickly
#Download Ubuntu LTS
# create user
adduser clem
# add to shudders
usermod -aG sudo clem
# download git
Sudo apt-get install git