Skip to content

Instantly share code, notes, and snippets.

@denmarkin
denmarkin / resque.rake
Created September 20, 2011 11:02
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@ninthspace
ninthspace / gist:4360267
Last active November 9, 2018 12:03
How I migrated from rbenv to chruby, and kept per-project gems nice and tidy.

Remove rbenv and any rubies, gems etc.:

$ rm -rf ~/.rbenv

Uninstall rbenv if installed via Homebrew

$ brew uninstall rbenv

Remove references to rbenv in ~/.bash_profile etc.

@sdball
sdball / sandi_metz_rules_for_developers.md
Created January 18, 2013 18:47
Rules for good development from Sandi Metz

Sandi Metz’ rules for developers

  1. Your class can be no longer than a hundred lines of code.
  2. Your methods can be no longer than five lines of code
  3. You can pass no more than four parameters and you can't just make it one big hash.
  4. In your controller, you can only instantiate one object, to do whatever it is that needs to be done.
  5. Your view can only know about one instance variable.
  6. Your Rails view should only send messages to that object i.e., no Demeter violations.[ "thunder dome principal". Translated: one model in, one model out! ]
  7. Rules are meant to be broken if by breaking them you produce better code. [ ...where "better code" is validated by explaining why you want to break the rule to someone else. ]
@stephenscaff
stephenscaff / fade-title-up-and-down-onscroll.html
Created September 13, 2013 11:51
Fade hero title down + up on scroll with a touch of jquery and CSS keyframes. No keyframe support? Loser. But, no worries, just fade title in and out with animate opacity then.
<!DOCTYPE html>
<head>
<!-- CSS
================================================== -->
<style>
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
@deanapeterson
deanapeterson / staticInclude.js
Created October 23, 2013 20:51
Include a view/template without creation of a new scope. Refined from snippet provided on this stackoverflow entry: http://stackoverflow.com/questions/12393703/how-to-include-one-partials-into-other-without-creating-a-new-scope#answer-17340138. jsFiddle: http://jsfiddle.net/DeanIconWeb/BVXUe/
module.directive('staticInclude', ["$http", "$templateCache", "$compile", "$parse",function($http, $templateCache, $compile, $parse) {
return function(scope, element, attrs) {
var templatePath = $parse(attrs.staticInclude)(scope);
attrs.$observe("staticInclude", function(value){
scope.$watch(value, function(templatePath){
loadTemplate(templatePath);
});
@lrobeson
lrobeson / .bash_profile
Created November 13, 2013 19:36
Git branch bash autocomplete with aliases (optional). Add to .bash_profile.
# To Setup:
# 1) Save the .git-completion.bash file found here:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# 2) Add the following lines to your .bash_profile, be sure to reload (for example: source ~/.bash_profile) for the changes to take effect:
# Git branch bash completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
@glombard
glombard / add-credential.bat
Created May 1, 2014 10:59
Use cmdkey to add a Git credential to the Windows Credential Manager
# to add a new Git credential to the Credential Manager:
cmdkey /generic:LegacyGeneric:target=git:https://github.com /user:username /pass:"mypassword"
# to list all credentials:
cmdkey /list
@sporto
sporto / 1-introduction.md
Last active November 17, 2024 14:52
CanJS: Communication between components

Introduction

The intention of this document is to explore patterns of communication between can components and discuss possible improvements and newer patterns.

We should aim for:

  • Making common scenarios easier
  • Establishing best practices and canonical patterns
  • Having as little surprise as possible, it should be clear from looking at the code exactly what the intention is
  • Aligning with future standards, specifically try to align with web components as much as possible
@haacked
haacked / download-nuget-licenses.ps1
Last active September 5, 2022 16:35
A PowerShell script to download your NuGet package licenses as first seen in http://haacked.com/archive/2015/03/28/download-nuget-package-licenses/
Split-Path -parent $dte.Solution.FileName | cd
New-Item -ItemType Directory -Force -Path ".\licenses"
@( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } ) | Sort -Unique Id | % { $pkg = $_ ; Try { (New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, (Join-Path (pwd) 'licenses\') + $pkg.Id + ".html") } Catch [system.exception] { Write-Host "Could not download license for $($pkg.Id)" } }
@aviaryan
aviaryan / zsh-on-windows.md
Last active February 9, 2024 03:22
Installing zsh and oh-my-zsh on Windows
  1. Install zsh from cygwin
  2. Install oh-my-zsh from https://github.com/robbyrussell/oh-my-zsh . Follow the manual instructions
  3. To make zsh default on ConEmu, create a task with C:\cygwin64\bin\mintty.exe /usr/bin/zsh - . Make it the defaut shell.
  4. To start a zsh shell on demand, add this batch script to your path or start menu or wherever.
start C:\cygwin64\bin\mintty.exe /usr/bin/zsh -