Skip to content

Instantly share code, notes, and snippets.

View harryhan24's full-sized avatar

harry han harryhan24

View GitHub Profile
@harryhan24
harryhan24 / rxjs-operators.ts
Created July 7, 2022 10:25 — forked from drewwiens/rxjs-operators.ts
Some handy custom RxJS operators for Angular etc
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
import { map, toPairs, fromPairs, differenceWith, isEqual, isNull, isUndefined } from 'lodash';
import { Observable, OperatorFunction, defer, empty, of, merge, pipe } from 'rxjs';
import { distinctUntilChanged, filter, map, shareReplay, pairwise } from 'rxjs/operators';
/**
* Convenience RxJS operator that filters out undefined & null and modifies the downstream type
* appropriately.
*/
export function exists<T>(): OperatorFunction<T | undefined | null, T> {
import {
DynamoDBClient,
PutItemCommand,
GetItemCommand,
UpdateItemCommand,
DeleteItemCommand,
} from '@aws-sdk/client-dynamodb';
import {
marshall,
unmarshall
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
import { DynamoDB, PutItemInput } from '@aws-sdk/client-dynamodb'
import { marshall } from '@aws-sdk/util-dynamodb'
import { v4 as uuid } from 'uuid'
interface TodoInput {
id?: string
title: string
done: boolean
}
@harryhan24
harryhan24 / server-status-widget.js
Created April 1, 2022 04:10 — forked from dioncodes/server-status-widget.js
Scriptable iOS Server Status Widget
const initialData = {
servers: [
{
url: 'https://1.example.com/',
title: 'Server 1',
online: null,
},
{
url: 'https://2.example.com/',
title: 'Server 2',
@harryhan24
harryhan24 / flutter.md
Created January 25, 2022 16:50 — forked from matteocrippa/flutter.md
Flutter Cheatsheet

Flutter

A quick cheatsheet of useful snippet for Flutter

Widget

A widget is the basic type of controller in Flutter Material. There are two type of basic Widget we can extend our classes: StatefulWidget or StatelessWidget.

Stateful

StatefulWidget are all the widget that interally have a dynamic value that can change during usage. It can receive an input value in the constructor or reference to functions. You need to create two classes like:

@harryhan24
harryhan24 / get_access_token.js
Created January 16, 2022 13:12 — forked from ejdoh1/get_access_token.js
How to get an access_token from AWS Cognito using Axios
// Get AWS Congito access token using node-fetch and axios
const axios = require('axios');
const fetch = require('node-fetch');
const url = 'https://REPLACE_ME.auth.ap-southeast-2.amazoncognito.com/oauth2/token';
const clientId = 'REPLACE_ME';
const clientSecret = 'REPLACE_ME';
const body = `client_id=${clientId}&client_secret=${clientSecret}&grant_type=client_credentials`
// with node-fetch
@harryhan24
harryhan24 / DockerUserNamespacesOnCentOS74.md
Created June 29, 2020 03:10 — forked from mjuric/DockerUserNamespacesOnCentOS74.md
Setting up Docker with user namespaces on CentOS 7.4

Setting up Docker with user namespaces on CentOS 7.4

The procedure below has been tested on a Digital Ocean VM with CentOS 7.4

# Install docker from RHEL’s standard repos
yum install -y docker

#
# We’ll activate the ‘user namespaces’ feature that defends against
@harryhan24
harryhan24 / .xvimrc
Created January 16, 2020 18:12 — forked from popeyelau/.xvimrc
.xvimrc
" VIM SETTINGS <(
" 搜索忽略大小写
set ignorecase
" 高亮搜索
set hlsearch
" 显示行号和列号
set ruler
" 不显示状态行
" set laststatus=0
@harryhan24
harryhan24 / lima-agnoster.zsh-theme
Created January 12, 2020 18:22 — forked from brunodles/lima-agnoster.zsh-theme
A simple change on agnoster theme. This will add the time of the last command on the right size.
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@harryhan24
harryhan24 / AndroidManifest.xml
Created December 27, 2019 07:28 — forked from AndSky90/AndroidManifest.xml
Firebase push handling
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="...">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="..."