View code.gs
// this is a google script method of getting a client key from stripe | |
// this means you don't have to get a server to take stripe payments because | |
// this can be your server. at the time of this script creation, you are | |
// limited to 20k per month. in order to 'deploy' this you'll have to | |
// go to https://script.google.com/ and create a new script, replace the | |
// body of the initial script file with this and then deploy it as a web app | |
// you'll have to give it the required permissions it asks for the first time | |
// and ensure you set it up for anonymous access. | |
// this function will just return the secret key for the client from stripe |
View JSZip.js
//import or add cdn for global, url should be passed in somehow | |
fetch(url) | |
.then(r=>r.blob()) | |
.then(JSZip.loadAsync) | |
.then(zip=>zip.files[Object.keys(zip.files)[0]].async('string')) | |
.then(JSON.parse) |
View downloadjsonascsv.js
//bind onclick to downloadcsv. | |
//o should be the json you want to turn into a table | |
//h should be a string array for the header row, or this can be null and it will use the keys from the first record | |
//n is the name of the file, csv will be appended. if omitted it will just be 'data.csv' | |
export const downloadcsv = (o,h,n = 'data') => { | |
downloadFile( toCSV(o,h) , n + '.csv', 'text/csv' ); | |
} | |
const toCSV = (o,h) => { | |
const a = (v) => `"${v.join(`","`)}"` | |
let csv = [] |
View Animation.js
//comments in blogpost | |
myoptions.events = [] | |
myoptions.animation = { | |
duration: 0, | |
onComplete: function () { | |
let chartInstance = this.chart | |
let ctx = chartInstance.chart.ctx | |
ctx.textAlign = 'center' | |
function formatLabel(value) { |
View GenericHTMLTagWrapper.js
// this simply generates helper html wrappers | |
// whatever tags you want helpers for can be listed in the htmlhelpers array | |
const htmlhelpers = ['h4','table','thead','tbody','tr','td','th','div']; | |
// this function generates other functions based on the tag that is passed into it | |
// also any extra attributes or other properties can be added as an argument | |
const tagwrapper = (tag,txt,att='')=>`<${tag}${att.length===0?'':' ' + att}>${txt}</${tag}>`; | |
// loop through the tags we want wrapper functions for, and generate eval statements | |
for(const s of htmlhelpers){eval(`var ${s} = (txt,att='')=>tagwrapper('${s}',txt,att);`)} | |
// the output of this will be functions that allow you to write something like: | |
// h4('hello world') |
View GenerateSql.ps1
# this is actually just output from running in powershell, | |
# but I'll just add my comments in here along with the output | |
## First of all, I am going to set an alias to the compiled exe | |
└[C:\git\h]> set-alias h "C:\git\h\bin\Release\netcoreapp3.1\win-x64\h.exe" | |
## Generate a users file, I'm using a tab here because if you | |
## select this from a database query window, it'll be tab seperated | |
## `t is a tab character in powershell | |
## This first line puts a header row in there |
View FileCreationInformation.ps1
function Copy-File-SPO( | |
$user, #username | |
$pass, #password | |
$site, #sp site url | |
$list, #sp list name | |
$dest, #dest path in list | |
$path #path for gci | |
){ | |
# check for and load dependency dlls |
View convertUserAgentStringToSimpleName.ps1
# in the example,they use numbers for the keys, but state they can be other things. | |
# i just left them as numbers to match their setup. i'm guessing you could use | |
# (new-guid).guid instead and avoid the ln var all together if that's your thing. | |
# note that i am not using the 'count' value from up above for this as it's not needed | |
# i just wanted that to look at when i was originally examining the $agentinfo results | |
# i usually don't end powershell lines in semicolons, but i actually ran this as a | |
# oneliner and spread it out here for readability. | |
$ln=1; | |
$hash=[ordered]@{}; | |
$agentinfo | %{ $hash.add("$ln",$_.Name);$ln++}; |
View FixLagSameDayLastMonth.sql
/* don't lock, be deadlock victim if needed */ | |
set transaction isolation level read uncommitted | |
set deadlock_priority -10 | |
/* generate sales data */ | |
declare @SalesByDay as table ( | |
[SalesDate] datetime not null primary key | |
, [TotalSales] decimal(19,2) not null | |
) | |
declare @mindate date = '20200101', @maxdate date = '20200630' |
View BootswatchThemeSwitcher.js
// I switched a basic bootstrap template site over to using bootswatch, | |
// but I wanted to swap the themes on it so i could see some of the colors and | |
// font sizes as i still had some items from the old theme in there. | |
// There are probably lots of ways to do this, but this is how I did it | |
// Go to https://www.bootstrapcdn.com/bootswatch and then you can run this on the | |
// page with all of the cdn links to copy and use with hashes, etc | |
//var vals = [...document.querySelectorAll('input[id*="html_"]')].map(x => [x.id.replace('html_', ''), x.value]).reduce( | |
// (acc, val) => (acc[val[0]] = val[1], acc), {} | |
//); |
NewerOlder