# List available rubies, to choose which ruby to use
$ rvm list rubies
# To install new ruby use, for example version '2.4.1'
$ rvm install 2.4.1
# Extended python -m http.serve with --username and --password parameters for | |
# basic auth, based on https://gist.github.com/fxsjy/5465353 | |
from functools import partial | |
from http.server import SimpleHTTPRequestHandler, test | |
import base64 | |
import os | |
class AuthHTTPRequestHandler(SimpleHTTPRequestHandler): |
sudo -i | |
cd | |
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y | |
sudo apt-get install libperl-dev gcc libjpeg-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz pkg-config | |
wget http://www.imagemagick.org/download/ImageMagick.tar.gz | |
tar xf ImageMagick.tar.gz | |
cd ImageMagick-6.9.2-8/ | |
./configure --prefix=/opt/imagemagick-6.9 | |
make | |
make install |
BEGIN { | |
require 'net/http' | |
Net::HTTP.module_eval do | |
alias_method '__initialize__', 'initialize' | |
def initialize(*args,&block) | |
__initialize__(*args, &block) |
After I installed the fantastic better_errors gem, I was disappointed to notice that linking to your text editor doesn't work correctly on Ubuntu (at least, it didn't for me). Here's how I fixed it.
First, create a new desktop entry:
# /usr/share/applications/subl-urlhandler.desktop
#!/bin/bash | |
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..." | |
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n" | |
## Gnuplot settings | |
echo "set terminal jpeg | |
set output 'benchmark_${1}_${2}.jpeg' | |
set title 'Benchmark: ${1} ${2}' |
# http://guides.rubygems.org/command-reference/#gem-environment | |
--- | |
gem: --no-document --verbose --backtrace | |
update_sources: true | |
backtrace: true |
I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.
Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.
A traditional approach for this on a Rails project is to use something like the acts_as_list
gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position
SQL query.
This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri
def self.reindex! | |
model_name = self.name.to_s | |
total = self.count | |
indexed = 0.to_f | |
progress = 0.to_f | |
row_length = 100.to_f | |
log_level = Sunspot::Rails::LogSubscriber.logger.level | |
time_start = Time.now | |
each_second = Time.now | |
per_second = 0 |
# Make gems available | |
require 'rubygems' | |
begin | |
require "ap" | |
alias pp ap | |
rescue LoadError | |
puts "Please install the 'awesome_print' gem." | |
end |