Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
import { Controller } from "stimulus";
import { get } from "@rails/request.js";
import { PageSnapshot } from "@hotwired/turbo";
export default class extends Controller {
static values = { hoverTime: Number };
connect() {
this.element.addEventListener("mouseover", this.prefetch.bind(this));
this.element.addEventListener("touchstart", this.prefetch.bind(this));
}
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 10, 2024 20:23
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@raybrownco
raybrownco / image_helpers.rb
Last active July 10, 2021 13:37
Inline SVG in Middleman
# Middleman - Inline SVG Helper
# ------------------------------------------------------------------------------
#
# Installation
# ------------
# 1. Save this file at `[project_root]/helpers/image_helpers.rb`
# 2. Open the project's Gemfile and add this line: `gem "oga"`
# 3. Run `bundle install` from the command line
#
# Note: Restart your local Middleman server (if it's running) before continuing
@clarkware
clarkware / lyrics.rb
Created September 10, 2012 20:05
Random Lyrics
#!/usr/bin/env ruby
# API Documentation at http://api.wikia.com/wiki/LyricWiki_API
require 'open-uri'
require 'json'
require 'tmpdir'
ARTIST = "Johnny Cash"
@czj
czj / gist:1263872
Created October 5, 2011 07:39
Script to encode with HandbrakeCLI (x264) 720p, high image quality, low file size
#!/usr/bin/env ruby
# encoding: utf-8
# x264 presets guide : https://forum.handbrake.fr/viewtopic.php?f=6&t=19426
X264 = "b-adapt=2:rc-lookahead=50:me=umh:bframes=5:ref=6:direct=auto:trellis=2:subq=10:psy-rd=1.0,0.10:analyse=all"
FORMAT = "--optimize --format mp4"
QUALITY = "--ab 64 --mixdown mono --quality 23 -e x264 -x '#{X264}'"
SIZE = "--width 1280 --height 720"
ARGV.each do |param|
@czj
czj / hosts
Created October 4, 2011 08:24
Hosts file for ads removal
127.0.0.1 da.feedportal.com
127.0.0.1 rss.feedportal.com
127.0.0.1 com.clubic.feedsportal.com
@czj
czj / gist:1261139
Created October 4, 2011 08:20
CSS filtering for Google Reader (remove ads & useless links)
/*
http://www.google.fr/reader/*
*/
a[href*=feedburner],
a[href*=feedsportal],
img[src*=feedsportal] {
display:none !important;
}
@czj
czj / gist:1251040
Created September 29, 2011 15:45
Custom .pryrc for OSX + Rails + polite
# This script is greatly inspired by Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# Use TextMate as default editor
Pry.config.editor = "mate -w"
# My pry is polite
Pry.hooks = {
:after_session => proc {
puts "\nGoodbye." if Pry.active_sessions == 1
@czj
czj / gist:1251031
Created September 29, 2011 15:43
.irbrc that runs Pry instead of IRB
# This script comes from Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
@czj
czj / sabnzdb_upgrade.sh
Created September 27, 2011 09:40
SABnzdb+ auto-update script
#!/bin/bash
cd ~/bin
API_KEY=`cat SABnzbd/sabnzbd.ini | grep ^api_key | awk '{print $3}'`
PORT=` cat SABnzbd/sabnzbd.ini | grep ^https_port | awk '{print $3}'`
VERSION=`curl -s http://sabnzbdplus.sourceforge.net/version/latest | head -n1`
VERSION=${VERSION%?}
DIR="SABnzbd-${VERSION}"
GZ="${DIR}-src.tar.gz"