Skip to content

Instantly share code, notes, and snippets.

View nebolsin's full-sized avatar
🎯
Focusing

Sergey Nebolsin nebolsin

🎯
Focusing
View GitHub Profile
@nebolsin
nebolsin / string_inquirer.rb
Created February 15, 2011 16:45
Rails 2.3.10 ActiveSupport::StringInquirer class
module ActiveSupport
# Wrapping a string in this class gives you a prettier way to test
# for equality. The value returned by <tt>Rails.env</tt> is wrapped
# in a StringInquirer object so instead of calling this:
#
# Rails.env == "production"
#
# you can call this:
#
# Rails.env.production?
@nebolsin
nebolsin / paperclip_extensions.rb
Created February 24, 2011 13:26
Paperclip extension to work with nginx upload module
module Paperclip
class Attachment
class UploadedPath
attr_reader :original_filename, :content_type, :size, :path
def initialize(uploaded_file)
@original_filename = uploaded_file["name"].downcase
@content_type = uploaded_file["content_type"].to_s.strip
@file_size = uploaded_file["size"].to_i
@path = uploaded_file["path"]
@nebolsin
nebolsin / nginx_upload.conf
Created March 1, 2011 08:56
Excerpt from nginx config file for using nginx_upload_module with Rails
location = /videos/ {
upload_pass_form_field "^video";
upload_store /path/to/your/app/tmp/upload;
upload_pass @large_upload;
upload_pass_args on;
upload_store_access all:rw;
upload_set_form_field "$upload_field_name[name]" "$upload_file_name";
upload_set_form_field "$upload_field_name[content_type]" "$upload_content_type";
upload_set_form_field "$upload_field_name[path]" "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name[md5]" "$upload_file_md5";
@nebolsin
nebolsin / postgresql_patches.rb
Created June 24, 2011 15:33
Rails Postgresql adapter patches for better schema support
# config/initializers/postgresql_patches.rb
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
def quote_table_name(name)
schema, name_part = extract_pg_identifier_from_name(name.to_s)
return quote_column_name(schema) unless name_part
table_name, name_part = extract_pg_identifier_from_name(name_part)
"#{quote_column_name(schema)}.#{quote_column_name(table_name)}"

Optimize non-Apple SSDs on OS X. (Run the following commands in the terminal.)

Enable TRIM support

Check IOAHCIBlockStorage version:

open /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist
@nebolsin
nebolsin / osx-for-hackers.sh
Created October 28, 2015 04:07 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@nebolsin
nebolsin / 00_README.md
Created April 10, 2016 19:11 — forked from dbalatero/00_README.md
This is an example of how I combine interaction/service classes with Wisper event broadcasting inside Rails.

This is an example of how I combine interaction/service classes with Wisper event broadcasting in Rails.

In this example, I show a UsersController#create API, a corresponding service object, and all the test code/listeners to make it all happen.

The outcome is:

  • Concepts in your system ("Signing up a user", "Creating an order") have a single entry point in your codebase, vs. making stupid raw ActiveRecord calls to object.save in dozens of places.
  • Since your concept has one entry point (the service class), you can easily grep for usage of it.
  • Stupid easy to attach listeners to the service class
  • All event listeners are very small and easily unit tested
@nebolsin
nebolsin / keybase.md
Created June 11, 2017 06:00
keybase.md

Keybase proof

I hereby claim:

  • I am nebolsin on github.
  • I am nebolsin (https://keybase.io/nebolsin) on keybase.
  • I have a public key ASBSbCz-7MIr-VOFm56_B4-rbOVK0qlwG_Jrkt1FFJjUhwo

To claim this, I am signing this object:

@nebolsin
nebolsin / btc
Created December 21, 2017 02:21 — forked from anonymous/btc
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<style>
body {padding:0; margin:0}
.container {display:flex; flex-wrap: wrap;}
.child {flex-grow: 1; width:50%; height:33.3vh;}
</style>
<div class='container'>
<div class='child'>
<script type="text/javascript">
new TradingView.widget({
@nebolsin
nebolsin / stellar-core-bug.cfg
Created February 5, 2018 07:14
Stellar Core unexpectedly resets DB
PEER_PORT=11635
HTTP_PORT=11636
DATABASE="postgresql://dbname=stellar-bug user=stellar"
LOG_FILE_PATH="/var/log/stellar/stellar-core-bug.log"
BUCKET_DIR_PATH="/var/lib/stellar/buckets-bug"
NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
KNOWN_PEERS=[