Skip to content

Instantly share code, notes, and snippets.

View paxer's full-sized avatar
💭
🤔

Pavel Kotlyar paxer

💭
🤔
View GitHub Profile
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@mumoshu
mumoshu / Unity+WebSocket.cs
Created August 31, 2011 16:13
Unity+WebSocket.cs
using UnityEngine;
using System.Collections;
using SuperWebSocket.Client;
using System;
public class Net : MonoBehaviour {
private string lastMessage = string.Empty;
public static string serverURI = "ws://192.168.100.196:12345/channels/0?userId=1";
public static WebSocket webSocket = new WebSocket(serverURI, "basic");
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@edouard
edouard / dominant_colors.rb
Created February 10, 2012 08:53
A ruby script to get the most dominant colours in an image (uses ImageMagick)
require 'RMagick'
TOP_N = 10 # Number of swatches
# Create a 1-row image that has a column for every color in the quantized
# image. The columns are sorted decreasing frequency of appearance in the
# quantized image.
def sort_by_decreasing_frequency(img)
hist = img.color_histogram
# sort by decreasing frequency
@jcasimir
jcasimir / exporter.rb
Created February 26, 2012 17:39
Export ActiveRecord Tables to CSV
require 'csv'
class Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.export_tables_to_csv(tables = DEFAULT_EXPORT_TABLES)
tables.each { |klass| export_table_to_csv(klass) }
end
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@bradleypriest
bradleypriest / active_record.rb
Created March 22, 2012 20:01 — forked from jcf/active_record.rb
Backport pluck to Rails 3.0/3.1
# config/initializers/extensions/active_record.rb
module ActiveRecord
class Base
class << self
delegate :pluck, to: :scoped
end
end
class CollectionProxy
delegate :pluck, to: :scoped
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@rubencaro
rubencaro / install_elixir.md
Last active September 30, 2023 03:58
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@omnibs
omnibs / phoenix showdown rackspace onmetal io.md
Last active January 25, 2023 18:33
Phoenix Showdown Comparative Benchmarks @ Rackspace

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)