Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
@products = {
"apples" => 100,
"mele" => 100,
"pommes" => 100,
"bananas" => 150,
"cherries" => 75,
}
@arturoherrero
arturoherrero / disk_space.sh
Created October 11, 2017 15:40
Send an email alert when the disk space gets low
#!/bin/bash
CURRENT=$(df /dev/sda | grep / | awk '{ print $5}' | sed 's/%//')
THRESHOLD=95
if [ "$CURRENT" -ge "$THRESHOLD" ]; then
echo "Subject: Disk space critical: $THRESHOLD% used" | /usr/sbin/sendmail -v your@email.com
fi
@arturoherrero
arturoherrero / osx-for-hackers.sh
Created December 18, 2016 23:28 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx

things I don't know

I took this list from What CS majors should know.

I think it is fun to list things I don't know so I did it =D. I actually found it to be a cool exercise -- maybe I should do a fun graphics project and learn about Open GL!

i wrote this because, while i think the things on this list are potentially worth knowing, and I actually think it's an awesome list of project ideas as well as good food for thought for people developing CS curricula (many of the things I don't know are great exercises!) -- I thought it was really weird to say that every CS student should know all of them. I have a CS degree and I learned very few of the things I do know inside my degree.

I classify "do know" as anything that I have a reasonable grasp of or at least some basic experience with -- the kind of experience I'd expect a CS student to be able to get. If I say I don't know something, it means either I know pretty much nothing about it (for "gr

@arturoherrero
arturoherrero / load_testing.sh
Created April 30, 2016 10:33
Load testing from the command line
for i in {1..1000}; do (curl localhost:4000 &); done
@arturoherrero
arturoherrero / +=.rb
Last active April 25, 2016 15:59
Comparing Array.push, Array.concat and Array.+= Ruby behaviour
a = [1,2,3] # => [1, 2, 3]
b = [4,5] # => [4, 5]
a.object_id # => 70128600052080
a += b # => [1, 2, 3, 4, 5]
[a, b] # => [[1, 2, 3, 4, 5], [4, 5]]
a.object_id # => 70128599818940
@arturoherrero
arturoherrero / gist:d20b072e35cf0f10aacc
Created February 9, 2016 13:00 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@arturoherrero
arturoherrero / deploy_to_heroku.sh
Last active August 29, 2015 14:23
Deploy Rails app to Heroku environments
#!/usr/bin/env bash
deploy_to_production() {
read -p "Are you sure? " -r
if [[ $REPLY =~ ^(yes|y|Y)$ ]]; then
git push production master && heroku run rake db:migrate -a app-production
fi
}
deploy_to_staging() {
@arturoherrero
arturoherrero / gist:136ae94b24482676edc7
Created March 26, 2015 11:49
Rename .css.sass to .sass files
for f in *.css.sass; do
mv "$f" "$(basename "$f" .css.sass).sass"
done
@arturoherrero
arturoherrero / remove.sh
Created December 25, 2014 20:41
Delete files
http://stackoverflow.com/q/11289551/462015
# Delete hundred of thousands of files:
$ rm -f /home/apps/ishows/images/
/bin/rm: cannot execute [Argument list too long]
$ find /home/apps/ishows/images/ -type f | xargs /bin/rm
# Delete files that was last accessed n*24 hours ago, e.g. +5 days