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 28, 2026 03:18
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

@joshschmelzle
joshschmelzle / remove-gamebar-powershell-win10.md
Last active April 7, 2026 00:39
How to Remove the Xbox Game Bar with Powershell on Windows 10. Scroll to the end of the gist for Windows 11.

You've probably stumbled upon this researching how to remove the Xbox Game Bar. This gist includes a few different methods you can try. Please note that some of these first options are probably not be available unless you are running an older version of Windows 10.

EDIT: make sure to check out the comment below from @nmhung1985 which seems to be working for most folks.

Uninstalling/Removing the Game Bar (old Windows 10 build GUI options)

(this is no longer an option on any recent Windows 10 build)

  1. Press Windows Key or click on the Start menu.
  2. Start typing Xbox or Game Bar, until you get the Xbox Game Bar app to appear in the results.
@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 = {