Skip to content

Instantly share code, notes, and snippets.

View jumph4x's full-sized avatar

Denis Ivanov jumph4x

  • FCP Euro
  • Oakland
View GitHub Profile
@ggonnella
ggonnella / mysql_DB_clone.rake
Created April 21, 2009 08:47
MySQL rake task for rails to copy the content of the production database to the development database. Please note that the current development database will be DROPPED!
namespace :db do
namespace :mysql do
desc "Overwrite the whole development db with a copy of the production db"
task :init_dev do
config = YAML.load(IO.read("config/database.yml"))
d = config["development"]
p = config["production"]
unless d["adapter"] == "mysql" and
@tansengming
tansengming / Rails Console Actionmailer test.rb
Created April 24, 2009 15:14
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
@tomlea
tomlea / gist:207938
Created October 11, 2009 22:55
This is very rough and ready.
require "net/http"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
#
@louisgillies
louisgillies / paperclip_migration.rake
Created October 26, 2010 11:36
Quick and dirty one off migration task for paperclip plugin to move files from local filesystem to Amazon S3.
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:model_1, :model_2] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
@coop
coop / Deploy
Created August 2, 2011 22:55
Deploy to S3 - Asset Pipeline, S3 and Heroku
namespace :deploy do
desc "Deploy to Heroku"
task :heroku do
Rake::Task["deploy:precompile_assets_and_upload_to_s3"].invoke
Rake::Task["deploy:push_heroku"].invoke
end
desc "Precompile assets and upload to s3"
task :precompile_assets_and_upload_to_s3 do
storage = Fog::Storage.new :provider => 'AWS', :aws_access_key_id => "123", :aws_secret_access_key => "123"
# app/models/my_model.rb
module MyApp
module Model
def self.included(base)
base.send :include, Mongoid::Document
base.send :include, Mongoid::Timestamps
base.send :include, ActiveAdmin::Mongoid::Patches
end
end
@ngauthier
ngauthier / README.md
Created July 5, 2012 20:10
Rdio "native" in linux

I like Rdio and linux. Rdio works great in a browser except for one thing: keyboard shortcuts!!!

When coding, I like to be able to play/pause my music quickly, meaning I don't want to switch windows. I figured out a way to do this:

Google Chrome --app

First, I made a file in my ~/bin called rdio that runs:

google-chrome --app=http://rdio.com
@capotej
capotej / getprismatic.com.js
Created July 25, 2012 16:19
scrubs useless stories from prismatic based on banned sites, tags, or words; install dotjs to use http://defunkt.io/dotjs/
var banned_sites = ['Bits', 'Forbes.com', 'TechCrunch', 'PCWorld', 'AllThingsD'];
var banned_tags = ['Venture Capital', 'Social', 'Startups', 'PHP', 'Social Media'];
var banned_words = ['Node', 'PHP', 'Zend', 'Cloud'];
var scrubber = function(){
$('.article').each(function(index, object){
var hideit = false;
var publisher = $(object).find('.publisher').find('.interest').text();
@NZKoz
NZKoz / apologies.text
Last active February 22, 2022 16:01
Template password compromise documentation
Dear [First Name],
We're really sorry but our systems were compromised and the attackers managed to take a copy
of your passwords.
The passwords were stored as:
[ ] Bcrypt hashes with a cost factor of X
[ ] PBKDF2 hashes with an iteration count of X
[ ] scrypt because I am Colin Percival
@willurd
willurd / web-servers.md
Last active May 23, 2024 08:59
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000