Skip to content

Instantly share code, notes, and snippets.

View rediris's full-sized avatar
💭
😸

Roman Edirisinghe rediris

💭
😸
  • United States
View GitHub Profile
@ben-caplan
ben-caplan / styled-select-js
Last active October 24, 2023 18:46
Styled Select JS
//CUSTOM SELECT - prevent double wrap incase this script is include in multiple locations...
$('select').each(function(){
var t = $(this);
if( !t.parent().hasClass('customSelect') ){
t.wrap('<div class="customSelect" />').before('<div class="displayCopy empty"></div>');
}
}).on('change fauxChange', function(){
var t = $(this);
t.siblings('.displayCopy').text( t.find('option:selected').text() );
//toggle "empty" class
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@BenMorel
BenMorel / viewport-units-ios.scss
Last active March 11, 2022 13:15
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.

Intercom user_hash

Remember that your secret key should never be exposed to the public

  • So Javascript code below should only be used for testing unless modified and used to run on a server
@jwilson8767
jwilson8767 / es6-element-ready.js
Last active April 22, 2024 20:28
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
@nmattia
nmattia / netlify-edge.ts
Created December 6, 2023 09:52
Netlify Edge Function for token-based website access (using cookie)
// On first access looks up a search param: `?token=...`
// If the token is valid, saves it in cookies so that
// subsequent requests don't need the search param.
import type { Config, Context } from "@netlify/edge-functions";
// Ideally look up from the environment
const EXPECTED_TOKEN = "very-secret";
const TOKEN_COOKIE_NAME = "my-token";
const TOKEN_HEADER_NAME = "x-my-token";