Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / scrollTo.js
Last active November 29, 2023 11:41
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
@james2doyle
james2doyle / rules.txt
Last active November 21, 2023 17:39
Some ublock rules that block elements that match specific pieces of text
! 2022-03-24 https://twitter.com
twitter.*##div[aria-label="Timeline: Trending now"]
twitter.*##div[aria-label="Home timeline"] > div > div article:has(div > div > div > span:has-text(Ad))
! 2022-03-29 https://google.com
google.*##.g:has(a[href*="thetopsites.com"])
google.*##.g:has(*:has-text(/bye topic of noninterest/i))
@james2doyle
james2doyle / tsconfig.json
Created October 16, 2023 17:39
A tsconfig file that works with Volar/Vue Language Tools on Vue 2.x projects
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"sourceMap": true,
"allowJs": true
},
@james2doyle
james2doyle / next.sublime-project
Last active October 6, 2023 20:39
A sublime project file for Next.js React code
{
"folders": [
{
"file_exclude_patterns": [".gitkeep", "*.min.*", "*.snap", "*lock*"],
"folder_exclude_patterns": [
".sanity",
".astro",
".netlify",
".next",
".vercel",
@james2doyle
james2doyle / react.sublime-project
Last active October 6, 2023 20:39
A sublime project file for React code
{
"folders": [
{
"file_exclude_patterns": [
".gitkeep",
"*.min.*",
"*.ts.snap",
"*lock*"
],
"folder_exclude_patterns": [
@james2doyle
james2doyle / typescript.sublime-project
Last active October 6, 2023 20:39
A sublime project file for Typescript code
{
"folders": [
{
"file_exclude_patterns": [
".gitkeep",
"*.min.*",
"*.ts.snap",
"*lock*"
],
"folder_exclude_patterns": [
@james2doyle
james2doyle / nginx-options-request.conf
Created September 26, 2016 16:35
A Nginx conf for handling OPTIONS request for functions like window.fetch
server {
# ...
# handle OPTIONS requests from window.fetch
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS";
add_header Access-Control-Allow-Headers "Authorization,content-type";
add_header Access-Control-Allow-Credentials "true";
@james2doyle
james2doyle / docker.fish
Last active September 29, 2023 13:27
Docker abbreviations for Fish shell
# usage: if read_confirm ...
function read_confirm
while true
read -l -p "Do you want to continue? [y/N] " confirm
switch $confirm
case Y y
return 0
case '' N n
return 1
end
@james2doyle
james2doyle / shopify-vue-app.js
Last active September 18, 2023 10:49
Support Vue apps inside the Shopify section editor. Supports refreshing the Vue instance when changes happen in the section editor
import Vue from 'vue';
/**
* EventHub to listen or broadcast to all components
*
* @see https://shopify.dev/tutorials/develop-theme-sections-integration-with-theme-editor
*
* Usage: eventHub.$on('shopify:section:select:{my-section-name}', (event) => handleSelect());
*
*/
@james2doyle
james2doyle / curl-smtp-email.sh
Last active September 15, 2023 17:21
Send SMTP email using cURL
curl --connect-timeout 15 -v --insecure "smtp://smtp.example.com:25" -u "username:password"
\ --mail-from "sender@example.com" --mail-rcpt "destination@example.com"
\ -T email-contents.txt --ssl