Skip to content

Instantly share code, notes, and snippets.

View oscarryz's full-sized avatar

Oscar Reyes oscarryz

View GitHub Profile
@oscarryz
oscarryz / gist:4121184
Created November 20, 2012 21:14
Brief history of Objective-C square brackets

Brief history of the "square brackets" as I remember it.

One of the most challenging aspects of the language are the square brackets because they look like arrays, as you just mention.

As I remember the language was inspired in smalltalk, but using C to gain speed.

The idea behind smalltalk was to send message as we do with real life objects. For instance if I ask you your age I would say something like this in natural language:

// Copiarlo todo en un archivo llamado:
// Ejemplo.java
// y compliar con:
// javac Ejemplo.java
// para probar con:
// java SistemaDeVenta
//
class Cliente {
String nombre;
Tarjeta tarjeta;
@oscarryz
oscarryz / Imagen.java
Created June 23, 2011 19:27
Cómico!, visor de imagenes escrito por José Manuel Hernandez Farias
/**
* Aplicacion que simula ser un visor de imagenes...
* Creado por: Jose Manuel Hernandez Farias @author KaltWulx
* Version: 0.0.0.0 :D
* @warning: Hecho por un novice Lvl 1/1... D:
*/
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
@oscarryz
oscarryz / Dagger 2 example.md
Last active September 11, 2021 11:36
Dagger 2 example

This example contains initially 3 java files:

  • SearchApp.java Has the main method
  • SearchInPage.java Perfoms the search of a keyword in a string
  • HttpClient.java Fetch a webpage

SearchInPage has a dependency on HttpClient, this example is to show how Dagger 2 can be used as Dependency Injection framework.

With Dagger 2 we change the dependency by adding the @Inject annotation, and we add 2 more clases: a Module and a Component which will be used by Dagger 2 to generate the required code to satisfy the dependency injection

@oscarryz
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
oscarryz / Testing express controllers.md
Last active February 13, 2020 23:23
Testing with supertest and mockery

TL;DR

  • 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

Setup

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:

https://blog.codinghorror.com/stack-overflow-none-of-us-is-as-dumb-as-all-of-us/

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 {
_context:
ExecutionContext {
_client:
CDPSession {
_events: [Object],
_eventsCount: 27,
_maxListeners: undefined,
_callbacks: Map {},
_connection: [Connection],