Skip to content

Instantly share code, notes, and snippets.

View nateklaiber's full-sized avatar

Nate Klaiber nateklaiber

View GitHub Profile
@jsok
jsok / README
Created October 4, 2012 04:36
iOS 6 SMS database dumping
Looking into how to retrieve SMS archives from iOS 6.
Useful resources:
http://lasc.livejournal.com/284909.html
To explain the datetime mangling:
"The timestamps are not traditional timestamps of the number of seconds from 1/1/1970, but are instead based on the number of seconds from 1/1/2001 (so, there is a 31 year offset). So, we have to add the number of seconds in 31 years (978264705) to the timestamp to change it to a traditional timestamp giving the number of seconds from 1/1/1970."
Query below will pull a history of all message to and from the PHONE NUMBER specified.
@daz
daz / gist:5392816
Last active December 16, 2015 06:39
Getting distinct years in Rails and Postgresql
# start_time is a #datetime column, Postgres stores as a timestamp, we need to use date_part to extract 'year'
Event.select("date_part('year', start_time)").uniq
# Spits out
# SELECT DISTINCT date_part('year', start_time) FROM "events"
require 'coercible'
class Transformer
include Enumerable
COERCER = Coercible::Coercer.new
COERCIONS = Hash.new(:to_string).update(
id: :to_integer,
updated_on: :to_date,
#!/usr/bin/ruby
require 'net/http'
require 'net/smtp'
# Brian Wigginton
# http://www.bwigg.com/2008/10/ruby-script-to-check-site-availability/
# 10/7/2008
#
# Check's availabilty of a website. Needs to be run via a cron job.
@hilios
hilios / gist:1284170
Created October 13, 2011 12:57
Nginx YSlow performance boost w/ Gzip + Far future expires Header
server {
# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# make sure gzip does not lose large gzipped js or css files
def has_pair_with_sum_brute_force(input, sum)
# Boolean coercion. Just returning an int (index where found) can be confusing
!!input.find.with_index do |value, i|
# All we need to do is keep the inner loop one ahead of the outer.
input[(i + 1)..-1].find do |sub_value|
value + sub_value == sum
end
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'rufus/scheduler'
scheduler = File.join(File.dirname(__FILE__), 'scheduler.rb')
options = {
:app_name => 'scheduler',
:ARGV => ARGV,
@schneems
schneems / asset_sync_is_the_devil.md
Last active June 19, 2021 00:12
I hate asset_sync

A not politically correct assertion of my feelings towards a piece of software:

Note: Repetition builds cynicism, asset_sync isn't bad, but when an asset problem cannot be solved via support it gets escalated to me. Often times someone using asset_sync the problem is due to their use of the library and not from Heroku.

Backstory

The asset sync gem uploads your assets (images, css, javascript) to S3. From there you can either point browsers to the copy on S3 or use a CDN + the S3 bucket. It's a good idea, and solved a problem at one time.

It is no longer needed and you should now use https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn instead. So rather than copying your assets over to S3 after they are precompiled the CDN grabs them from your website instead. Here's some reasons why it's better.

@FUT
FUT / install-redis.sh
Last active April 19, 2022 11:16
Install Redis on EC2
1. Install Linux updates, set time zones, followed by GCC and Make
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make
2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
@craigbeck
craigbeck / introspection-query.graphql
Created April 6, 2016 20:20
Introspection query for GraphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {