Skip to content

Instantly share code, notes, and snippets.

@mustafaturan
mustafaturan / network-tweak.md
Last active June 16, 2024 21:58
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@dideler
dideler / upgrade-postgres-9.3-to-9.4.md
Last active June 8, 2020 03:24
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 4, 2024 04:16
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@basti
basti / application.rb
Last active March 1, 2021 10:42 — forked from keighl/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@appsandwich
appsandwich / MKMapView+Extensions
Created January 10, 2014 15:04
Get & set the zoom level of a MKMapView
@interface MKMapView (Extensions)
-(double)as_zoomLevel;
-(void)as_setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(NSUInteger)zoomLevel animated:(BOOL)animated;
@end
static double mercadorRadius = 85445659.44705395;
static double mercadorOffset = 268435456;
@linjunpop
linjunpop / Objective-C-for-Rubyist.md
Last active November 28, 2018 12:18
Objective-C for Rubyist.

Objective-C for Rubyist

Basic Syntax

Message

[you say:@"Hello."];
@nolanlawson
nolanlawson / 00_Font_Size_Adjust_PhoneGap_Plugin.md
Last active October 2, 2019 13:55
PhoneGap plugin that allows you to modify the WebView font size on Android.

Font size adjustment plugin for PhoneGap on Android: a simple PhoneGap plugin that allows you to dynamically modify the WebView's textSize property in order to make the text larger/smaller.

Usage:

// increase the font size by one unit (units are [50%,75%,100%,150%,200%])
window.plugins.fontSizeAdjust.increase(myCallback(newFontSizeAsPercent){});

// decrease the font size by one unit
window.plugins.fontSizeAdjust.decrease(myCallback(newFontSizeAsPercent){});
@knzai
knzai / uri_validator.rb
Last active December 14, 2015 16:09 — forked from bluemont/url_validator.rb
Totally untested, just forked and tweaked for discussion
require 'addressable/uri'
#Accepts options[:message] and options[:allowed_protocols]
class UriValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
uri = parse_uri(value)
if !uri
record.errors[attribute] << generic_failure_message
elsif !allowed_protocols.include?(uri.scheme)
@shtirlic
shtirlic / gist:5052306
Last active November 18, 2021 17:58 — forked from joelmoss/gist:2470666
set :stage, 'production'
set :shared_children, shared_children << 'tmp/sockets'
puma_sock = "unix://#{shared_path}/sockets/puma.sock"
puma_control = "unix://#{shared_path}/sockets/pumactl.sock"
puma_state = "#{shared_path}/sockets/puma.state"
puma_log = "#{shared_path}/log/puma-#{stage}.log"
namespace :deploy do
desc "Start the application"
@ryanb
ryanb / development.rb
Created November 27, 2012 21:38
Some rack middleware to add headers to asset pipeline.
class AssetHeaders
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
response = @app.call(env)
if request.path =~ /^\/assets\//
# there maybe a better way to add headers