Skip to content

Instantly share code, notes, and snippets.

View m8r1x's full-sized avatar

Willie M.I.K. m8r1x

View GitHub Profile
@m8r1x
m8r1x / README.md
Created June 22, 2018 04:18
Nodejs Server with vanilla nodejs + typescript

Usage

import Server from "./server";

const PORT = 5000;
const server = new Server();

server.route.register("/", (req, res) => {
 res.end("ok");
@m8r1x
m8r1x / asyncGenerator.js
Created June 17, 2018 07:15
Promises + Generators
function async(generatorFn) {
return function () {
var iterator = generatorFn.apply(this, arguments);
function handle(result) {
if (result.done) return Promise.resolve(result.value);
return Promise.resolve(result.value).then(function (res) {
return handle(iterator.next(res));
}, function (err) {
@m8r1x
m8r1x / .gitignore
Created June 14, 2018 16:48
Node gitignore
## Node
#npm5
package-lock.json
# Logs
logs
*.log
npm-debug.log*
@m8r1x
m8r1x / cache.js
Last active September 28, 2018 10:42
Function Cache and Async function timer
function cacheFn(fn) {
const cache = new Map(); // need .has, .get, .set methods.
return (...args) => {
const cacheKey = JSON.stringify(args.reduce((argsObject, arg, index) => { argsObject[index] = arg; return argsObject }, {}));
if (cache.has(cacheKey)) {
return cache.get(cacheKey);
}
const computed = fn(...args);
cache.set(cacheKey, computed);
return computed;
@m8r1x
m8r1x / git-aliases.md
Last active June 7, 2018 07:14 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@m8r1x
m8r1x / shop.cpp
Created February 11, 2018 09:03
C++ Shop program (Add, Display, Search items in a file)
/*
Copyright 2018 wmik
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@m8r1x
m8r1x / .gitlab-ci.yml
Created December 11, 2017 20:01 — forked from abdullah353/.gitlab-ci.yml
Basic skeleton of Gitlab CI integration with AWS Lambda for auto deployments.
image: docker:latest
before_script:
- apt-get update -y # Updating the Ubuntu Docker instance.
- python -V # Print out python version for debugging.
- apt install -y zip jq
- pip install awscli --upgrade --user
- export PATH=~/.local/bin:$PATH # Required for awscli.
- aws --version # Print out aws cli version for debugging.
@m8r1x
m8r1x / .gitlab-ci.yml
Created October 22, 2017 17:07
Sample gitlab CI file for deploying a `create-react-app` application to firebase.
image: node:6.11.3
cache:
key: cache_yarn
paths:
- .cache_yarn
stages:
- install
- build