Skip to content

Instantly share code, notes, and snippets.

@rantoniuk
rantoniuk / backup.rake
Created January 10, 2011 12:53
Rake task for backing up MySQL database in Rails projects
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
@mariusbutuc
mariusbutuc / myRubyMine.sh
Created May 18, 2011 15:18
Executable script to run RubyMine under Ubuntu, using bash
#!/bin/sh
export JDK_HOME=/usr/lib/jvm/java-6-sun
cd /home/marius/.RubyMine31/bin
exec ./rubymine.sh
@daz
daz / style.scss
Last active May 13, 2023 11:24 — forked from kevindavis/gist:1868651
Bootstrap styling for jQuery UI autocomplete
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
float: left;
display: none;
min-width: 160px;
_width: 160px;
padding: 4px 0;
@jwo
jwo / mysql.database.yml
Last active March 28, 2024 15:32
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 30, 2024 08:12
A badass list of frontend development resources I collected over time.
@imposibrus
imposibrus / install.sh
Last active January 6, 2018 12:13
Install MongoDB PHP driver on Ubuntu 14.04
sudo apt-get install -y php-pear php5-dev
sudo pecl install mongo
sudo sh -c "echo 'extension=mongo.so' > /etc/php5/mods-available/mongo.ini"
sudo ln -s /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/mongo.ini
sudo service apache2 restart
@wendygwo
wendygwo / Adding 'Forgot Password' to login page.md
Last active February 21, 2022 14:03
How to add 'Forgot password' to a Rails app that's using bcrypt for authentication

Credit:

All the steps below came from watching the Railscast below:

http://railscasts.com/episodes/274-remember-me-reset-password

The steps below assumes that your app already has a user and user authentication set up.

  • Add to app/views/sessions/new.html.erb file
<p><%= link_to 'Forgot password?', new_password_reset_path %></p>
@SunDi3yansyah
SunDi3yansyah / pwl.php
Created October 12, 2015 17:06
Tugas Pemrograman Web Lanjut {M. Rudyanto Arief, MT}
<?php
$nilai_angka = 85;
$mata_kuliah = 'Pemrograman Web Lanjut';
if ($nilai_angka > 80) {
$nilai_huruf = 'A';
$ket = 'Lulus';
} elseif ($nilai_angka > 60) {
$nilai_huruf = 'B';
$ket = 'Lulus';
} elseif ($nilai_angka > 50) {
@wicky-andrian
wicky-andrian / Issue about Rails 4.2.4 Make sure that `gem install mysql2 -v '0.4.1'`
Created November 8, 2015 17:57
About Issue Mysql2 cannot bundle install in rails -v 4.x.x
do it ..
gem 'mysql2', '~> 0.3.18' this gem works with rails version 4.x.x
if install gem 'mysql2', '~> 0.4.0' it produces gem load error
referense
https://github.com/rails/rails/issues/21544
@rwarbelow
rwarbelow / running_app_in_production_locally.markdown
Created November 11, 2015 18:26
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.