Skip to content

Instantly share code, notes, and snippets.

View jarrad's full-sized avatar

jarrad jarrad

  • NC
View GitHub Profile
@jarrad
jarrad / .bashrc
Created January 17, 2013 15:36
Shell Prompt with current git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}
function cli {
local BLUE="\[\033[0;34m\]"
@jarrad
jarrad / devise.rb
Last active January 1, 2016 15:49
Needed to extend Devise to integrate and authenticate with a legacy app. Stitched this solution together after reading multiple articles and trying various combinations therein.
# config/initializers/devise.rb
require 'devise/models/remote_authenticatable'
require 'remote_auth_strategy'
Devise.setup do |config|
# all the other shenanigans...
config.warden do |manager|
manager.intercept_401 = false
manager.default_strategies(:scope => :user).unshift :remote
@jarrad
jarrad / log.template
Created February 4, 2015 18:24
Eclipse slf4j logger template. Create a Logger for the current class and import the slf4j classes.
${:import(org.slf4j.Logger, org.slf4j.LoggerFactory)}
private static final Logger log = LoggerFactory.getLogger(${enclosing_type}.class);
@jarrad
jarrad / jvmFlags.sh
Created February 11, 2015 14:09
List available JVM flags
java -XX:+PrintFlagsFinal
@jarrad
jarrad / javahog.sh
Created February 11, 2015 14:18
Find the Java Thread that is hogging your CPU
# first find the process using top
top -H
# find the java process
top - 15:32:53 up 1 day, 2:20, 1 user, load average: 1.28, 1.17, 1.18
Tasks: 2355 total, 2 running, 2353 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.4%us, 1.4%sy, 0.0%ni, 66.1%id, 5.7%wa, 0.0%hi, 0.2%si, 0.2%st
Mem: 16332248k total, 9613508k used, 6718740k free, 312148k buffers
Swap: 1048572k total, 0k used, 1048572k free, 1858716k cached
@jarrad
jarrad / lgfiles.sh
Last active August 29, 2015 14:15
find large files from the shell
find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $0 ": " $5 }'
@jarrad
jarrad / devise_skip_confirmation.rb
Last active August 29, 2015 14:16
Skip Devise Confirmation
user = User.find(user_id).skip_confirmation!
user.save!
@jarrad
jarrad / gunsoutsoftware.txt
Created March 11, 2015 01:36
G★O - Guns Out Software ASCII header
__ _____
___ ___ _____ ___ ___ __ __/ /____ ___ / _/ /__ _____ ________
/ _ `/ // / _ \(_-</ _ \/ // / __(_-</ _ \/ _/ __/ |/|/ / _ `/ __/ -_)
\_, /\_,_/_//_/___/\___/\_,_/\__/___/\___/_/ \__/|__,__/\_,_/_/ \__/
/___/
@jarrad
jarrad / install-kafka.txt
Last active July 14, 2024 15:09
Install Kafka on OSX via Homebrew
$> brew cask install java
$> brew install kafka
$> vim ~/bin/kafka
# ~/bin/kafka
#!/bin/bash
zkServer start
kafka-server-start.sh /usr/local/etc/kafka/server.properties
@jarrad
jarrad / fizzBuzz.go
Last active August 28, 2015 19:53
FizzBuzz in golang
package main
import "fmt"
func main() {
for i := 0; i < 100; i++ {
m3 := i % 3 == 0
m5 := i % 5 == 0