Skip to content

Instantly share code, notes, and snippets.

View niedfelj's full-sized avatar

Joel N niedfelj

View GitHub Profile
@niedfelj
niedfelj / web-fonts-asset-pipeline.md
Created March 5, 2020 13:59 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@niedfelj
niedfelj / PreventGhostClick.js
Created January 10, 2020 17:21 — forked from jtangelder/PreventGhostClick.js
PreventGhostClick
/**
* Prevent click events after a touchend.
*
* Inspired/copy-paste from this article of Google by Ryan Fioravanti
* https://developers.google.com/mobile/articles/fast_buttons#ghost
*
* USAGE:
* Prevent the click event for an certain element
* ````
* PreventGhostClick(myElement);
@niedfelj
niedfelj / shopify_api_retry.rb
Created November 7, 2019 20:51 — forked from sshaw/shopify_api_retry.rb
Ruby module to retry a Shopify API request if an HTTP 429 (too many requests) is returned. Moved to https://github.com/ScreenStaring/shopify_api_retry
require "shopify_api"
#
# Retry a ShopifyAPI request if an HTTP 429 (too many requests) is returned.
#
# ShopifyAPIRetry.retry { customer.update_attribute(:tags, "foo") }
# ShopifyAPIRetry.retry(30) { customer.update_attribute(:tags, "foo") }
# c = ShopifyAPIRetry.retry { ShopifyAPI::Customer.find(id) }
#
# By Skye Shaw (https://gist.github.com/sshaw/6043fa838e1cecf9d902)
@niedfelj
niedfelj / gui-docker.md
Created June 1, 2019 21:51 — forked from rizky/gui-docker.md
Running Graphical applications in Docker for Mac

Setup

Docker for Mac lets you run any Linux executable in an isolated process on Mac. A graphical app is just another process, that needs access to the X11 socket of the system, or an X11 server. You can run X11 applications on a Mac using an open source project called Xquartz. The steps to expose XQuartz to a Linux process running in Docker are simple:

  1. install XQuartz from xquartz.org. Note: you need to install XQuartz version 2.7.10, version 2.7.11 does not work with Docker for Mac. Then you have 3 choices:
  2. Proxy the XQuartz socket to port 6000 or
  3. Tell Xquartz to accept network calls. This is not very secure.
  4. Tell Xquartz to accept network calls and require authentication, setup X11 security using xauth, and mount ~/.Xauthority in the container.
@niedfelj
niedfelj / oneliners.js
Created April 2, 2019 21:07 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// By @coderitual
// https://twitter.com/coderitual/status/1112297299307384833
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.
@niedfelj
niedfelj / bash-path-vars
Created March 14, 2019 18:52 — forked from caruccio/bash-path-vars
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts

Keybase proof

I hereby claim:

  • I am niedfelj on github.
  • I am joeltom (https://keybase.io/joeltom) on keybase.
  • I have a public key ASC6kiH7YMdKBu7isAXVwuQnbMB3OI-fmvN0T4odT7WcYAo

To claim this, I am signing this object:

@niedfelj
niedfelj / watchpack-ignore-node-modules.sh
Created June 30, 2017 14:08 — forked from aripalo/watchpack-ignore-node-modules.sh
Using webpack and its polling watch feature (via watchpack) can drain CPU which is due to watchpack polling all the npm deps within node_modules folder. This is a quick hack/fix until proper fix is merged & available in watchpack.
#!/bin/bash
# Should be used until https://github.com/webpack/watchpack/pull/23 is merged and available in npm
# See https://github.com/webpack/watchpack/issues/2#issuecomment-135204573 for more info
# Ensure we have npm
if ! hash npm 2>/dev/null; then
echo 'No NPM installed!'
exit 1
fi
// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@niedfelj
niedfelj / gist:a6c0e6e3aa8e899c0077a21bac736793
Created May 20, 2017 16:16 — forked from jashmenn/gist:111981
a simple server/client using dnssd (bonjour) and git-style-binaries
#!/usr/bin/env ruby -rubygems
require 'git-style-binary/command'
require 'dnssd'
require 'set'
TestService = Struct.new(:name, :host, :port, :description) unless defined?(TestService)
TcpType = "_dnssdtest._tcp" unless defined?(TcpType)
GitStyleBinary.primary do
version "dnssd-test"