Skip to content

Instantly share code, notes, and snippets.

Avatar

Abimael Martell abimaelmartell

View GitHub Profile
@abimaelmartell
abimaelmartell / closestNumbers.js
Created Mar 13, 2021
Given an array of distinct integers, determine the minimum absolute difference between any two elements. Return all element pairs with that minimal absolute difference in ascending order.
View closestNumbers.js
/*
* Complete the 'closestNumbers' function below.
*
* The function accepts INTEGER_ARRAY numbers as parameter.
*/
const closestNumbers = (numbers) => {
let result = [];
let minimalDistance = Infinity;
numbers.sort((a, b) => a - b);
@abimaelmartell
abimaelmartell / FantasticFour.java
Last active Feb 15, 2021
Clase para Tarea de Programación Orientada a Objetos
View FantasticFour.java
import learning.business.superAnimals.ElasticHuman;
import learning.business.superAnimals.HomoSapiens;
import learning.business.superAnimals.Superman;
import learning.business.superAnimals.Invisible;
import learning.basicGUI.BaseAppGUI;
import learning.basicGUI.ImagePanel;
import learning.basicGUI.InternalButton;
import learning.basicGUI.FlowPanel;
import learning.basicGUI.GridPanel;
import java.awt.TextArea;
@abimaelmartell
abimaelmartell / 🍝.php
Created Jan 28, 2021
Ejemplo de Espaghetti
View 🍝.php
<?php
$servername = "127.0.0.1";
$username = "user";
$password = "password";
$dbname = "db";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
View Dockerfile
FROM ruby:2.7.0-alpine
ENV PORT=80
RUN apk add --no-cache \
build-base \
libxml2-dev \
libxslt-dev \
postgresql-dev \
tzdata
@abimaelmartell
abimaelmartell / gh-pages.yml
Created Feb 13, 2020
Deploy Slate Documentation to Github Pages using Github Actions
View gh-pages.yml
name: Github Pages Build
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
@abimaelmartell
abimaelmartell / default_gateway.go
Created Oct 19, 2016
Get default gateway by parsing RIB information using the net/route package. BSD Only.
View default_gateway.go
package main
import (
"fmt"
"golang.org/x/net/route"
)
var defaultRoute = [4]byte{0, 0, 0, 0}
func main() {
@abimaelmartell
abimaelmartell / ruby process debug.md
Last active Jun 15, 2016
Debug a memory leak, or a hanging process on a rails application.
View ruby process debug.md

Attach the process to a gdb session.

sudo gdb $(rbenv which ruby) $(pgrep thin)

Enter this on the gdb prompt.

set $ary = (int)backtrace(-1)
View Makefile
all:
gcc main.c -o main -ltcejdb -std=c99 -Wall -fPIC -pedantic -O2
View layout.erb
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Application</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>