Skip to content

Instantly share code, notes, and snippets.

@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@justintv
justintv / .bashrc
Created August 17, 2009 00:53
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active May 16, 2024 18:51
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

@nkbt
nkbt / .eslintrc.js
Last active May 11, 2024 13:03
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@myronmarston
myronmarston / ways_to_use_vcr.rb
Created April 13, 2012 15:00
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.
@seanharmer
seanharmer / gist:f0fb73170853c5628613ef90ed3b540c
Created December 10, 2020 08:36
Rails font awesome xlink
# app/helpers/application_helper.rb
module ApplicationHelper
def declare_fa_icon(options, anchor_name)
fa_icon(options, data: { 'fa-symbol': anchor_name })
end
def use_fa_icon(anchor_name, text)
%Q(<svg class="icon-fa-xs"><use xlink:href="##{anchor_name}"></use></svg>#{text}).html_safe
end
@yann-yinn
yann-yinn / ApolloQuery.vue
Last active March 21, 2024 09:28
Use "apollo-client" package with Vue.js, without "vue-apollo"
<!--
If you really like to use apolloClient declaratively, here is a naive implementation
of a custom 'ApolloQuery' component
-->
<template>
<div>
<slot name="result" :result="this.result" />
</div>
</template>
@gskema
gskema / color-gradient.js
Last active March 2, 2024 22:14
Generate gradient color from 2 or 3 colors using JavaScript. Example: https://jsfiddle.net/e18g5f3L/
/**
* You may use this function with both 2 or 3 interval colors for your gradient.
* For example, you want to have a gradient between Bootstrap's danger-warning-success colors.
*/
function colorGradient(fadeFraction, rgbColor1, rgbColor2, rgbColor3) {
var color1 = rgbColor1;
var color2 = rgbColor2;
var fade = fadeFraction;
// Do we have 3 colors for the gradient? Need to adjust the params.
@CJBridges
CJBridges / circleci_command_for_cache_optimization.yml
Last active January 22, 2024 18:56
CircleCI does not support checks for existence of a cache key without restoring the full cache. Save a tiny key in parallel with the cache to allow bailing out faster if the cache already exists. More documentation on the approach and the code I started from (thanks TzookB!) is here: https://tzookb.com/circleci-project-deepdive
commands:
halt_if_cache_exists:
description: Halt a build if a cache already exists, without downloading the entire cache. Match only exact key. Pair with mark_cache_existence.
parameters:
category:
description: friendly name of the sort of cache (e.g. bundle, src)
type: string
key:
description: hash key where underlying data would be stored
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE