Skip to content

Instantly share code, notes, and snippets.

module Enumerable
def dups
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
end
end
# arr = [2,8,8,42,7,33,42]
# puts arr.dups.inspect
# [8, 42]
@daveed
daveed / solr_bash
Last active October 16, 2018 21:58
start and stop solr on a local environment using bash scripting
alias solr_start='cd ~/sunspot-1.1.0/solr/ && java -Xms512M -Xmx1024M -Djetty.port=8982 -Dsolr.data.dir=/home/flashgordon/ruby-dev/sas/solr/data/development -jar start.jar'
# Custom function
function solr_stop() {
pids=$(ps aux | grep -v awk | awk '/java.*-Djetty.port=8982/' |cut -c10-15)
if [ "x${pids}" != "x" ]; then
for pid in $pids; do
kill -9 $pid
echo -e "\033[1;32m[OK] \033[00msolr stopped"
done

How to run your Travis CI Elixir builds locally with Docker

Make sure you have Docker installed.

Pull the Travis Erlang image docker run --name travis-debug -dit travisci/ci-erlang:packer-1494865151 /sbin/init

Execute the container docker exec -it travis-debug -u travis bash -l

@daveed
daveed / .zshrc
Last active May 6, 2019 04:34
zsh config
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
@daveed
daveed / alias-git-remove-untracked.sh
Created October 16, 2018 21:50
Gi remove untracked
alias git-remove-untracked='git fetch --prune && git branch -r | awk "{print \$1}" | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \$1}" | xargs git branch -d'
@daveed
daveed / travis-debug-docker.md
Last active October 18, 2018 00:14
debug travis build locally with Docker
  • get latest docker travis build tag and run it in the background

      docker run -dit travisci/ci-ruby:packer-1494868441 /sbin/init
    
  • exec container

      docker exec -it <container_id> bash -l
    
  • change user

XCode free space
https://medium.com/@nqtuan86/clean-mac-storage-for-xcodes-users-5fbb32239aa5#
~/Library/Caches/com.apple.dt.Xcode
~/Library/Developer/Xcode/DerivedData
~/Library/Developer/Xcode/Archives
~/Library/Developer/Xcode/iOS\ DeviceSupport/
~/Library/Developer/CoreSimulator
xcrun simctl delete unavailable