Skip to content

Instantly share code, notes, and snippets.

View kenchoong's full-sized avatar
🏠
Working from home

Ken choong kenchoong

🏠
Working from home
View GitHub Profile
@pingwping
pingwping / gist:92219a8a1e9d44e1dd8a
Last active March 6, 2023 18:35
Create and update embedded documents with MongoEngine
# REF: http://www.quora.com/How-do-I-create-and-update-embedded-documents-with-MongoEngine
class Comment(EmbeddedDocument):
content = StringField()
name = StringField(max_length=120)
class Post(Document):
title = StringField(max_length=120, required=True)
author = StringField(required=True)
@melvinbeemer
melvinbeemer / AVPlayer+IsPlaying.swift
Last active January 7, 2023 23:30
Check if AVPlayer is currently playing an item
import Foundation
import AVFoundation
extension AVPlayer {
var isPlaying: Bool {
if (self.rate != 0 && self.error == nil) {
return true
} else {
return false
@MOOOWOOO
MOOOWOOO / py-gitignore
Last active July 24, 2024 05:26
python pycharm gitignore
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@rharter
rharter / SharedPreferenceLiveData.kt
Last active March 19, 2023 08:15
Creates LiveData objects that observe a value in SharedPreferences while they have active listeners.
import android.arch.lifecycle.LiveData
import android.content.SharedPreferences
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
private val preferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == this.key) {
value = getValueFromPreferences(key, defValue)
@shortjared
shortjared / list.txt
Last active July 19, 2024 21:20
List of AWS Service Principals
a4b.amazonaws.com
access-analyzer.amazonaws.com
account.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
airflow-env.amazonaws.com
airflow.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com
@kenchoong
kenchoong / Fcm.php
Created March 9, 2018 19:36
Fcm.php
<?php
/*
* Add FCM Class
*/
class Google_Service_Fcm extends Google_Service
{
/** Set URL for Google Cloud Platform services. */
const CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
const FCM = "https://www.googleapis.com/auth/firebase.messaging";
@baumandm
baumandm / Chakra-UI x React-datepicker.md
Last active May 29, 2024 05:29
Chakra-UI x React-datepicker

⚠️ I'd recommend using this fork by @igoro00 which has better theme support.


Tiny wrapper component for React-Datepicker to stylistically fit with Chakra-UI 1.x.

<DatePicker selectedDate={myDate} onChange={(d) => console.log(d)} />
@hassaku63
hassaku63 / determination-api-stack.ts
Created December 28, 2020 10:25
aws-cdk example - API Gateway V2 HTTP API & lambda NodejsFunction
import * as path from 'path';
import * as cdk from '@aws-cdk/core';
import * as ddb from '@aws-cdk/aws-dynamodb';
import * as apiGatewayV2 from '@aws-cdk/aws-apigatewayv2';
import { LambdaProxyIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
import { NodejsFunction, NodejsFunctionProps } from '@aws-cdk/aws-lambda-nodejs';
import { HttpIntegration, HttpIntegrationType } from '@aws-cdk/aws-apigatewayv2';
import { dirname } from 'path';
const project_root_dir = path.join(dirname(__filename), '../')