Skip to content

Instantly share code, notes, and snippets.

View amoshydra's full-sized avatar
💭
What's happening?!

Amos Wong amoshydra

💭
What's happening?!
  • Singapore
  • 02:40 (UTC +08:00)
View GitHub Profile
@amoshydra
amoshydra / machine.js
Last active May 6, 2021 05:34
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@amoshydra
amoshydra / CssModuleExtension.ts
Created August 6, 2020 10:08
A build module for Nuxt 2 that add support for *.module.css / *.module.scss CSS module files
import type { Module } from '@nuxt/types';
import type * as webpack from 'webpack';
class UnableToExtendError extends Error {
constructor() {
super('Unable to configure for css module');
}
}
const isCssOrScssRule = (rule: webpack.RuleSetRule): boolean | undefined => {
const fs = require('fs');
const glob = require('glob');
module.exports = (options = {}) => {
const collector = {};
const stuffs = glob.sync(options.inputGlob)
.map(filepath => fs.readFileSync(filepath, { encoding: 'utf8' }))
.join('\n')
// Collect then remove import syntax
.replace(/@import url\([^;]+\);/g, (match) => {
@amoshydra
amoshydra / build.js
Last active August 21, 2020 16:51
Example of script for building of multiple components using vue-cli-service
const { performance } = require('perf_hooks');
const consola = require('consola');
const path = require('path');
const glob = require('glob');
const shell = require('shelljs');
const camelCase = require('lodash/camelCase');
const upperFirst = require('lodash/upperFirst');
const fs = require('fs-extra');
const os = require('os');
@amoshydra
amoshydra / CollatePages.js
Created November 23, 2018 02:48
A script to consolidate pdf consisting of a set of even and a set of odd pages into a single correct paginated PDF file
// Complements: Planet PDF (http://www.planetpdf.com/)
// Source: https://forums.adobe.com/thread/286654?start=40&tstart=0
// Modified by
// - Christian Sass for Acrobat XI compatibility
// - Bernd Alheit for newer Acrobat compatibility
// - amoshydra for comsolidating solution
// Add a menu item to reverse all pages in the active document
app.addToolButton({ cName: "Reverse", cLabel: "Reverse", cExec: "PPReversePages();", cEnable: "event.rc = (event.target != null);"});
app.addToolButton({ cName: "Collate", cLabel: "Collate", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);"});
@amoshydra
amoshydra / .eslintrc.js
Last active July 9, 2017 15:08
My favored eslintrc
// http://eslint.org/docs/user-guide/configuring
module.exports = {
'extends': [
'standard',
'plugin:vue/recommended',
],
'plugins': [
'standard'
],
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amoshydra
amoshydra / markdown.css
Created January 6, 2017 12:29
Hackmd Markdown CSS
/* Remove title heading */
h1:first-child {
font-size: 0.5em;
display: none;
page-break-before: avoid;
}
/* Make done task smaller and less significant */
#done-tasks {
opacity: 0.5 !important;
@amoshydra
amoshydra / build_nginx.sh
Created December 11, 2016 05:42 — forked from MattWilcox/build_nginx.sh
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.39
export VERSION_OPENSSL=openssl-1.1.0c
export VERSION_NGINX=nginx-1.10.2
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/