Skip to content

Instantly share code, notes, and snippets.

View alexsc6955's full-sized avatar
🏠
Working from home

Santiago alexsc6955

🏠
Working from home
View GitHub Profile
@alexsc6955
alexsc6955 / binary_search.py
Created June 5, 2023 22:32
Binary search algorithm use cases
import random
import timeit
from typing import List, Optional
import unittest
# simple binary search algrothim. requires a sorted list function
def binary_search(sorted_list: List[str], target: str) -> Optional[int]:
left, right = 0, len(sorted_list) - 1
while left <= right:
@alexsc6955
alexsc6955 / tweet.py
Last active January 4, 2022 00:03
Tweet using tweepy
import tweepy
# You can get this credentials from your tweeter developer account
consumer_key = 'xxxxxxxxxxxxxxxxx'
consumer_secret = 'xxxxxxxxxxxxxxxxxxx'
key = 'xxxxxxxxxxxxxx-xxxxxxxxxxxxx'
secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
try:
@alexsc6955
alexsc6955 / replaceBrackets.js
Created October 8, 2021 18:12
Async function to replace words between brackets
/**
* Async function to replace words between brackets
*
* E.g.
* replaceBrackets(
* "Hey, {{ name }}. We just sent your authentication code to {{ email||phoneNumber }}",
* {
* name: "Jhon Doe",
* email: "doe@example.com"
* }
@alexsc6955
alexsc6955 / generateRandomString.js
Last active November 7, 2022 17:10
Generates a random string with a given lenth
/**
* Generate a random string with a given lenth
*
* @author <@thehomelessdev>
* @version 1.0.1
*
* @example
* // returns ten random characters including numbers and special characters
* generateRandomString(10, { includeSpecialCharacters: true })
*
@alexsc6955
alexsc6955 / index.js
Created July 6, 2021 02:25
Parse Html Mail Template with node.js replacing string between brackets.
// Require the module
const { parseMailTemplate } = require("./path/to/parseMailTemplate");
// The params we need to pass
const html = '<html lang="es"><head><meta charset="utf-8"><title>Email Verification</title></head><body><h1>Hey, {{ name }}</h1><p>You have just created an account on <strong>{{ company }}</strong>. Please click the following <a href="{{ link }}" target="_blank">link</a> so you can start using your account.</p></body></html>';
const data = {
name: "Jhon Doe",
company: "My awesome company",
link: "http://example.com,
};
@alexsc6955
alexsc6955 / canvas.js
Created April 27, 2021 14:43
Add a custom font to a HTML canvas using javascript
var canvas = document.querySelector('canvas');
// we need this to load the font
var myFont = new FontFace('myFont', 'url(assets/fonts/myFont/myFont.otf)');
myFont.load().then(function(font){
// with canvas, if this is ommited won't work
document.fonts.add(font);
console.log('Font loaded');
@alexsc6955
alexsc6955 / modal-form.pug
Created March 2, 2020 17:14
modal from pug mixin
mixin modalForm(params)
//- Subscribe Form Moda
.modal.fade(id=params.modalId, tabindex="-1", role="dialog", aria-labelledby=params.modalId, aria-hidden="true")
.modal-dialog.modal-dialog-centered(role="document")
.modal-content
//- Form
form(id=params.form.id, action=params.form.action, method="POST", data-submit=params.form.attrData.submit, data-disable-submition-btn=params.form.attrData.disableSubmitBtn, data-message=params.form.attrData.message)
//- Modal Header
.modal-header
h5.modal-title(id="subscribeFormModalLongTitle") Recibe nuestras notificaciones
@alexsc6955
alexsc6955 / meta.html
Created March 15, 2017 02:04
Meta Tag For Forcing IE 8 to Behave Like IE 7
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
@alexsc6955
alexsc6955 / index.html
Created March 15, 2017 02:00
HTML5 Page structure.
<!DOCTYPE HTML>
<html lang="es" class="no-js">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mi página Web</title>
</head>
@alexsc6955
alexsc6955 / article.html
Created March 15, 2017 01:43
HTML5 article estructure. Example
<article class="post">
<header>
<h1 class="post-title">But Will It Make You Happy?</h1>
<time class="post-updated" datetime="2017-03-14 21:36:03-0400" pubdate>03-14-2017</time>
<p class="post-author">
By <span class="fn">Santiago Rincón</span>
</p>
</header>
<div class="post-content">