Skip to content

Instantly share code, notes, and snippets.

View groteck's full-sized avatar
:octocat:

Juan Fraire groteck

:octocat:
View GitHub Profile
@groteck
groteck / test.ts
Last active July 5, 2021 15:14
Examples of Typescript
// ?. Mixed with the type system
let thing: number | undefined | string | { descripcion: string } = 1;
console.log(thing?.descripcion); // => test.ts(2,20): error TS2339: Property 'descripcion' does not exist on type 'number'.
thing = "test";
console.log(thing?.descripcion); // => test.ts(5,20): error TS2339: Property 'descripcion' does not exist on type 'string'.
thing = { descripcion: "test" };
console.log(thing?.descripcion); //=> test.ts(11,20): error TS2339: Property 'descripcion' does not exist on type 'string | number | { descripcion: string; }'.
@groteck
groteck / input.unknown
Last active February 21, 2019 11:03
Elm ctags
port module Main exposing (..)
import List
import Maybe exposing (withDefault)
import Json.Encode as Je
type Thing
= One
| Two Int
@groteck
groteck / UrlParser.md
Last active December 12, 2018 12:51
Params parser generator

This is an example of a url parser generated from a list of types

@groteck
groteck / css-svg-spinner.markdown
Created September 25, 2017 00:33
css svg spinner
@groteck
groteck / Facebook.elm
Last active November 2, 2018 22:10
elm facebook integration test
port module Facebook exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
import Debug
main =
@groteck
groteck / Spelling.elm
Last active February 20, 2020 18:01 — forked from evancz/Spelling.elm
Remove unused import
port module Spelling exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
import String
main =
program
{ init = init
@groteck
groteck / blocks
Last active April 11, 2016 17:48
Blocks with "do" are different to Blocks with "{}"
#!/usr/bin/env ruby
puts "Count with {}"
puts [[1,1],[2],[3],[4,3]].count { |elements| !elements.all? { |element| element == elements.first } or elements.size == 1 }
puts "----------------------"
# Response:
# Count with {}
# 3
# ----------------------
@groteck
groteck / boot.rb
Last active February 3, 2016 22:08
Access to rails in docker from outside
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '0.0.0.0', Port: 3000)
end
end
end
@groteck
groteck / csv_with_semicolons_or_colons_parser.rb
Last active January 19, 2021 03:31
Parse CSV file for colons or semicolons
# CSV.parse(csv_header, col_sep: ColSepSniffer.find(csv_header))
# returns a CSV::Table object
p CSV.parse(csv_file,
headers: true,
col_sep: ColSepSniffer.find(csv_headers)).map(&:to_hash)
#!/usr/bin/env ruby
# encoding: utf-8
require "csv"
@groteck
groteck / .zshrc
Last active August 29, 2015 14:19
my zsh config file
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="pygmalion"
# Uncomment the following line to use case-sensitive completion.