Skip to content

Instantly share code, notes, and snippets.

View liuliangsir's full-sized avatar
💻
Coding

流浪大法师 liuliangsir

💻
Coding
View GitHub Profile
@fscm
fscm / install_cmake.md
Last active July 1, 2026 21:27
[macOS] Install CMake

[macOS] Install CMake

Instructions on how to install the CMake tool on macOS.

Uninstall

First step should be to unsinstall any previous CMake installation. This step can be skipped if no CMake version was previously installed.

To uninstall any previous CMake installations use the following commands:

@DeoluA
DeoluA / beforeUploadFunc.js
Last active March 22, 2024 12:24
Ant Design - Check the file type, file size and image dimensions before upload
// plugged in this answer from S.O. - https://stackoverflow.com/a/8904008/5172977
// import { Upload } from 'antd';
// function returns a promise
beforeUpload = (file) => {
return new Promise((resolve, reject) => {
// check the file type - you can specify the types you'd like here:
const isImg = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/gif';
if (!isImg) {
@pgmoir
pgmoir / PreviewImage.js
Last active March 9, 2023 09:23
Responsive resize of canvas to match inserted image and plot/tag points that stay in location during resize
import React, { useRef, useEffect } from 'react';
const scaleWidth = 500;
const scaleHeight = 500;
/*
topImage is an object
{
image: String, // name of image
imageUrl: String, // full url of remote hosted image

Phoenix 1.4.x to 1.5.0 upgrade instructions

Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running elixir -v on the command line.

Install the new phx.new project generator

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.5.0
@jakub-g
jakub-g / safari-release-notes-history+stable-technical-preview-mapping.md
Last active April 1, 2026 12:44
Mapping Safari releases to Safari TP versions
@nokidding
nokidding / updateNpm.bat
Created March 31, 2020 13:08
Windows batch file which updates npm for nvm-windows
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1
@tanhauhau
tanhauhau / my-webpack-plugin.js
Created February 20, 2020 00:55
Webpack additional compilation pass
const PLUGIN_NAME = 'MY_WEBPACK_PLUGIN';
class MyWebpackPlugin {
constructor() {
this.cssReady = false;
this.cssFiles = [];
}
apply(compiler) {
compiler.hooks.watchRun.tap(PLUGIN_NAME, () => {
this.cssReady = false;
@silver-xu
silver-xu / ts-boilerplate.md
Last active July 14, 2026 20:25
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@CSTDev
CSTDev / auto-increment-version.sh
Last active June 28, 2025 07:37
Script that will find the last Git Tag and increment it. It will only increment when the latest commit does not already have a tag. By default it increments the patch number, you can tell it to change the major or minor versions by adding #major or #minor to the commit message.
#!/bin/bash
#get highest tag number
VERSION=`git describe --abbrev=0 --tags`
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}
@ChrisDobby
ChrisDobby / canvasDraw.jsx
Last active March 9, 2023 09:23
React component to redraw a canvas when resized
import React from "react";
const scaleWidth = 500;
const scaleHeight = 500;
function draw(canvas, scaleX, scaleY) {
const context = canvas.getContext("2d");
context.scale(scaleX, scaleY);
context.clearRect(0, 0, canvas.clientWidth, canvas.clientHeight);