Skip to content

Instantly share code, notes, and snippets.

@tyler-vs
tyler-vs / Detect mobile devices script
Created April 2, 2024 15:13 — forked from burners77/Detect mobile devices script
Detect mobile devices script
<script type="text/javascript">
var mobile = (/iphone|ipod|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
do something;
}
</script>
<script type="text/javascript">
var isAndroid = (/android/i.test(navigator.userAgent.toLowerCase()));
if (isAndroid) {
@tyler-vs
tyler-vs / gist:50cad79d13195575e8ab16194a60a8ad
Created January 31, 2024 14:36 — forked from paulirish/gist:5558557
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@tyler-vs
tyler-vs / ajax-contact-form.js
Created January 18, 2024 16:16 — forked from callaginn/ajax-contact-form.js
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}
@tyler-vs
tyler-vs / pubsub.js
Created January 17, 2024 20:04 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@tyler-vs
tyler-vs / reset.css
Created November 17, 2023 16:54 — forked from Asjas/reset.css
Modern CSS Reset - Andy Bell
// https://piccalil.li/blog/a-modern-css-reset
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Remove default margin */
diff --git a/assets/stylesheet.css b/assets/stylesheet.css
index cb0a5ee0..9e691b64 100755
--- a/assets/stylesheet.css
+++ b/assets/stylesheet.css
@@ -4088,6 +4088,7 @@ ul.collection__sidebar-menu li.js-parent-menu.open > .parent_item > a svg {
}
.sidebar-filter.filter--color .filter_swatch label {
+ margin-top: 5px;
margin-bottom: 10px;
@tyler-vs
tyler-vs / app.js
Last active September 29, 2023 18:51 — forked from prof3ssorSt3v3/app.js
const express = require('express');
const app = express();
const port = 3333;
const data = [];
app.post('/analytics', (req, res) => {
data.push(Date.now());
console.log('Request received at:');
console.log(data[data.length - 1]);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dice</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style-traditional.css">
<style type="text/css">
class Pubsub {
constructor() {
this.events = {};
}
subscription (eventName, func) {
return {
subscribe: () => {
if (this.events[eventName]) {
this.events[eventName].push(func);