Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
MONTH=`date +"%Y-%m"`
DAY=`date +"%d"`
THISHOUR=`date +"%H"`
LASTHOUR=`expr $THISHOUR - 1`
TIMESTAMP=`date +"%Y-%m-%d"`
TIMESTAMP="${TIMESTAMP}-${LASTHOUR}"
echo "Start: postgresql.log.${TIMESTAMP}"
@ruckus
ruckus / mailer_recipient_override.rb
Created September 9, 2016 21:40
Place in `config/initializers/mailer_recipient_override.rb` and be sure to define an environment variable for `EMAIL_RECIPIENT_OVERRIDE`
class OverrideMailReciptient
def self.delivering_email(mail)
if Rails.env.development?
original_to = mail.to
mail.to = ENV['EMAIL_RECIPIENT_OVERRIDE']
mail.subject = "[DEVELOPMENT] #{mail.subject} - Recipient: #{original_to}"
if mail.cc && mail.cc.any?
new_body = "#{mail.body}\n\nRemoved CC: recipients: #{mail.cc.join(", ")}"
mail.body = new_body
mail.cc = []
@Bind(R.id.distributor)
TextView mDistributor;
@Bind(R.id.status)
TextView mStatus;
@Bind(R.id.order_date)
TextView mOrderDate;
@Bind(R.id.pickup_date)
TextView mPickupDate;
@Bind(R.id.delivery_date)
TextView mDeliveryDate;
@ruckus
ruckus / generate_butterknife_binds.rb
Created September 30, 2015 02:14
Auto-generate ButterKnife @Bind calls
require 'rubygems'
require 'nokogiri'
xml = Nokogiri::XML(File.read(ARGV[0]))
xml.remove_namespaces!
class String
def camel_case
return self if self !~ /_/ && self =~ /[A-Z]+.*/
sheet.sheet_view do |sv|
sv.pane do |pane|
pane.top_left_cell = 'B1'
pane.state = :frozen
pane.x_split = 1
pane.active_pane = :top_right
end
end
<sheetView windowProtection="false" tabSelected="false" showWhiteSpace="false" showOutlineSymbols="false" showFormulas="false" rightToLeft="false" showZeros="true" showRuler="true" showRowColHeaders="true" showGridLines="true" defaultGridColor="true" zoomScale="100" workbookViewId="0" zoomScaleSheetLayoutView="0" zoomScalePageLayoutView="0" zoomScaleNormal="0">
<pane topLeftCell="B1" state="frozen" activePane="topRight" ySplit="0" xSplit="1"/>
</sheetView>
@ruckus
ruckus / rds_download_logfiles.rb
Created January 9, 2015 03:58
Ruby script to download log files from RDS and archive to S3.
=begin
This script uses the AWS v2 API
Gemfile:
source "https://rubygems.org"
gem "aws-sdk", "2.0.17.pre"
@ruckus
ruckus / MainActivity.java
Created September 25, 2014 20:49
Example of using a ViewPager as a Header in a ListView. We need to explicitly set the layout params of the Header view because its not known at initialization time, in my case I am asynchronously loading images into the ViewPager.
public class ProductDetailActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
final int width = displayMetrics.widthPixels;
mListView = (ListView)findViewById(R.id.product_detail_list_view);

Keybase proof

I hereby claim:

  • I am ruckus on github.
  • I am toolbag (https://keybase.io/toolbag) on keybase.
  • I have a public key whose fingerprint is E0A2 B6E5 3211 66F3 C462 ADC6 90E5 F40B 708B A52A

To claim this, I am signing this object:

@ruckus
ruckus / gist:747c702d7ab7f4243c69
Created August 1, 2014 15:52
Sample result of QBO AgedReceivables report
{
"Header": {
"Time": "2014-07-01T08:51:36-07:00",
"ReportName": "AgedReceivables",
"StartPeriod": "2014-08-01",
"EndPeriod": "2014-08-01",
"Currency": "USD",
"Option": [
{
"Name": "report_date",