Skip to content

Instantly share code, notes, and snippets.

@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)

@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",
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@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
@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
@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;
# Newbie Programmer
def factorial(x)
if x == 0
return 1
else
return x * factorial(x - 1)
end
end
puts factorial(6)
puts factorial(0)
@md-5
md-5 / Rules.md
Created May 6, 2013 06:49
#spigot IRC rules

Please follow these rules at all times. The general rule of thumb is two kicks and a ban. A ban will be at a length determined by md_5, and never be more than a week. If you have any complaints or feel you have been unfairly banned, please message md_5.

  • Keep the chat at a PG-13 level. If you think it might be inappropriate, don't say it.
  • Racism, sexism, bigotry, harassment, threats, etc. are strictly prohibited. Do not use racial slurs, or bigoted remarks. Do not harass or threaten any user or use this channel as a place to coordinate attacks on others.
  • No trolling, flaming, or flame-baiting. Keep discussion civil. Acting like a goof will get you removed.
  • No excessive profanity. Every now and then is fine, but if every other word that comes out of your mouth is profane, that's not ok.
  • Do not flood or spam the channel, abuse bots, or abuse chat color. It is impossible to hold a conversation when the channel is filled with inane chatter. Bots are here to provide information and preform other useful
@azenla
azenla / TPSigns.java
Last active December 21, 2015 20:29
New Annotation Based Plugins
package com.github.kaendfinger.tpsigns;
import org.minetweak.plugins.Plugin;
import org.minetweak.plugins.PluginInfo;
import org.minetweak.plugins.event.PluginEnableEvent;
import org.minetweak.util.TweakLogger;
@Plugin
public class TPSigns {
@Plugin.Instance
<tutorial>
<stage title="Capture the Wool">
<message>
<line>`7This map is a `b`lCapture the Wool `r`8(`bCTW`8) `7map.</line>
<line>`7The objective is to grab the wool on the other team's side and return it to your base.</line>
</message>
<teleport>
<point yaw="180" pitch="45">85,45,103</point>
</teleport>
</stage>