Skip to content

Instantly share code, notes, and snippets.

View lijunle's full-sized avatar

Junle Li lijunle

View GitHub Profile
@lijunle
lijunle / media-renames.mjs
Last active May 6, 2024 09:08
Rename DJI and iOS video files to normalized format.
import fs from 'node:fs';
import path from "node:path";
import process from "node:process";
import url from "node:url";
if (!process.argv[2]) {
console.error(`Usage: node ${process.argv[1]} <media-folder> [shift-hours]`);
process.exit(-1);
}
@lijunle
lijunle / bright-horizons-photo.mjs
Last active March 14, 2023 08:38
Download Photos from Bright Horizons
/* Download Bright Horizons Photos */
import fs from "node:fs";
import https from "node:https";
import path from "node:path";
import process from "node:process";
import url from "node:url";
import util from "node:util";
if (!process.argv[2]) {
@lijunle
lijunle / index.html
Last active November 12, 2022 06:46
Enable open graph metadata for PiGallery2
<html>
<head>
<script src="open-graph-metadata.js"></script>
</head>
<body>Index file.</body>
</html>
@lijunle
lijunle / ping-google.sh
Last active August 29, 2019 16:28
Performance to ping Google
#!/bin/sh
IKEY='<Instrumentation-Key-Here>'
while true
do
TIME=$(date +%Y-%m-%dT%H:%M:%S%z)
PING_OUTPUT=$(ping -q -c 1 -w 3 www.google.com)
PING_RESULT=$?
DELAY=$(echo $PING_OUTPUT | sed -r -n 's/^.+ rtt .+ = (.+) ms$/\1/p' | cut -d '/' -f 1)
@lijunle
lijunle / useStatePromise.ts
Created May 7, 2019 06:17
React Hook to set promise as a state
function useStatePromise<S>(initialValue: S): [S, (promise: Promise<S>) => Promise<void>] {
const [state, setState] = React.useState<S>(initialValue);
const asyncCount: React.MutableRefObject<number> = React.useRef(0);
async function setStatePromise(nextValuePromise: Promise<S>): Promise<void> {
const currCount: number = ++asyncCount.current;
const nextValue: S = await nextValuePromise;
if (currCount === asyncCount.current) {
setState(nextValue);
}
@lijunle
lijunle / README.md
Created January 8, 2019 19:58
Minimal Visual Studio Support on .Net Core

Minimal Visual Studio Support on .Net Core

  1. Install .Net Compiler Platform SDK (with 3 more related)
  2. Install NuGet targets and build tasks
  3. Install the standalone .Net Core SDK.
  4. Set environment variable MSBuildSDKsPath=C:\Program Files\dotnet\sdk\2.2.101\Sdks
  5. Update CSPROJ to include ToolsVersion="15.0" as workaround.
@lijunle
lijunle / Dockerfile
Last active December 22, 2018 15:54
container-insights
#
# container-insights
#
# Send the docker container status to Azure Application Insight on every minute.
#
# Run it:
# docker run -d --privileged --restart always \
# -v /var/run/docker.sock:/var/run/docker.sock \
# -e IKEY=12345678-1234-1234-1234-1234567890xx \
# -e PREFIX=docker-01 \
@lijunle
lijunle / generator-yield.ts
Last active November 6, 2017 06:49
Generator/yield introduction
import performanceNow = require('performance-now');
console.log();
console.log('# What is yield?');
console.log();
console.log();
console.log('## Return Array');
console.log();
/** @file App.tsx */
class App extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
mount: true
};
}
@lijunle
lijunle / SassMeister-input.scss
Created October 14, 2016 07:03
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$ms-screen-lg-min: 100px;
$ms-screen-xl-min: 500px;
@mixin ms-u-lg2 {
@media (min-width: $ms-screen-lg-min) {