Skip to content

Instantly share code, notes, and snippets.

View slimlime's full-sized avatar
๐Ÿ˜€
Hello, welcome to Weiber.

slimlime

๐Ÿ˜€
Hello, welcome to Weiber.
  • Australia
View GitHub Profile
@slimlime
slimlime / class_decorator.ts
Created July 9, 2018 08:00 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@slimlime
slimlime / stringify.js
Created July 9, 2018 05:30 — forked from zmmbreeze/stringify.js
json stringify can deal with circular reference
// http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json/11616993#11616993
var o = {};
o.o = o;
var cache = [];
JSON.stringify(o, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
@slimlime
slimlime / arch.js
Created July 1, 2018 23:25 — forked from domenic/arch.js
Mozilla arch JS code
function curveInArchCoords(col, rows, cols) {
const mathX = col / cols * 2 * Math.PI;
const mathY = Math.cos(mathX);
const archY = (1 + mathY) / 2 * rows;
return archY;
}
function setFrame(frame, rows, cols, colOffset) {
for (const i of frame) {
frame[i] = 0;
@slimlime
slimlime / promises.md
Created July 1, 2018 23:24 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
// When one has to conform to using Regex, ameliorate the nasties and qualify/quantify as many identifiers as you can :boom: :tada:
// E.g. Self-documenting version of an unmaintainable Regex string
// 1. Break it up into readable functions/vars with doc comments
// 2. Build up the parts back into the final result
// Win. :lion: :gem:
@slimlime
slimlime / README.md
Last active July 1, 2018 14:41
[vs-code] Get recommended list of extensions installed extensions

Get recommended list of extensions installed extensions

@slimlime
slimlime / convert-each-output-for-json-string-array.sh
Created July 1, 2018 05:41
Redirect | and wrap output with a prefix/suffix script example.
# /*
# * @Author: slimlime
# * @Date: 2018-07-01 15:23:12
# * @Last Modified by: slimlime
# * @Last Modified time: 2018-07-01 15:23:12
# */
# ^^Should probably revamp some of these auto-generator extensions^^.
# // Convenience utility to wrap a string in prefix suffix. e.g. "string", to populate a string[] for my JSON settings.
ls | sed 's/.*/"&",/'
@slimlime
slimlime / steam_quick_queue.user.js
Created July 1, 2018 05:15 — forked from xPaw/steam_quick_queue.user.js
Discover the Steam queue three times to get the sale cards
// ==UserScript==
// @name Steam Queue Auto Discoverer
// @description Discover the Steam queue three times to get the sale cards
// @version 2.3.0
// @namespace https://gist.github.com/xPaw/73f8ae2031b4e528abf7
// @updateURL https://gist.github.com/xPaw/73f8ae2031b4e528abf7/raw/steam_quick_queue.user.js
// @icon https://store.steampowered.com/favicon.ico
// @match https://store.steampowered.com/explore*
// @grant none
// ==/UserScript==
/*
* @Author : SLim
* @Date : 2018-06-30 13: 58: 47
* @Last Modified time: 2018-06-30 15: 04: 36
*/
// Limited-use, specific problem.
// Showcases a workaround to cast namespace/module definition onto an "any" typed module (because using JavaScript node module require)
// For autocompletion usage, typing to speed up development.
@slimlime
slimlime / Bash Prompt with Git and Emoji
Created June 30, 2018 00:19 — forked from jstuckey/Bash Prompt with Git and Emoji
Bash Prompt with Git and Emoji - Add to ~/.bash_profile
git_branch='`git rev-parse --abbrev-ref HEAD 2> /dev/null | sed s/^/\ \|\ /`'
emojis=(๐Ÿถ ๐Ÿบ ๐Ÿฑ ๐Ÿญ ๐Ÿน ๐Ÿฐ ๐Ÿธ ๐Ÿฏ ๐Ÿจ ๐Ÿป ๐Ÿท ๐Ÿฎ ๐Ÿต ๐Ÿผ ๐Ÿง ๐Ÿ ๐Ÿข ๐Ÿ™ ๐Ÿ  ๐Ÿณ ๐Ÿฌ ๐Ÿฅ)
emoji='`echo ${emojis[$RANDOM % 22]}`'
PS1="\[\033[0;36m\]\T | \W$git_branch | $emoji > \[\e[0m\]"