Skip to content

Instantly share code, notes, and snippets.

Diogo Scudelletti scudelletti

Block or report user

Report or block scudelletti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@scudelletti
scudelletti / import_and_extend.exs
Created Oct 25, 2018
Delegates methods to "imported" module on Elixir
View import_and_extend.exs
defmodule Father do
def sing() do
IO.puts "Lalalalalala"
end
def song(a, b) do
turn_bass_on()
IO.puts "Lelelelelele #{a} #{b}"
end
View pir.ino
// http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/
int ledPin = 13;
int pirPin = 2;
int default_remaining = 30;
int remaining = 0;
int val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
@scudelletti
scudelletti / export_env.sh
Created Apr 13, 2018
Export Env Variables stored on /etc/environment
View export_env.sh
# Loan Env Variables
while read line; do
export $(echo $line | sed 's/"//g')
done < /etc/environment
@scudelletti
scudelletti / numbers_in_lambda_calculus.lisp
Last active Dec 10, 2018
Numbers in Lambda Calculus - Following Destroy All Software approach
View numbers_in_lambda_calculus.lisp
;; Church Numbers
(setq zero (lambda (f) (lambda (x) x)))
(setq one (lambda (f) (lambda (x) (funcall f x))))
(setq two (lambda (f) (lambda (x) (funcall f (funcall f x)))))
;; Manual Calc
(funcall (funcall zero (lambda (x) (+ 1 x))) 0)
(funcall (funcall one (lambda (x) (+ 1 x))) 0)
(funcall (funcall two (lambda (x) (+ 1 x))) 0)
@scudelletti
scudelletti / Dockerfile
Last active Jun 21, 2017
Run GUI Linux Apps through Docker with xQuartz on MacOS
View Dockerfile
# How to Use
# open -a XQuartz
# socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# docker build . -t ds-xclock
# docker run -e DISPLAY=YOUR_LOCAL_IP_HERE:0 -it ds-xclock
#
# Useful Links:
# https://github.com/moby/moby/issues/8710
# http://kartoza.com/en/blog/how-to-run-a-linux-gui-application-on-osx-using-docker/
@scudelletti
scudelletti / class_definition_in_specs.rb
Created May 27, 2016
How to avoid global constant in the specs
View class_definition_in_specs.rb
require 'spec_helper'
describe "Wow Coins" do
let(:klasz_class) do
Class.new do
attr_reader :title
def initialize(properties)
@title = properties[:title]
end
@scudelletti
scudelletti / ssh_config
Last active Apr 22, 2016
Forward port on SSH
View ssh_config
Host *.staging.something.com
User someuser
ForwardAgent yes
LocalForward localhost:43306 localhost:3306
LocalForward localhost:49200 localhost:9200
LocalForward localhost:49001 localhost:9001
@scudelletti
scudelletti / lambda_calculus.rb
Last active Nov 22, 2016
If condition on lambda calculus
View lambda_calculus.rb
# Rules: A lamda always has 1 parameter, nothing more, nothing less
# Useful Content: https://en.wikipedia.org/wiki/Church_encoding
# Identity lambda
IDENTITY = ->x { x }
# True, returns the first argument
TT = ->x { ->y { x } }
# False, returns the last argument
@scudelletti
scudelletti / class_variable_example.rb
Last active Aug 29, 2015
Ruby Class Variable Examples without @@
View class_variable_example.rb
# Ruby Class Variable Examples without @@
# http://www.sitepoint.com/class-variables-a-ruby-gotcha/
class Foo
def self.talk
puts 'Hey! I\'m talking'
end
end
class Bar
@scudelletti
scudelletti / count_words_loop.clj
Last active Aug 29, 2015
Count Words using Clojure - Loop and Map Reduce Way
View count_words_loop.clj
(defn split-words
[phrase]
(clojure.string/split phrase #"\s"))
(defn count-words
[phrase word]
(let [words (split-words (clojure.string/lower-case phrase))
lower-case-word (clojure.string/lower-case word)]
(loop [head (first words)
tail (rest words)
You can’t perform that action at this time.