Skip to content

Instantly share code, notes, and snippets.

View alexsasharegan's full-sized avatar

Alex Regan alexsasharegan

View GitHub Profile
@alexsasharegan
alexsasharegan / pattern-matching.ts
Created August 15, 2018 20:08
A guide to pseudo pattern matching in TypeScript.
/**
* Step 1:
* Create a string enum. This can be done with a TS enum type,
* or a sum type (union of strings).
*/
// enum style
enum TokenType {
Text = "Text",
UserMention = "UserMention",
#!/usr/bin/env bash
dlurl=https://dl.pstmn.io/download/latest/linux64
wget $dlurl -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman
sudo cat > /usr/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@alexsasharegan
alexsasharegan / aliases.sh
Created June 13, 2018 23:37
Mac to Linux aliases
alias pbcopy="xclip -sel clip"
alias pbpaste='xsel --clipboard --output'
import { shallowCopy, deepCopy } from "@/core/object";
import { ucFirst } from "@/core/string";
/**
* Returns a dynamic mixin that will shallow clone the desired prop.
* Adds a mutable data attribute with the given alias (`${prop}Copy`),
* a reset method to reset value to the actual prop's value
* (`reset${prop}Copy` or `reset${customAlias}`), and handles watching
* the prop for updates.
*/
const { spawn } = require("child_process");
function stream_cmd(cmd, args, { stdout, stderr, close, error }, options = {}) {
const proc = spawn(cmd, args, options);
if (stdout) {
proc.stdout.on("data", stdout);
}
if (stderr) {
proc.stderr.on("data", stderr);
javascript:!function(a,b){for(const c of b)a.querySelectorAll(c).forEach(d=>{d.parentElement&&d.parentElement.removeChild(d)})}(document,["iframe","video","ins","#carbonads"]);

Keybase proof

I hereby claim:

  • I am alexsasharegan on github.
  • I am alexsasharegan (https://keybase.io/alexsasharegan) on keybase.
  • I have a public key ASCIRCofm80VvfC_DUjdxZ2Pz2G0ZMvaz3WzVbEjFgP0eQo

To claim this, I am signing this object:

<?php
function fprint($wx, ...$lns)
{
foreach ($lns as $ln) {
fwrite($wx, $ln . PHP_EOL);
}
}
function print_table($wx, array $keys, ...$data)
<template>
<b-card>
<header slot="header">
<h3 class="m-0">
<i class="fa fa-fw fa-area-chart" /> HD Orders:
<span class="font-weight-normal">
<slot name="title"></slot>
</span>
</h3>
@alexsasharegan
alexsasharegan / typescript.json
Created April 3, 2018 21:00
Typescript snippets
{
"async function": {
"prefix": "afunc",
"body": [
"async function ${1:name}($2) {",
"\t$3",
"}"
]
},
"arrow function": {