This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Cache } from './cache.decorator'; | |
class Test { | |
seed; | |
constructor(seed?) { | |
this.seed = seed || Math.random(); | |
} | |
@Cache() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'reflect-metadata'; | |
interface Type<T> { | |
new(...args: any[]): T; | |
} | |
export const Injector = new class extends Map { | |
resolve<T>(target: Type<T>): T { | |
let tokens = Reflect.getMetadata('design:paramtypes', target) || []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
parse_path() { | |
if [ / = $PWD ]; then | |
echo "/"; | |
return; | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
if [ -z "$1" ] | |
then | |
echo "Missing destination file parameter." | |
echo "Usage: $0 path/to/dest" | |
echo "Example: $0 /srv/registry/security/htpasswd" | |
exit 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# change all .js files to .ts | |
find . -name '*.js' -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Blockchain() { | |
const blocks = this.blocks = [] | |
const getBlockId = (i) => blocks[i] && blocks[i].id || '00000000' | |
function hash(str) { | |
const hash = Array(8).fill(0); | |
for (let i = 0; i < str.length; i++) | |
hash[i % 8] ^= str.charCodeAt(i) | |
return hash.map((e) => e % 10).join('') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# autocompletion for d and dokcer (docker) | |
source /usr/share/bash-completion/completions/docker | |
complete -F _docker d dokcer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /__special { | |
internal; | |
allow all; | |
root /usr/share/nginx/html/__special; | |
} | |
location = /__md_file { | |
internal; | |
allow all; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g') | |
echo "Version is >${VERSION}<" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net'); | |
const isServer = process.argv[2] == 'server'; | |
const port = process.argv[3]; // server port | |
const display = (data) => console.log('> ' + data.toString().trim()); | |
let send = null; | |
if (isServer) { |