Skip to content

Instantly share code, notes, and snippets.

View letmein's full-sized avatar
🏠
Working from home

Yuriy Kharchenko letmein

🏠
Working from home
  • Armenia, Yerevan
  • 15:30 (UTC +04:00)
View GitHub Profile
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@bf4
bf4 / bin-squash_migrations
Created November 12, 2015 16:07
Squash Rails migrations in this one easy step
#!/usr/bin/env bash
git ls-files db/migrate/*.rb | sort | tail -1 | \
ruby -e "schema_version=STDIN.read[/\d+/]; init_schema=%(db/migrate/#{schema_version}_init_schema.rb);
%x(git rm -f db/migrate/*.rb;
mkdir db/migrate;
git mv db/schema.rb #{init_schema};
rake db:migrate;
git add db/schema.rb; git commit -m 'Squashed migrations')"
@drhenner
drhenner / gist:8462170
Created January 16, 2014 19:53
Form Objects vs. Inheritance
# The purpose of this gist is to propose use of inheritance when upgrading objects to have "more functionality".
# For example:
# Lets say you have a `company` model and your project manager purposes a huge pivot to your existing application.
# Now new fields are "required" for the new companies you create. Unfortunately adding validators to the existing
# `company` model will cause things to blow up. You could create a form object for the new forms with form specific
# validators. Several issues are now introduced:
# 1) There can be several form objects for the company. Each with a slight difference in logic.
anonymous
anonymous / Idea Request
Created October 18, 2012 09:37
Idea Request
{"idea":{"description":"fghgfh","planned_at":"2012-10-18 11:35:32 +0300","lon":-122.4105,"image_base64":"iVBORw0KGgoAAAANSUhEUgAAAMAAAAEcCAYAAACRV7vnAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAHGlET1QAAAACAAAAAAAAAI4AAAAoAAAAjgAAAI4AAB\/sBALxiAAAH7hJREFUeAHsnWdwXNd5hjeJI1k2gMWCaKREgA0ECZIi\/Sf5lYziyQ\/nhx17PHQscheFALahkQQIgqQkVrH3XkRRhaKsaku2ZU+cmYwnk+IZO4nHE8WJ7diWTTWbYhcbsDfv+9177l6UXbRdACY\/znxz7hbuXpx93vOVe865PsuyfDT8+2Nfbe0nfeHFfl\/oS8U5DcFHCsLBhvxozYpAJLg6NxLamhcJ7skNB4\/nRZb+MC8c\/FlueOlv8PiDvHDoIzy+hPaKPxa8Dbvjj4W6\/dFgN9oefxQWq+7xR0IJsain5bHavd0H5KI3E+DFcAOOhCcwFQ3eAmOXHdZ+D\/7O4\/jXsLfB5nfQHvKHl+5Gu74gGmoPRKrjgcbQV+8LPzrHV\/vFfF\/L0jzfI498Aqz\/kcu9e6ACuLchHM9BaDwFICM\/4ff5PuELf\/5TvuW1+b6GR0tyoo9+tiCyJJwvSgqtyW0Mbof69uU2hk7mRUKOBwjCA4TEA\/jD1ZcwusMDhG7nx4N38uEBbKvuycfoL4ZOxuc5Vo1WTfvAMGC4QGt4kRYcgSc\/LRq6BcbgAaoZbcADBD0eYOl38xqDR2B7EaFsDMSCqwLRYHMgvHTJffHQXF9sScC3Ouz3zZt3H1j\/kyT3DHsk9Al\/Kh9u4tNtj5Y80La4LC\/y6OcC4WCzvyG4Nh8uJRfhD8A\/nBupftofCf4H3NEvcEK\/hX2Ak7qI9jLgv+qP1dz2x6shgOpuf7yG1pNPi8G8wMfwh6tpHxgGvGw4z
@letmein
letmein / database.rb
Created September 18, 2012 11:53
Read database config from database.yml in a padrino app
# On Heroku we'll read the config from ENV
if postgres = URI.parse(ENV['DATABASE_URL'] || '')
ActiveRecord::Base.configurations[:production] = {
:adapter => 'postgresql',
:encoding => 'utf8',
:database => postgres.path[1..-1],
:username => postgres.user,
:password => postgres.password,
:host => postgres.host
}
@deekayen
deekayen / df.sh
Created July 18, 2012 19:11
Disk space cron monitor for Ubuntu
#!/bin/bash
ADMIN="help@example.com"
ALERT=95
df -H | grep -vE '^Filesystem|none|tmpfs|cdrom|varrun|varlock|udev|devshm|boot' | awk '{ print $4 " " $5 " " $6 }' | while read output;
do
usep=$(echo $output | awk '{ print $2}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $3 }' )
free=$(echo $output | awk '{ print $1 }' )
if [[ $usep -ge $ALERT ]]; then
echo "Running out of space $partition ($usep% used, $free avail)
@re5et
re5et / dig.rb
Created March 2, 2012 01:29
ruby hash dig
class Hash
def dig(*path)
path.inject(self) do |location, key|
location.is_a?(Hash) ? location[key] : nil
end
end
end
@lucashungaro
lucashungaro / links.textile
Created August 14, 2010 16:36
Links de referência utilizados em minha palestra
@torsten
torsten / proxy.rb
Last active April 30, 2024 17:53
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,