Skip to content

Instantly share code, notes, and snippets.

Ethan Liew ethanliew

View GitHub Profile
ethanliew / Mac OS X: Open in Visual Studio Code
Last active Jul 16, 2020 — forked from tonysneed/Mac OS X: Open in Visual Studio Code
Add a command to Finder services in Mac OSX to open a folder in VS Code
View Mac OS X: Open in Visual Studio Code
- Open Automator
- File -> New -> Quick Action
- Change "Workflow Receives current" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "" --args "$*"
- Save it as something like "Open in VSCode"
ethanliew / convert id_rsa to pem
Created Jun 24, 2020 — forked from mingfang/convert id_rsa to pem
Convert id_rsa to pem file
View convert id_rsa to pem
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 600 id_rsa.pem
### Google Domains provides an API to update a DNS "Syntheitc record". This script
### updates a record with the script-runner's public IP, as resolved using a DNS
### lookup.
### Google Dynamic DNS:
### Synthetic Records:
ethanliew /
Created Feb 11, 2020 — forked from bertrandmartel/
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
ethanliew / beerSchema.js
Created Dec 12, 2019 — forked from suissa/beerSchema.js
Creating models dynamically
View beerSchema.js
var mongoose = require('mongoose');
var BeerSchema = new mongoose.Schema({
id: { type: Number, min: 0},
name: { type: String, default: '' },
description: { type: String, default: '' },
abv: { type: Number, min: 0},
category: { type: String, default: ''},
created_at: { type: Date, default: },
updated_at: { type: Date, default: }
ethanliew / axios-catch-error.js
Created Dec 6, 2019 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
View axios-catch-error.js
* Handling Errors using async/await
* Has to be used inside an async function
try {
const response = await axios.get('');
// Success 🎉
} catch (error) {
// Error 😨
ethanliew / main.dart
Created Sep 23, 2019 — forked from branflake2267/main.dart
Flutter - Display the SnackBar using the GlobalKey
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
View recaptcha-final-angular.directive.ts
import { AfterViewInit, Directive, ElementRef, EventEmitter, forwardRef, Inject, Injectable, InjectionToken, Injector, Input, NgZone, OnInit, Output } from '@angular/core';
import { AbstractControl, ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR, NgControl, Validators } from '@angular/forms';
import { Http } from '@angular/http';
declare const grecaptcha : any;
declare global {
interface Window {
grecaptcha : any;
reCaptchaLoad : () => void
ethanliew / Post.php
Created Jul 20, 2019 — forked from fredyounan/Post.php
Eloquent boot method
View Post.php
class Post extends Eloquent {
* This is a useful switch to temporarily turn of automatic model validation.
public static $autoValidate = true;
* The rules to use for the model validation.
* Define your validation rules here.
ethanliew / hosts
Created Jun 24, 2019 — forked from consti/hosts
/etc/hosts to block shock sites etc.
View hosts
# This hosts file is brought to you by Dan Pollock and can be found at
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#<localhost> localhost localhost.localdomain broadcasthost
::1 localhost
You can’t perform that action at this time.