Skip to content

Instantly share code, notes, and snippets.

View dennmart's full-sized avatar

Dennis Martinez dennmart

View GitHub Profile
@dennmart
dennmart / random_emoji.rb
Last active August 29, 2015 13:56 — forked from hrp/emojibomb.rb
Gets a random emoji from http://www.emoji-cheat-sheet.com/ and copy it to the clipboard (Mac Only).
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open("http://www.emoji-cheat-sheet.com/"))
emoji = doc.css('.name')
IO.popen('pbcopy', 'w') { |f| f << ":#{emoji.to_a.sample.text}:" }
puts "Copied to clipboard!"
@dennmart
dennmart / nginx
Created April 3, 2014 14:50 — forked from hisea/nginx
sudo cp nginx /etc/init.d/
sudo update-rc.d nginx defaults
sudo chmod +x /etc/init.d/nginx
/etc/init.d/nginx start
@dennmart
dennmart / duplicate_stripe_customers.rb
Created September 8, 2014 23:43
Ruby script to find duplicate Stripe customers
require 'stripe'
Stripe.api_key = "YOUR_STRIPE_API_KEY"
duplicate_customers = []
last_customer_id = nil # Cursor for paginating through results
# Stripe can retrieve a maximum of 100 customers in one go, so we need to loop.
loop do
customers = Stripe::Customer.all(limit: 100, starting_after: last_customer_id)
emails = customers.data.each.map { |d| d["email"] }
@dennmart
dennmart / provision.sh
Created November 11, 2014 03:59
Provisioning script for WaniKani to Anki (https://github.com/dennmart/wanikani-to-anki) Vagrantfile
#!/usr/bin/env bash
echo "Updating apt..."
sudo apt-get update -y -qq > /dev/null
echo "Installing required libraries for the app..."
sudo apt-get -y -q install ruby-dev > /dev/null
cd /vagrant
GeoIP C API /Gem Install on Intel Mac
# Download the GeoIP C API.
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
# Uncompress and install GeoIP C API from source.
tar zxvf GeoIP-1.4.6.tar.gz
cd GeoIP-1.4.6
env ARCHFLAGS="-arch i386" ./configure --prefix=/srv/GeoIP
env ARCHFLAGS="-arch i386" make
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
#!/bin/bash
echo "Deleting dennmart.com archive for $(date +%A) if it exists..."
tarsnap --cachedir /usr/local/tarsnap-cache --keyfile /root/tarsnap.key -d -f dennmart.com-daily-$(date +%A)
echo "Creating dennmart.com archive for $(date +%A)..."
tarsnap --cachedir /usr/local/tarsnap-cache --keyfile /root/tarsnap.key -c -f dennmart.com-daily-$(date +%A) /var/www/dennmart.com
echo "Making temporary database dump..."
mysqldump -u root -pxxxxxx --all-databases --add-drop-table > /tmp/mysqldump.sql
echo "Deleting database dump archive for $(date +%A) if it exists..."
We couldn’t find that file to show.
mysql> SELECT * FROM logs LIMIT 1;
+----+--------------+---------------+--------+---------+
| ID | ipaddress | date | user | time |
+----+--------------+---------------+--------+---------+
| 1 | 192.168.1.23 | March 3, 2004 | dennis | 1:28 pm |
+----+--------------+---------------+--------+---------+
1 row in set (0.00 sec)
We couldn’t find that file to show.