Skip to content

Instantly share code, notes, and snippets.

@nono
nono / blowfish.rb
Created June 26, 2012 10:57
How to encrypt and decrypt Blowfish in Ruby 1.9 with https://github.com/drench/blowfish.js
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0
@chengyin
chengyin / linkedout.js
Last active July 11, 2021 15:23
Unsubscribe all LinkedIn email in "one click". For an easier to use version, you can check out the bookmarklet: http://chengyin.github.io/linkedin-unsubscribed/
// 1. Go to page https://www.linkedin.com/settings/email-frequency
// 2. You may need to login
// 3. Open JS console
// ([How to?](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers))
// 4. Copy the following code in and execute
// 5. No more emails
//
// Bookmarklet version:
// http://chengyin.github.io/linkedin-unsubscribed/

Turning Off Github Issues

My friend Michael Jackson turned off github issues on one of his smaller projects. It got me thinking...

Maintainers getting burned out is a problem. Not just for the users of a project but the mental health of the maintainer. It's a big deal for both parties. Consumers want great tools, maintainers want to create them, but maintainers don't want to be L1 tech support, that's why they

@johnrees
johnrees / gist:1670449
Created January 24, 2012 14:32
Remote IP on Heroku
def remote_ip
if forwarded = request.env["HTTP_X_FORWARDED_FOR"]
forwarded.split(",").first
elsif addr = request.env["REMOTE_ADDR"]
addr
end
end

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@phaedryx
phaedryx / summary
Last active December 3, 2022 19:27
Loyalty and Layoffs by David Brady
Original text here: https://whydavewhy.com/2013/08/16/loyalty-and-layoffs/
@kamermans
kamermans / mysql_countries.sql
Created December 7, 2011 04:43
MySQL Dump - continents and countries with 2 and 3 char codes, names and full names - Braintree compatible as of Dec 2011
/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@bluet
bluet / Database Naming Convention and Data Warehouse Design Principles.md
Last active November 13, 2023 13:12
Database Naming Convention and Data Warehouse Design Principles
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')