Skip to content

Instantly share code, notes, and snippets.

@Bradsta
Bradsta / gist:3805806
Created September 30, 2012 04:01
Cleverbot java responder
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Random;
import javax.script.Invocable;
import javax.script.ScriptEngine;
@carlsednaoui
carlsednaoui / New mac address
Created August 29, 2012 02:56
Generate and set a new mac address
# Place this in your .bash_profile to change your mac address
# Simply run newmac from your terminal and boom, you'll have a new mac address
# Change mac address
function newmac() {
local OLDMAC=$(ifconfig en0 | grep ether | cut -d ' ' -f 2)
local GENMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig en0 ether $GENMAC
@carlsednaoui
carlsednaoui / generate_csv.rb
Last active October 6, 2015 12:17 — forked from jescalan/sample.rb
Easily generate a csv file.
# This is the easiest way to generate a csv and have it downloaded by the user.
# Drop this in a method in the controller and call it on click.
require 'csv'
file = CSV.generate do |csv|
csv << ["Name", "Email"] # headers
Contact.all.each do |person|
csv << [person.name, person.email]
end
@rstacruz
rstacruz / index.md
Last active May 27, 2026 15:23
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@ayanamist
ayanamist / proxy.pac
Created November 24, 2011 06:08
My Pac File for Auto Proxy
var PROXY = {
"direct":"DIRECT",
"gfw":"PROXY 127.0.0.1:8123"
};
var DEFAULT = "direct";
var SECTIONS = [
{
"name":"direct",
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)