Skip to content

Instantly share code, notes, and snippets.

View jweyrich's full-sized avatar
:octocat:
Making some lives easier and happier!

Jardel Weyrich jweyrich

:octocat:
Making some lives easier and happier!
View GitHub Profile
export class cloneable {
public static deepCopy<T>(source: T): T {
return Array.isArray(source)
? source.map(item => this.deepCopy(item))
: source instanceof Date
? new Date(source.getTime())
: source && typeof source === 'object'
? Object.getOwnPropertyNames(source).reduce((o, prop) => {
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop)!);
o[prop] = this.deepCopy((source as { [key: string]: any })[prop]);
@fabidick22
fabidick22 / migrate-ecr.py
Last active January 21, 2025 04:25
Migrate AWS ECR images from one account to another in different regions
"""
MIT License
Copyright (c) 2021 fabidick22
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
@kwilczynski
kwilczynski / filter.go
Created July 24, 2019 14:12
Generic slice filter in Go.
package main
import (
"fmt"
"reflect"
"time"
)
func Filter(slice interface{}, filter interface{}) interface{} {
if slice == nil {
@ryukinix
ryukinix / dateparser_lark.py
Last active February 4, 2022 15:35
An EBNF grammar based in the Lark Parser designed to parse multivariate date formats. (PT_BR)
#!/usr/bin/env python3
# coding: utf-8
#
# Copyright © Neoway Business Solutions
#
# @project: Diário Oficial
# @author: Manoel Vilela
#
"""

Dynamic methods on a TypeScript class

Sometimes, we want to be able to generalize a class that is tailored to some static set of data, but want to do so while preserving type safety. This can be achieved in TypeScript by combining userland enums, private constructors, mapped types, and intersection types.

Individual techniques

Each of the individual techniques above are known TypeScript patterns built on

function email {
instance_profile=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
AWS_ACCESS_KEY=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
AWS_SECRET_KEY=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
TOKEN=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep Token | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
TO="CHANGE@ME"
FROM="CHANGE@ME"
SUBJECT="CHANGE ME"
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 21, 2025 23:44
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@developit
developit / compositional-components-demo.js
Created January 7, 2017 22:44
Demonstrates compositional components in Preact (or React). Live demo: https://jsfiddle.net/developit/umnb4y87/
import { h, cloneElement, Component } from 'preact';
/** Example <Fetch url="/foo.json" /> compositional component.
* Just to demonstrate a compositional component that requires input massaging.
*/
class Fetch extends Component {
state = { loading: true };
componentDidMount() {
this.update();
@developit
developit / views.js
Created October 25, 2016 20:09
preact-views
import { h, cloneElement, Component } from 'preact';
/**
* <Views view="home">
* <Home name="home" />
* <Other name="other" />
* </Views>
*/
class Views extends Component {
state = {
anonymous
anonymous / IRC client in pure bash 4
Created March 28, 2016 16:57
IRC client written in pure bash using only bash builtin commands and no other binaries.
#!/bin/bash
#no PATH, no way to accidently run any programs
PATH=''
#useful variables
term_height=0
term_width=0
term_scroll_height=0
status_line_row=0