Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@unclebob
unclebob / apology.
Created April 27, 2012 12:19
Apology to Women Programmers.
Today I gave a keynote at ACCU in Oxford. In the midst of it I made two (count them) two statements that I should have known better than to make. I was describing the late '70s, and the way we felt about the C language at the time. My slide said something like: "C was for real men." Emily Bache, whom I know and hold in high regard, spoke up and said "What about women?". And I said something like: "We didn't allow women in those days." It was a dumb crack, and should either not have been said, or should have been followed up with a statement to the effect that that was wrong headed.
The second mistake I made was while describing Cobol. I mentioned Adm. Grace Hopper. I said something like "May she rest in peace." I don't know that any of the words were actually demeaning, but the tone was not as respectful as it should have been to an Admiral in the United State Navy, and one who was so instrumental in our industry; despite what I feel about Cobol.
I am a 59 year old programmer who was brought up
@matthewd
matthewd / db-switch.rb
Created April 1, 2021 05:50
bin/db-switch
#!/usr/bin/env ruby
require(Dir.pwd + "/config/environment")
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
ActiveRecord::Base.establish_connection(db_config.config)
context = ActiveRecord::Base.connection.migration_context
missing_migrations = []
@natematykiewicz
natematykiewicz / migrate-sidekiq-redis.rb
Last active February 21, 2024 17:18
Migrate Sidekiq Redis
# A script to migrate Sidekiq's redis to a new server.
# This obviously can work for any redis, but I only handled
# data types that Sidekiq uses.
require 'redis'
old_redis = Redis.new url: 'redis://old-redis:6379'
new_redis = Redis.new url: 'redis://new-redis:6379'
unknowns = []
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 16, 2024 12:16
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@chantastic
chantastic / .projections.json
Last active February 13, 2024 19:42
ember-cli VIM projections
{
"app/adapters/*.js": {
"command": "adapter",
"template": [
"// export default DS.{capitalize}Adapter.extend();",
]
},
"app/components/*.js": {
"command": "component",
@bf4
bf4 / polymorphic_many_to_many_in_rails.md
Last active February 6, 2024 21:13
a polymorphic many-to-many association in Rails

This was my solution for a polymorphic many-to-many association

class ItemCountry < ActiveRecord::Base
  belongs_to :locatable, :polymorphic => true
  belongs_to :country
  # fields are :locatable_id, :locatable_type, :country_id
end

class Title < ActiveRecord::Base

has_many :countries, :through => :item_countries, :as => :locatable

@drnic
drnic / schema_dumper.rb
Last active February 6, 2024 16:01
Our rails db includes our own tables/schema and the Salesforce/Heroku Connect schema (under "salesforce.*"). We place this file in config/initializers/schema_dumper.rb and now our rails db:schema:dump includes both our own tables and the salesforce. tables.
# This solution was based on https://gist.github.com/GlenCrawford/16163abab7852c1bd550547f29971c18
Rails.configuration.to_prepare do
ActiveRecord::SchemaDumper.ignore_tables = %w[
salesforce._hcmeta
salesforce._sf_event_log
salesforce._trigger_log
salesforce._trigger_log_archive
]
end
URL Page_Title Date Transcript Img_Title Img_URL Keywords from http://www.andromedayelton.com/dckx.php
http://xkcd.com/1 Barrel - Part 1 [[A boy sits in a barrel which is floating in an ocean.]] Boy: I wonder where I'll float next? [[The barrel drifts into the distance. Nothing else can be seen.]] {{Alt: Don't we all.}} Don't we all. http://imgs.xkcd.com/comics/barrel_cropped_(1).jpg
http://xkcd.com/2 Petit Trees (sketch) [[Two trees are growing on opposite sides of a sphere.]] {{Alt-title: 'Petit' being a reference to Le Petit Prince, which I only thought about halfway through the sketch}} 'Petit' being a reference to Le Petit Prince, which I only thought about halfway through the sketch http://imgs.xkcd.com/comics/tree_cropped_(1).jpg
http://xkcd.com/3 Island (sketch) [[A sketch of an Island]] {{Alt:Hello, island}} Hello, island http://imgs.xkcd.com/comics/island_color.jpg
http://xkcd.com/4 Landscape (sketch) [[A sketch of a landscape with sun on the horizon]] {{Alt: There's a river flowing through the ocea
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.