Skip to content

Instantly share code, notes, and snippets.

View luciomartinez's full-sized avatar
🍫
I'd code for chocolates

Lucio Martinez luciomartinez

🍫
I'd code for chocolates
View GitHub Profile
@luciomartinez
luciomartinez / AppRouter.spec.js
Last active April 8, 2020 17:47
Showcases of spying/mocking/stubbing that are hard to remember
/**
* When testing usage of React Router DOM library, the `BrowserRouter` component gets in the way.
* This component must be mocked in order to test children components such as Route.
*
* Here's the JSX rendered by the component to be tested (`AppRouter.js`):
* <Router>
* <Switch>
* <Route exact path="/home" component={HomePage} />
* <Route ... />
* </Switch>
@luciomartinez
luciomartinez / functional.js
Last active August 24, 2017 00:19
Functional vs imperative vs OOP in JavaScript examples
function() {
"use strict";
var capify = function(str) {
return [str.charAt(0).toUpperCase(), str.substring(1)].join("");
};
var processWords = function(fn, str) {
return str.split(" ").map(fn).join(" ");
};
document.getElementById("main_button").addEventListener("click", function(e) {
var something = prompt("Give me something to capitalize");
@luciomartinez
luciomartinez / slash.sh
Last active June 1, 2023 08:49
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
@luciomartinez
luciomartinez / LA_POSTA.md
Last active January 26, 2023 23:50
Cómo usar PostgreSQL en GNU/linux?

Instalar postgres, el garron de tu vida

$ sudo apt install postgresql postgresql-contrib

Create un usuario como super user cuando es tan inutil que no va a servir para loguearte

$ sudo -u postgres createuser --interactive -P

Loguearte como postgres porque tu user es aun una bosta

@luciomartinez
luciomartinez / git-help.md
Last active November 10, 2023 17:57
Git for humans

How to get a remote repository (from BitBucket, GitHub or anyone)

$ git clone https://github.com/<username>/<repository>.git

If you have added a SSH key, then you can also use this command:

$ git clone git@bitbucket.org:<username>/<repository>.git

How to create a new repository from the command line

@luciomartinez
luciomartinez / index
Last active December 20, 2015 14:18
Very simple HTML page that loads dynamical content using jQuery AJAX function calling a Perl script.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Home</title>
</head>
<body>
<div id="container">Nothing was loaded yet..</div>
<!-- Load jQuery at the end of the rendering -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
@luciomartinez
luciomartinez / GetChar.py
Last active December 18, 2015 02:28
Persons is a CLI Unix system wrote in Python. This application offer the possibility to create, edit, save and remove information with a command line interface.
#~ Created by Danny Yoo on Fri, 21 Jun 2002
#~ Under the PSF license
#~ http://code.activestate.com/recipes/134892/
class GetchUnix:
def __init__(self):
import tty, sys
def __call__(self):