Skip to content

Instantly share code, notes, and snippets.

View kalv's full-sized avatar

Kalv Sandhu kalv

View GitHub Profile
# Run this command to get a prompt on each deleted item from your git status, useful when deleting load of files
# need to only prompt for filenames...
git status | grep deleted | xargs -p -n1 git rm
# Run on mac terminal to stop really small fonts being shown in emails - happens most when people send
# html email from microsoft land
defaults write com.apple.mail MinimumHTMLFontSize 13
mysql> SELECT concat(table_schema,'.',table_name),concat(round(table_rows/1000000,2),'M') rows,concat(round(data_length/(1024*1024*1024),2),'G') DATA,concat(round(index_length/(1024*1024*1024),2),'G') idx,concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,round(index_length/data_length,2) idxfrac FROM information_schema.TABLES ORDER BY data_length+index_length DESC LIMIT 10;
+-------------------------------------------+--------+-------+-------+------------+---------+
| concat(table_schema,'.',table_name) | rows | DATA | idx | total_size | idxfrac |
+-------------------------------------------+--------+-------+-------+------------+---------+
| aspire_production.form_answers | 28.23M | 2.97G | 1.81G | 4.78G | 0.61 |
| aspire_production.sessions | 7.52M | 1.25G | 0.53G | 1.78G | 0.42 |
| aspire_production.searches | 1.87M | 0.71G | 0.32G | 1.02G | 0.44 |
| aspire_production.aggregate_vacancy_stats | 2.80M |
desc "Subscribe a number of feeds to a superfeedr account"
task :subscribe_superfeedr do
Superfeedr.connect(Tfweb.conf[:superfeedr_jid], Tfweb.conf[:superfeedr_password]) do
puts "Connected to superfeedr"
pos = 0
batch_size = 100
loop do
feeds = Feed.find(:all, :select=>["feedurl, id"], :limit=>batch_size, :offset=>pos, :conditions=>{:superfeedr=>false})
if feeds.count == 0
@kalv
kalv / gist:209380
Created October 13, 2009 17:08
RecordHttp - helps save http requests into files when testing
# Record HTTP is to help recording the http calls for further testing
#
# usage:
# require 'record_http'
# set up the directory it needs to save the responses
# RecordHttp.save_path = '../spec/data'
# RecordHttp.include_headers = true
# RecordHttp.file_prefix = 'http_'
#
# Run your net http requests, tests, gems that use net/http and watch everything save away!
Into ./test.rb
#!/usr/bin/env ruby
#
puts RELEASE_DATE
$ /opt/ruby-enterprise/bin/rake -e "`./test.rb`"
rake aborted!
(eval):1:in `standard_rake_options': compile error
(eval):1: Illegal octal digit
2007-09-24

Playing with keywords on message

Chris and myself worked on removing keywords on the basis that it was messy and with the aim to reduce the size of the database.

This was prompted while fixing the bug where whitespace in messages were creating a lot of empty keywords.

results

We created new code to regexp to search message content. All tests were passing. But before we committed we run some benchmarks on realistic data (1.1m messages on development machine).

class Capybara::Driver::RackTest < Capybara::Driver::Base
class Node < Capybara::Node
def click
if tag_name == 'a'
driver.process(:get, self[:href].to_s)
elsif (tag_name == 'input' or tag_name == 'button') and %w(submit image).include?(type)
Form.new(driver, form).submit(self)
end
end
end
@kalv
kalv / gist:822337
Created February 11, 2011 13:29
O2 Broadband router changes

O2 Broadband router changes

These are the changes that i did to the router. Obviously some assumptions made here but last week the changes made a difference, I think resetting the box yesterday lost the changes.

Wanting to improve the wifi as at the moment believe the adsl is good but the box is crap at wifi and juggling everything else it needs to do.

Via the web interface

  • When logged in, click on wireless, then select configure from the top right and then do this:
  • Power reduction enabled should be disabled (We want the box to dedicate