Skip to content

Instantly share code, notes, and snippets.

View perfect-scroll.js
let PerfectScrollbar
const isTouchDevice = "ontouchstart" in document.documentElement
if (!isTouchDevice) {
PerfectScrollbar = require("vue2-perfect-scrollbar")
require("vue2-perfect-scrollbar/dist/vue2-perfect-scrollbar.css")
} else {
PerfectScrollbar = {
install(Vue) {
Vue.component("PerfectScrollbar", {
View axiosCacheAdapter.js
import localForage from "localforage"
import buildURL from "axios/lib/helpers/buildURL"
const forageCache = {
get: async (key) => {
const data = await localForage.getItem(key)
if (!data) return null
const { expire, value } = data
if (expire < Date.now()) {
View UserContentEditor.vue
quill.on("selection-change", function(range, oldRange) {
if (range === null && oldRange !== null) {
//unfocus
save("unfocus")
window.clearInterval(this.autoSaveHandler)
} else if (range !== null && oldRange === null) {
//focus
this.autoSaveHandler = window.setInterval(() => save("autosave"), 5000)
}
})
@pwang2
pwang2 / init.lua
Last active Nov 23, 2020
hammerspoon init file
View init.lua
hs.loadSpoon("Lunette")
spoon.Lunette:bindHotkeys()
hs.alert.show("Config Reloaded")
hs.loadSpoon("ReloadConfiguration")
spoon.ReloadConfiguration:start()
function changeVolume(diff)
return function()
local current = hs.audiodevice.defaultOutputDevice():volume()
View GlobeCanvas.vue
<template>
<canvas ref="globe" />
</template>
<script>
import { presimplify, simplify, feature } from "topojson"
import countryData from "i18n-iso-countries"
import {
select as d3Select,
geoPath,
View Globe.vue
<template>
<div id="globe-canvas"></div>
</template>
<script>
import * as d3 from "d3"
import { geoPath, geoCentroid, geoOrthographic } from "d3-geo"
import { json as d3Json, csv as d3Csv } from "d3-fetch"
import { drag } from "d3-drag"
import { transition as d3Transition } from "d3-transition"
View CsvToAzureTable.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
View Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot -c Release
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
View build-blob-storage.sh
#!/usr/bin/env bash
if [ ! -f package.json ]; then
echo -e "\e[31mPlease run this script from project root(with .git folder)\e[0m"
exit 1
fi
set -exuo pipefail
VERSION=$(jq .version ./package.json)
View .alacritty.yml
# https://github.com/alacritty/alacritty/blob/master/alacritty.yml
background_opacity: .8
live_config_reload: true
shell:
program: /bin/zsh
args:
- --login
You can’t perform that action at this time.