Skip to content

Instantly share code, notes, and snippets.

View bensochar's full-sized avatar
🗜️
coding...

Benjamin Sochar bensochar

🗜️
coding...
View GitHub Profile
@bensochar
bensochar / Gradient.js
Created October 25, 2021 14:51 — forked from jordienr/Gradient.js
Stripe Mesh Gradient WebGL
/*
* Stripe WebGl Gradient Animation
* All Credits to Stripe.com
* ScrollObserver functionality to disable animation when not scrolled into view has been disabled and
* commented out for now.
* https://kevinhufnagl.com
*/
@jordienr
jordienr / Gradient.js
Created September 12, 2021 00:23
Stripe Mesh Gradient WebGL
/*
* Stripe WebGl Gradient Animation
* All Credits to Stripe.com
* ScrollObserver functionality to disable animation when not scrolled into view has been disabled and
* commented out for now.
* https://kevinhufnagl.com
*/
@bazzel
bazzel / README.md
Last active July 27, 2024 16:48
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@hopsoft
hopsoft / prefetch.js
Last active December 27, 2023 02:45
Turbolinks Prefetching
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
@ChrisLTD
ChrisLTD / docker-compose.yml
Last active November 14, 2020 00:37
Docker Compose for WordPress with Data Persistence
# Docker Compose for WordPress with Data Persistence
#
# Resources
# https://medium.com/@tatemz/local-wordpress-development-with-docker-3-easy-steps-a7c375366b9
# https://hub.docker.com/_/wordpress/
# https://hub.docker.com/r/_/mariadb/
# https://stackoverflow.com/a/39208187/648844
# https://github.com/nezhar/wordpress-docker-compose
#
version: "2"
@Ch4s3
Ch4s3 / turboLinksPreFetch.js
Last active February 9, 2022 17:26
decaffeinated version of https://gist.github.com/Enalmada/6e11191c1ea81a75a4f266e147569096 with a flag for turning it on or off
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const OldHttpRequest = Turbolinks.HttpRequest;
Turbolinks.CachedHttpRequest = class CachedHttpRequest extends Turbolinks.HttpRequest {
constructor(_, location, referrer) {
super();
@ChrisLTD
ChrisLTD / geolocation-test.js
Last active November 21, 2016 14:55
Pull latitude and longitude from the HTML5 geolocation API with a fallback to Freegeoip. ES6.
'use strict';
const GEOLOCATION_TYPE = {
GEOPOSITION: 'GEOPOSITION',
FREEGEOIP: 'FREEGEOIP'
};
class Localizer {
constructor() {
@taranda
taranda / dynamic-critical-path-css.md
Last active July 7, 2021 19:53
Dynamically Add Critical CSS to Your Rails App

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

@FelixMalfait
FelixMalfait / app.js
Created September 13, 2016 16:01
Front App plugin
var siteUrl = 'https://luckey.herokuapp.com/';
var apiUrl = 'https://luckey.herokuapp.com/api/v1/';
angular
.module('luckey-plugin', ['ngResource', 'ui.router', 'satellizer', 'templates', 'algoliasearch', 'uiGmapgoogle-maps'])
.config(['$stateProvider', '$urlRouterProvider', '$authProvider', function($stateProvider, $urlRouterProvider, $authProvider) {
// Satellizer configuration that specifies which API
// route the JWT should be retrieved from
$authProvider.loginUrl = apiUrl + 'authenticate';

Git Cheat Sheet

Commands

Getting Started

git init

or