Skip to content

Instantly share code, notes, and snippets.

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

Samuel Chan samuelchanx

🏠
Working from home
View GitHub Profile
@samuelchanx
samuelchanx / evernote-shortcuts.user.js
Last active March 15, 2017 10:21
Simple script to add shortcuts for Evernote web, can be used with Tempermonkey extension
// ==UserScript==
// @name Evernote Shortcuts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description shows how to use babel compiler
// @author You
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
// @require http://code.jquery.com/jquery-3.1.1.min.js
// @match https://www.evernote.com/Home.action*
@samuelchanx
samuelchanx / script.js
Last active September 26, 2018 07:30
Simple script to download pdf files from canvas, such as `https://canvas.ust.hk/courses/xxxxx/files`
let links = [];
$('.mimeClass-pdf').parents('a').each(function() {
const link = $(this).attr('href');
console.log(`Link: ${link}`);
links.push(link);
});
let currentLink = 0;
@samuelchanx
samuelchanx / gitlab_newrepo.sh
Last active March 24, 2019 20:21
Create a repo on gitlab & set remote for current git directory
#!/bin/bash
echo "What's the name of the repository?"
read repoName
curl --header "PRIVATE-TOKEN: <YOUR PERSONAL PRIVATE TOKEN from Settings/Access Tokens>" -X POST "https://gitlab.com/api/v4/projects?name=$repoName"
echo "\n"
echo "Done. Do you want to add remote for current directory? (Y) / (N)"
read answer
@samuelchanx
samuelchanx / openLinks.js
Created November 13, 2019 16:50
Getting all links in text and open them all at once. For daily twitter task use.
@samuelchanx
samuelchanx / jsonserializable.code-snippets
Created September 23, 2021 08:18
Flutter VSCode snippet - generate json serializable template #vscode
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
"Json Serializable Template": {
"scope": "flutter,dart",
@samuelchanx
samuelchanx / districts.csv
Created September 30, 2021 06:00
Hong Kong Districts data
district_en district_zh sub_district_en sub_district_zh
Hong Kong 香港 ABERDEEN 香港仔
Hong Kong 香港 ADMIRALTY 金鐘
Hong Kong 香港 AP LEI CHAU 鴨脷洲
Hong Kong 香港 CAUSEWAY BAY 銅鑼灣
Hong Kong 香港 CENTRAL 中環
Hong Kong 香港 CHAI WAN 柴灣
Hong Kong 香港 CHUNG HOM KOK 舂坎角
Hong Kong 香港 DEEP WATER BAY 深水灣
Hong Kong 香港 HAPPY VALLEY 跑馬地
@samuelchanx
samuelchanx / helper.dart
Created January 1, 2022 08:34
Missed dart extensions like in kotlin
ReturnType run<ReturnType>(ReturnType Function() operation) {
return operation();
}
extension ScopeFunctionsForObject<T extends Object> on T {
ReturnType let<ReturnType>(ReturnType Function(T item) operationFor) {
return operationFor(this);
}
T also(void Function(T item) operationFor) {
@samuelchanx
samuelchanx / .graphqlrc.yaml
Last active February 20, 2022 04:14
build.yaml for artemis
# To support the GraphQL validation in VSCode
name: "GraphQL API"
schema: "./schema.graphql"
documents: "./graphql/**/*.graphql"
@samuelchanx
samuelchanx / sync.sh
Last active November 8, 2022 15:55
Sync Android Emulator Date Time with your Host Computer #android
# Just run this in your terminal
adb -e shell su root date $(date +%m%d%H%M%Y.%S)
@samuelchanx
samuelchanx / guide.md
Last active October 28, 2022 10:26
Android create a new secret key #android

How to create a new key

mkdir secrets
keytool -genkey -v -keystore ./secrets/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

Android setup

build.gradle update