Skip to content

Instantly share code, notes, and snippets.

View ulisesantana's full-sized avatar
😍
In love with TypeScript

Ulises Santana ulisesantana

😍
In love with TypeScript
View GitHub Profile
@ulisesantana
ulisesantana / dialog.html
Last active February 14, 2017 22:19
Jugando con elementos y con JavaScript en línea
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Jugando con elementos</title>
</head>
<body>
<button onclick="modal.show()">MODAL</button>
@ulisesantana
ulisesantana / localStorage.service.js
Last active January 19, 2022 06:55
Service for localStorage
function localStorageService() {
return {
get(itemName) {
const item = localStorage.getItem(itemName);
const numPatt = new RegExp(/^\d+$/);
const jsonPatt = new RegExp(/[\[\{].*[\}\]]/);
if(item){
if(jsonPatt.test(item)){
return JSON.parse(item);
@ulisesantana
ulisesantana / vscode.sh
Last active November 17, 2017 16:02
My script for setting up a just installed Visual Studio Code
#!/bin/bash
code --install-extension ikappas.phpcs
code --install-extension ms-vscode.Theme-MarkdownKit
code --install-extension sakryukov.convert-markdown-to-html
code --install-extension whatwedo.twig yzane.markdown-pdf
code --install-extension PeterJausovec.vscode-docker
code --install-extension be5invis.toml
code --install-extension christian-kohler.npm-intellisense
code --install-extension christian-kohler.path-intellisense
code --install-extension leizongmin.node-module-intellisense
@ulisesantana
ulisesantana / docker-msyql.sh
Last active July 2, 2020 09:30
Create a MySQL docker instance for develop
#!/bin/bash
export MYSQL_ROOT_PASSWORD=root MYSQL_ROOT_HOST=%
sudo mkdir -p /data/mysql
sudo chmod -R 775 /data
docker run --name=mysql -d \
-e MYSQL_ROOT_PASSWORD \
@ulisesantana
ulisesantana / fizzBuzz.js
Last active May 12, 2018 11:21
Fizz Buzz JavaScript Solution
function fizzBuzz(num) {
const isDivisibleBy = x => y => y % x === 0;
const isDivisibleBy3 = isDivisibleBy(3);
const isDivisibleBy5 = isDivisibleBy(5);
return isDivisibleBy3(num) && isDivisibleBy5(num)
? 'FizzBuzz'
: isDivisibleBy3(num)
? 'Fizz'
: isDivisibleBy5(num)
@ulisesantana
ulisesantana / index.js
Created July 7, 2018 12:11
Proof of concept about inheritance in JS without classes
function Animal(animalName, animalType) {
let name = animalName;
const type = animalType;
return {
getName() {
return name;
},
setName(newName) {
name = newName;
@ulisesantana
ulisesantana / portainer-service.sh
Last active October 17, 2020 05:29
Create portainer as docker swarm service
#!/bin/bash
mkdir -p /data/portainer
docker service create \
--name portainer \
--publish 9000:9000 \
--replicas=1 \
--constraint 'node.role == manager' \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
--mount type=bind,src=/data/portainer,dst=/data \
portainer/portainer-ce -H unix:///var/run/docker.sock
@ulisesantana
ulisesantana / QuicksortJS.md
Last active July 21, 2018 12:25
JavaScript Quicksort algorithm implementation

QuickSort JavaScript implementation

This is my implemention of Quicksort algorithm in JavaScript. According to Wikipedia the Quicksort algorithm is:

Quicksort is a divide and conquer algorithm. Quicksort first divides a large array into two smaller sub-arrays: the low elements and the high elements. Quicksort can then recursively sort the sub-arrays.

The steps are:

  • Pick an element, called a pivot, from the array.
  • Partitioning: reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
@ulisesantana
ulisesantana / reduxTdd.d.ts
Created September 13, 2018 20:17
redux-tdd typing
declare module "redux-tdd" {
import { ActionsObservable } from 'redux-observable';
import { combineReducers, ReducersMapObject } from 'redux'
import { shallow, ShallowWrapper } from 'enzyme';
class ReduxTdd {
constructor(reducers: ReducersMapObject, render: Function)
getCurrentWrapper(): ShallowWrapper
it(str: string): ReduxTdd
@ulisesantana
ulisesantana / styleguide.config.js
Last active January 25, 2019 08:53
React Styleguidist Config for Create React App(^2.1.3) with TypeScript
module.exports = {
components: 'src/components/**/[A-Z]*.{ts,tsx}',
propsParser: require('react-docgen-typescript').parse,
webpackConfig: require('react-scripts/config/webpack.config.js')
};