Skip to content

Instantly share code, notes, and snippets.

# https://gist.github.com/sononum/6183139
module Kaminari
module ActiveRecordRelationMethods
def total_count_with_speed
if where_values_hash.empty?
sql = "SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname = #{self.connection.quote table_name}"
@_hacked_total_count || (@_hacked_total_count = self.connection.execute(sql).first["reltuples"].to_i)
else
total_count_without_speed
end
@apeckham
apeckham / test.svg
Last active August 29, 2015 14:22 — forked from anonymous/test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@apeckham
apeckham / sphinx-beta.rb
Created September 13, 2011 00:58 — forked from mikezter/sphinx-beta.rb
Homebrew Recipe to install Sphinx Search 1.10-beta
require 'formula'
class SphinxBeta < Formula
url 'http://sphinxsearch.com/files/sphinx-1.10-beta.tar.gz'
homepage 'http://www.sphinxsearch.com'
md5 '5b52ce9e93a73c66d37bc3a2402f14fa'
head 'http://sphinxsearch.googlecode.com/svn/trunk/'
def install
fails_with_llvm "fails with: ld: rel32 out of range in _GetPrivateProfileString from /usr/lib/libodbc.a(SQLGetPrivateProfileString.o)"
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get -y upgrade
require 'queue_classic'
module CloudApp
Queue = QC::Queue
FailedQueue = QC::Queue.new 'queue_classic_failed_jobs'
class Worker < QC::Worker
def handle_failure(job, exception)
FailedQueue.enqueue job
@apeckham
apeckham / generate-iOS-app-icons.sh
Created October 6, 2015 21:37 — forked from marcuswestin/generate-iOS-app-icons.sh
Generate all xcode 5 app icon sizes from one original large icon
mkdir -p generated
for size in 29 $((29*2)) $((29*3)) $((40*2)) $((40*3)) 57 $((57*2)) $((60*2)) $((60*3)) 29 $((29*2)) 40 $((40*2)) 50 $((50*2)) 72 $((72*2)) 76 $((76*2)); do
sips -Z $size --out generated/$size.png sourceIcon.png
done
@apeckham
apeckham / git-timestamp.sh
Last active March 2, 2016 05:33 — forked from davidwindell/git-timestamp.sh
Set the files' last modified times to match their git commit timestamps
#!/bin/bash -e
####
# based on http://www.clock.co.uk/blog/a-guide-on-how-to-cache-npm-install-with-docker
#
# Set's the last modified timestamp of a file to it's repositories commit timestamp.
#
# Particularly useful with docker when building after a new git checkout has been made,
# can improve docker build times for composer, bower, npm, etc
#
# @see https://github.com/docker/docker/issues/3556
@apeckham
apeckham / helpscout-export.rb
Last active December 7, 2017 14:31 — forked from stympy/helpscout-export.rb
Script to export helpscout data as json
#!/usr/bin/env ruby
require 'helpscout'
require 'fileutils'
require 'json'
api_key = ARGV[0]
helpscout = HelpScout::Client.new(api_key)
module InstanceVariablesToJson