Skip to content

Instantly share code, notes, and snippets.

View oyeanuj's full-sized avatar

Anuj oyeanuj

View GitHub Profile
# Block the main Analytics Spammers
# Crazy big list here: http://perishablepress.com/blacklist/ultimate-referrer-blacklist.txt
SetEnvIfNoCase Referer semalt.com spammer=yes
SetEnvIfNoCase Referer darodar.com spammer=yes
SetEnvIfNoCase Referer buttons-for-website.com spammer=yes
SetEnvIfNoCase Referer fbdownloader.com spammer=yes
SetEnvIfNoCase Referer descargar-musicas-gratis.com spammer=yes
SetEnvIfNoCase Referer baixar-musicas-gratis.com spammer=yes
SetEnvIfNoCase Referer savetubevideo.com spammer=yes
SetEnvIfNoCase Referer srecorder.com spammer=yes
@kennethkalmer
kennethkalmer / nginx.conf
Last active August 3, 2021 19:44
Sample nginx config for serving a rails API and static frontend like Ember on the same domain...
daemon off;
worker_processes 4;
events {
use epoll;
accept_mutex on;
multi_accept on;
worker_connections 1024;
}
@jackrg
jackrg / active_record.rb
Created May 16, 2014 18:14
Add bulk import functionality to Rails Active Record (add this file to config/initializers, call <model>.import!(array-of-record-hashes))
class ActiveRecord::Base
def self.import!(record_list)
raise ArgumentError "record_list not an Array of Hashes" unless record_list.is_a?(Array) && record_list.all? {|rec| rec.is_a? Hash }
return record_list if record_list.empty?
(1..record_list.count).step(1000).each do |start|
key_list, value_list = convert_record_list(record_list[start-1..start+999])
sql = "INSERT INTO #{self.table_name} (#{key_list.join(", ")}) VALUES #{value_list.map {|rec| "(#{rec.join(", ")})" }.join(" ,")}"
self.connection.insert_sql(sql)
@demisx
demisx / active_record_objects_autosave.md
Last active April 29, 2024 09:02
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@bartholomej
bartholomej / css-media-queries-cheat-sheet.css
Last active May 2, 2024 08:30
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@jaymiejones86
jaymiejones86 / rails_website_launch_checklist.md
Last active January 18, 2021 17:51
Rails Website Launch Checklist

Ruby on Rails Website Launch Checklist

Copy this gist and customise it to your liking.

  • Run Brakeman and resolve any issues where required
  • Run rails best practices and resolve any warnings
  • Run full test suite and make sure all tests are passing
  • Make sure no dummy email addresses are left in any notification emails (eg contact form)
  • Make sure production assets compile correct (eg files in vendor, etc, compile and are not 404'ing in production environment)
  • If using unicorn in production, make sure deploys are restarting the unicorns
@devinrhode2
devinrhode2 / clean-scrollbar.css
Created May 2, 2012 03:42
Like, basically PERFECT scrollbars
/**
* Like, basically PERFECT scrollbars
*/
/*
It's pure CSS.
Since a quick google search will confirm people going crazy about Mac OS Lion scrollbars...
this has no fade-out effect.
In Mac OS Lion, the lowest common denominator is always showing scrollbars by a setting.