Skip to content

Instantly share code, notes, and snippets.

View oscarryz's full-sized avatar

Oscar Reyes oscarryz

View GitHub Profile
oscarryz / Password.exs
Created March 23, 2021 16:34
Basic "while" loop in elixir
defmodule Password do
@doc """
Consider a basic password loop
it exists with a positive result if the user chooses the right password
It exists with a negative result if theuser is wrong three times
How would you code this loop
def guess(attempts \\ 0)
def guess(attempts) when attempts < 3 do
guess = IO.gets "Guess: "
/* full component */
.button {
color: red;
font-family: sans-serif;
..etc. etc.
/* or utilities */
.red {
color: red;
oscarryz / Testing express
Last active February 13, 2020 23:23
Testing with supertest and mockery


  • Use mockery to inject a mock the require dependency
  • Use supertest to make an http request to the server
  • Use mocha as test runner

How to test express controllers


Source code for this example

I think StackOverflow was awesome when it started (and several years later still is) but over then it had failed to innovate / grow.

There has been attempts to create products like SO documentation, and SO jobs (and now SO teams) but they are not aligned with what made SO good in the first place. ¿What is the one thing SO was meat to solve in the first place?

This is was Jeff Atwood wrote when it was launched:

Stackoverflow is sort of like the anti-experts-exchange (minus the nausea-inducing sleaze and quasi-legal search engine gaming) meets wikipedia meets programming reddit. It is by programmers, for programmers, with the ultimate intent of collectively increasing the sum total of good programming knowledge in the world. No matter what programming language you use, or what operating system you call home. Better programming is our goal.

ElementHandle {
ExecutionContext {
CDPSession {
_events: [Object],
_eventsCount: 27,
_maxListeners: undefined,
_callbacks: Map {},
_connection: [Connection],
abstract class A {
public String s() {
return this.getClass().getName();
class B extends A {
public static void main(String...args) {
System.out.println(new B().s());
"hash": "87b6c030d59c1c74357bb19a89d206517e09df2d"
class A {
private int i;
public String toString() { return ""+ i; }
class B extends A {}
class Main {
public static void main( String [] args ) {