Skip to content

Instantly share code, notes, and snippets.

View averyvery's full-sized avatar

Doug Avery averyvery

View GitHub Profile

Create a shallow clone with the last fifty commits. git clone --depth 50 some-repository

Open the current diff in the editor. git add -e

View ALL branches: git branch -a master

Fetch changes from all remote repositories.

@averyvery
averyvery / application.rb
Last active May 27, 2024 07:35
Inline CSS or JS in Rails
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@averyvery
averyvery / load-view-specific-css.rb
Last active October 30, 2017 14:27
Load view-specific CSS in Rails
def view_css
path = "views/#{params[:controller]}/#{params[:action]}"
stylesheet_link_tag(path) unless Rails.application.assets.find_asset(path).nil?
end
@averyvery
averyvery / distribute.sass
Last active August 29, 2015 14:12
Smooth CSS property distribution with media queries
=distribute($property, $min, $max, $start, $end, $precision, $metric)
#{$property}: $min
// get the range we're operating on
$range: $end - $start
// get the number of iterations we need to run by seeing how precise we should be
$loops: strip-units(ceil($range / $precision)) - 1
@averyvery
averyvery / spread.sass
Last active May 16, 2020 22:07
spread.sass
// strip-units required by spread mixin
// http://stackoverflow.com/questions/12328259/how-do-you-strip-the-unit-from-any-number-in-sass
@function strip-units($number)
@return $number / ($number * 0 + 1)
// pow and sqrt required by ease function
// adapted from https://github.com/at-import/Sassy-math/blob/master/sass/math.scss
@function pow($base, $exponent)
$value: $base
▓█████▄ ▒█████ █ ██ ▄████ ▄▄▄ ██▒ █▓▓█████ ██▀███ ▓██ ██▓
▒██▀ ██▌▒██▒ ██▒ ██ ▓██▒ ██▒ ▀█▒ ▒████▄ ▓██░ █▒▓█ ▀ ▓██ ▒ ██▒▒██ ██▒
░██ █▌▒██░ ██▒▓██ ▒██░▒██░▄▄▄░ ▒██ ▀█▄▓██ █▒░▒███ ▓██ ░▄█ ▒ ▒██ ██░
░▓█▄ ▌▒██ ██░▓▓█ ░██░░▓█ ██▓ ░██▄▄▄▄██▒██ █░░▒▓█ ▄ ▒██▀▀█▄ ░ ▐██▓░
░▒████▓ ░ ████▓▒░▒▒█████▓ ░▒▓███▀▒ ▓█ ▓██▒▒▀█░ ░▒████▒░██▓ ▒██▒ ░ ██▒▓░
▒▒▓ ▒ ░ ▒░▒░▒░ ░▒▓▒ ▒ ▒ ░▒ ▒ ▒▒ ▓▒█░░ ▐░ ░░ ▒░ ░░ ▒▓ ░▒▓░ ██▒▒▒
░ ▒ ▒ ░ ▒ ▒░ ░░▒░ ░ ░ ░ ░ ▒ ▒▒ ░░ ░░ ░ ░ ░ ░▒ ░ ▒░▓██ ░▒░
░ ░ ░ ░ ░ ░ ▒ ░░░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░░ ░ ▒ ▒ ░░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░
module.exports = React.createClass({
getInitialState() {
return {
usingMouse : false,
focusedOnElement : false
}
},
_setUsingMouse(usingMouse) {
this.setState({usingMouse: usingMouse})
@averyvery
averyvery / svg.jsx
Created April 14, 2015 18:42
svg.jsx
// option for inlining (for index)
// option for caching (for SVGs used more than once)
export default React.createClass({
getInitialState() {
return {
svg: ''
}
},
import store from 'data/store'
import browser from 'browser'
import Intro from './Intro'
import LevelEnd from './LevelEnd'
import Questions from './Questions'
import TimeoutTransitionGroup from 'vendor/timeout-transition-group'
export default React.createClass({
_getScreen() {
const level = store.getLevel(this.props.level)
#!/usr/bin/env ruby
# coding: utf-8
require 'pbcopy'
project_data = File.read('projects.csv')
hours_data = File.read('hours.csv')
projects = project_data.split(/\n/)
projects.shift