This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2012 Google Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "nkf" | |
require 'google/apis/gmail_v1' | |
require 'googleauth' | |
require 'googleauth/stores/file_token_store' | |
require 'rmail' | |
require 'fileutils' | |
class GmailMailer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailedZipFileExtractor | |
# This class downloads an email from gmail and extracts a file out of a .zip attachment | |
require 'google/apis/gmail_v1' | |
require 'googleauth' | |
require 'zip' | |
# These credentials come from creating an OAuth Web Application client ID | |
# in the Google developer console | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/https" | |
require "uri" | |
crt = File.read("client-2048.crt") | |
key = File.read("client-2048.key") | |
app_key = "YOUR_APP_KEY" | |
username = "YOUR_USERNAME" | |
password = "YOUR_PASSWORD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'openssl' | |
def test_connection(ip_address, uri, delays) | |
Net::HTTP.start(ip_address, uri.port, | |
use_ssl: true, | |
verify_mode: OpenSSL::SSL::VERIFY_NONE, | |
keep_alive_timeout: 50 | |
) do |http| | |
while true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export data from Microsoft Access .mdb database into .csv files | |
# using https://github.com/brianb/mdbtools | |
# Install with homebrew - "brew install mdbtools" | |
class ConverterScript | |
tables = `mdb-tables -d , your_db_name.mdb`.chop.split(",") | |
tables.each do |table| | |
exists = system("mdb-export your_db_name.mdb '#{table}'") | |
`mdb-export your_db_name.mdb '#{table}' > #{table.gsub(" ", "_")}.csv` if exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(httr) | |
setwd("C:/Dropbox/Projects/20160206_Soccer_Scores") | |
if (!file.exists("20160206_Soccer_Scores.csv.gz")) { | |
cat("must reread") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer < ActiveRecord::Base | |
after_create :send_welcome_email, unless: :auto_registered? | |
has_one :auto_created, dependent: :destroy | |
private | |
def send_welcome_email | |
CustomerMailer.welcome_email(self).deliver | |
end | |
def auto_registered? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomersController < ApplicationController | |
# … | |
def create | |
@customer = Customer.new(customer_params) | |
respond_to do |format| | |
if @customer.save | |
format.html { redirect_to @customer, | |
notice: 'Customer was successfully created.' } | |
format.json { render :show, status: :created, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomersController < ApplicationController | |
# … | |
def create | |
if auto_create_request? | |
@customer = Customer.auto_create(customer_params) | |
else | |
@customer = Customer.register(customer_params) | |
end | |
respond_to do |format| |