Skip to content

Instantly share code, notes, and snippets.

View bitmaybewise's full-sized avatar
🏠
Working from home

Hercules Merscher bitmaybewise

🏠
Working from home
View GitHub Profile
@bitmaybewise
bitmaybewise / pattern_matching.rb
Last active August 29, 2015 14:14
Ruby's pattern matching
# pattern matching on blocks
def print_break(msg)
puts '-' * 50, msg
end
print_break 'normal params'
block = -> (one, two) { p one, two }
block.call(1, 2)
# 1
@bitmaybewise
bitmaybewise / DoNotation.hs
Created November 22, 2014 13:18
Playing with Haskell monads and do notation
module DoNotation where
-- without do notation
-- applying only >>=
monadChainSuccess1 = Just "hello" >>= \xs ->
Just (xs ++ " ") >>= \ys ->
Just (ys ++ "world")
-- applying >>= and >>
@bitmaybewise
bitmaybewise / WordCounter.hs
Last active August 29, 2015 14:08
Um contador de palavras numa frase em Haskell
import Data.List
frase = "vaca batata galinha batata coxinha macaco batata vaca batata"
wordCounter frase =
nub $ map (\x -> (x, length $ filter (== x) palavras)) palavras
where palavras = words frase
-- [("vaca",2),("batata",4),("galinha",1),("coxinha",1),("macaco",1)]
@bitmaybewise
bitmaybewise / README.md
Created August 12, 2014 23:16
Yesod HelloWorld

Yesod HelloWorld

$ cabal install yesod

$ runhaskell helloworld.hs

@bitmaybewise
bitmaybewise / InferenciaDeTipo.cs
Last active December 14, 2015 13:18
Tipagem fraca/forte e inferência de tipo
using System;
public class InferenciaDeTipo
{
public static void Main(String[] args)
{
int valor1 = 10;
String valor2 = "Valor";
var permitido1 = 1;
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<title>Audio and video</title>
</head>
<body>
<!-- Audio -->
<audio src="musica.ogg" controls="true" autoplay="true" />
@bitmaybewise
bitmaybewise / git-commands.md
Last active October 13, 2015 20:48
Git commands

List deleted files and removes each

$ git ls-files -d | xargs git rm

Show a text-based graphical representation

$ git log --graph

Ignoring changes in tracked files

@bitmaybewise
bitmaybewise / fizzbuzz.rb
Created December 10, 2012 22:51
FizzBuzz inline. It's bad.
100.times {|n| puts (if n % 3 == 0 && n % 5 == 0; 'FizzBuzz'; elsif n % 3 == 0; 'Fizz'; elsif n % 5 == 0; 'Buzz'; else; n; end)}
@bitmaybewise
bitmaybewise / FizzBuzz.cs
Created September 29, 2012 01:53
FizzBuzz: From DojoPuzzles
/*
* FizzBuzz
* http://dojopuzzles.com/problemas/exibe/fizzbuzz/
*/
using System;
using System.Text;
namespace FizzBuzz
{