Skip to content

Instantly share code, notes, and snippets.

View ZoeLiao's full-sized avatar

Liao, Jo-Yu (Zoe) ZoeLiao

View GitHub Profile
@ZoeLiao
ZoeLiao / react_google_sigin_siginout.js
Last active July 10, 2020 15:31
react_google_sigin_siginout.js
import React, { Component } from 'react'
import { GoogleLogin, GoogleLogout } from 'react-google-login';
const CLIENT_ID = '<your Client ID>';
class GoogleBtn extends Component {
constructor(props) {
super(props);
{% load i18n %}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
@ZoeLiao
ZoeLiao / django_logging_watchtower.py
Last active November 14, 2019 01:03
Plug your Django application logging directly into AWS CloudWatch by watchtower
import logging
from boto3.session import Session
AWS_ACCESS_KEY_ID = 'your aws key ID'
AWS_SECRET_ACCESS_KEY = 'your aws secret access key'
AWS_REGION_NAME = 'your region name. e.g, us-east-1'
AWS_LOG_GROUP = 'MyLogGroup', # your log group
AWS_LOG_STREAM = 'Mystream', # your stream
AWS_LOGGER_NAME = 'watchtower-logger' # your logger
@ZoeLiao
ZoeLiao / drf_customized_pagination.py
Last active October 27, 2021 00:14
Django REST framework customized pagination
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
DEFAULT_PAGE = 1
DEFAULT_PAGE_SIZE = 10
class CustomPagination(PageNumberPagination):
page = DEFAULT_PAGE
page_size = DEFAULT_PAGE_SIZE
@ZoeLiao
ZoeLiao / ext_isAllowedFileSchemeAccess_demo.js
Last active August 26, 2019 05:39
Chrome - Extension - isAllowedFileSchemeAccess - Demo
const LOCAL_FILE_REGEX_WINDOWS = new RegExp('^([A-Za-z]:[^\<\>\:\"\|\?\*]+)');
const LOCAL_FILE_REGEX_MAC = new RegExp('^(file:\//\/)');
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (!tabs[0]) {
return;
}
let url = tabs[0].url;