Skip to content

Instantly share code, notes, and snippets.

@bazzel
bazzel / README.md
Last active March 20, 2022 22:00
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@dideler
dideler / bot.rb
Last active May 23, 2024 17:31
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@hoverlover
hoverlover / pg_locking.rb
Last active November 26, 2019 08:57
PG::LockNotAvailable rescue woes
def save_with_lock
r = Record.first
# This will raise PG::LockNotAvailable if already locked
#
r.with_lock("FOR UPDATE NOWAIT") do
# do stuff
end
# This rescue block isn't executed for some reason??
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@mindmergedesign
mindmergedesign / st3_sync
Created February 14, 2014 18:33
Sync Sublime Text 3 Packages and Settings with Dropbox
####################
# FROM MAIN COMPUTER
####################
# Create the sync directory in Dropbox
$ mkdir ~/Dropbox/sublime-text-3
# Move your ST3 "Packages" and "Installed Packages" to Dropbox
$ cd ~/Library/Application\ Support/Sublime\ Text\ 3
$ mv Packages/ ~/Dropbox/sublime-text-3
$ mv Installed\ Packages/ ~/Dropbox/sublime-text-3
@stereoscott
stereoscott / active_admin_extensions.rb
Created January 12, 2014 00:29
Sample ActiveRecord model that uses paperclip to upload a csv report to s3
module ActiveAdmin
module Reports
module DSL
def enable_reports
action_item only: :index do
link_to("Download", {action: :report, params: params}, {method: :post, data: { confirm: "Are you sure you want to generate this report?"}})
end
collection_action :report, method: :post do
@infertux
infertux / select2_helper.rb
Last active November 17, 2022 20:46
Helper to select a Select2 item with Capybara/Cucumber
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb
module Select2Helper
# @example
# select2 "Item", from: "select_id"
# select2 /^Item/, from: "select_id"
#
# @note Works with Select2 version 3.4.1.
def select2(text, options)
find("#s2id_#{options[:from]}").click
@impressiver
impressiver / raven-config.html
Last active February 27, 2024 14:27
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 22, 2024 05:53
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'