Skip to content

Instantly share code, notes, and snippets.

@mmuchin
mmuchin / Tiny JavaScript tokenizer.js
Created October 3, 2022 02:51 — forked from borgar/Tiny JavaScript tokenizer.js
A compact tokenizer written in JavaScript.
/*
* Tiny tokenizer
*
* - Accepts a subject string and an object of regular expressions for parsing
* - Returns an array of token objects
*
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid');
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ]
*
*/
@mmuchin
mmuchin / apache2.sh
Created October 5, 2019 16:25 — forked from mikepfeiffer/apache2.sh
EC2 Bootstrap Script for Apache v2
#!/bin/bash
yum update -y
yum install -y httpd
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
echo "<h1>Hello World from $instanceId</h1>" > /var/www/html/index.html
systemctl start httpd
systemctl enable httpd
@mmuchin
mmuchin / stress.sh
Created October 5, 2019 16:25 — forked from mikepfeiffer/stress.sh
Install Stress Utility on Amazon Linux 2
sudo amazon-linux-extras install epel -y
sudo yum install stress -y
@mmuchin
mmuchin / redis_cheatsheet.bash
Created July 25, 2019 12:02 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@mmuchin
mmuchin / api-module.js
Created May 8, 2019 12:48 — forked from d-levin/api-module.js
Reusable Javascript ES6 API module using Axios
import axios from 'axios'
function httpRequest (method, url, request) {
return axios[method](url, request)
.then(response => Promise.resolve(response))
.catch(error => Promise.reject(error))
}
export default {
get (url, request) {
@mmuchin
mmuchin / FTP-UploadDirectory.ps1
Created May 7, 2019 20:41 — forked from dkittell/FTP-UploadDirectory.ps1
PowerShell – FTP Upload Directory With Sub-Directories
clear
# FTP Server Variables
$FTPHost = 'ftp://192.168.1.1/html/'
$FTPUser = 'user'
$FTPPass = 'password'
#Directory where to find pictures to upload
$UploadFolder = "C:\Temp\"
@mmuchin
mmuchin / axios-interceptors-refresh-token.js
Created April 30, 2019 11:48 — forked from INQTR/axios-interceptors-refresh-token.js
Axios interceptors token refresh for few async requests. ES6
import axios from 'axios';
import { settings } from '../settings';
import { authAPI } from '.';
const request = axios.create({
baseURL: settings.api_v1,
});
request.interceptors.request.use(
config => {
@mmuchin
mmuchin / e-commerce.md
Created April 14, 2019 17:41 — forked from hjr3/e-commerce.md
Examples of RESTful API calls for E-commerce platforms

Examples of RESTful API calls for E-commerce platforms

These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.

Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.

Relevant links

// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@mmuchin
mmuchin / bootstrap-4-sass-mixins-cheat-sheet.scss
Created May 29, 2018 12:35 — forked from anschaef/bootstrap-4-sass-mixins-cheat-sheet.scss
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// @author http://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/v4-dev/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;