Skip to content

Instantly share code, notes, and snippets.

View CodeBrotha's full-sized avatar

Tineyi CodeBrotha

  • United States
View GitHub Profile
@gautamk
gautamk / gist:2016111
Created March 11, 2012 11:35
Delete local and remote branches
############ GIT ################
# Delete local branch
git branch -D <branch-name>
# Delete remote branch
git push origin :<branch-name>
@robotmay
robotmay / compare.rb
Created June 26, 2012 13:32
Compare multiple CSV files; specify a pattern to match across the files and it will remove duplicates from the first input file.
#!/usr/bin/env ruby
require 'optparse'
require 'csv'
@options = {
:files => [],
:pattern => /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i,
:columns => [],
:output => nil
}
@rtwomey
rtwomey / Heroku DB Migration.mdown
Created July 23, 2012 18:47
How to migrate a DB on heroku to another plan

Recently, I had a staging database on Heroku that was running on the Ronin database (which was originally the lowest-sized DB you could get at Heroku). Since they added two new options, Crane and Kappa, we wanted to take advantage of the cost savings. Here's how you can migrate your Ronin DB to Crane (or any other plan).

The old database was named BROWN while the new one is CRIMSON. You can determine this by running:

heroku pg:info --app myapp-staging
  1. Add Crane database

     heroku addons:add heroku-postgresql:crane --app myapp-staging
    

heroku pg:wait --app myapp-staging

@arnklint
arnklint / track-form-abandonment.md
Last active December 18, 2017 18:57
Track Form Abandonment in Google Analytics in five rows of javascript

Put this code on the page where the form you want to track resides. Some other examples are currently passed around the web with varying quality. This is one that will work as long as your form tag has an id= or name attribute.

You don´t have to change this code to be able to track form abandonment in your shopping cart, order form or whatever form you want.

This sends events to Google Analytics when a user focuses somewhere not in a field after having focused on a input field. You won´t know for how long users focused on respective fields, or the actual conversion rate in the form using this, but it might be a start.

A tool that provides more insight both over time and per field, is Form Analytics wich helps you optimize your online forms. For instance, it measures dropout rate, average field input length, conversion rate and average time per field. All which provides great insights in the most overlooked, yet important part of you site.

Anyway, here´s the code:

@xero
xero / css-injection.html
Last active October 22, 2021 08:03
css style injection via jQuery. basically calling body/head append with a style tag and your own css will add a new tag and your styles to the bottom of the page/head and override any existing ones. why is this useful? imagine embedding a single js file into the page and defining your own styles (think widget for a client), or loading css via aj…
<!DOCTYPE html>
<html>
<head>
<title>css injection | xero.nu</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style type="text/css">
body{
font: normal 12pt "Times New Roman", serif;
background: #ccc;
color: #000066;
@jwebcat
jwebcat / gist:5122366
Last active March 25, 2024 18:25 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@mynameispj
mynameispj / view.html.erb
Created June 11, 2013 08:26
Rails - each do loop with message if the loop is empty
<% if @project_quantity.each do |quantity| %>
<%= quantity.quantity %>
<% end.empty? %>
0
<% end %>
@olleolleolle
olleolleolle / gist:5933425
Created July 5, 2013 09:49
zsh: noglob option, in action. Rake tasks can take arguments in hard brackets. These brackets have special meaning in zsh. So, either turn off the special expansion stuff (noglob) or escape the brackets.
zsh: Too helpful. Turn off the extra features, so that you can run commands:
$ noglob foreman run -f Procfile.dev rake coupons:seed[1,"One year"]
$ rund rake coupons:seed\[1,"One year"\]
Oh, 'rund' is an alias:
$ alias |grep rund
rund='foreman run -f Procfile.dev'
runt='rund -e .env_test'
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active May 28, 2024 17:41
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active June 7, 2024 23:10
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"