Skip to content

Instantly share code, notes, and snippets.

Terence Ponce terenceponce

Block or report user

Report or block terenceponce

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
terenceponce /
Created Aug 13, 2012
Twitter gem error: unauthorized

I can't follow/unfollow users with the Twitter gem because Twitter could not authenticate me.

I've written the Twitter app credentials in config/config.yml and I've loaded it in config/initializers/app_config.rb:

APP_CONFIG = YAML.load_file(Rails.root.join('config', 'config.yml'))

After I do Twitter.follow(username), I get a Twitter::Error::Unauthorized exception

Did I miss anything?

terenceponce / something.rb
Created Aug 14, 2012
What's the best way to retrieve tweets that are on a given timeframe?
View something.rb
def live_tweets
tweets = Twitter.user_timeline(self.twitter_username, :include_entities => true)
max_id = nil
since_id = nil
last_id = nil
tweets.each do |tweet|
if tweet.created_at.utc <= self.time_end.utc
max_id =
terenceponce / database.yml
Created Aug 27, 2012
Rails 3 PostgreSQL sample config
View database.yml
adapter: postgresql
encoding: unicode
database: applicationname_development
host: localhost
pool: 5
username: postgres
password: postgres
terenceponce /
Created Sep 5, 2012
Implementing a decent trending algorithm in Rails

I'm trying to implement a trending feature. The trending feature is based on searches that have become viral in a span of 4 hours. It will get the 6 latest popular searches.

Of course, to pull that off, I created a model called Search that has a keyword field. Every search done on the application will be stored as one row in the Search table.

At the moment, this is what I'm doing to retrieve the keywords to be classified as trending:

@popular_search = Search.where('created_at >= ?', 4.hours.ago).group(:keyword).order('count_keyword DESC').limit(6).count(:keyword)
terenceponce /
Created Nov 11, 2012
Content appears in my browser, but not in my test

I can see the content fine in my browser, but it doesn't appear in the the test. I checked the page with save_and_open_page and the categories that I created isn't in the generated page. What am I missing here?

This is the error that I'm getting:

  1. Categories index page when the user is signed in should be able to see a list of categories Failure/Error: page.should have_content expected there to be content "category-1" in "Gastos\n\n\n\n\n\n\n\n\nGastos\n\n\nHome\n\n\nAbout\n\n\nContact\n\n\n\nLogged in as\\n\nEdit profile\nSign Out\n\n\n\n\n\n\n\nBrowse Categories\nName\n\n\n\n"

    ./spec/requests/categories_spec.rb:19:in `block (4 levels) in <top (required)>'

terenceponce / ruby_example.rb
Created Aug 1, 2016
Looker embed integration
View ruby_example.rb
require 'cgi'
require 'securerandom'
require 'uri'
require 'base64'
require 'json'
require 'openssl'
module LookerEmbedClient
def self.created_signed_embed_url(options)
# looker options
terenceponce / bitcoin.conf
Last active Aug 27, 2018
Omnicore config
View bitcoin.conf
# /home/omnicore/.bitcoin/bitcoin.conf
# [core]
# [rpc]
terenceponce / profile_management_spec.rb
Last active Oct 12, 2018
Creating Signed Cookies in Capybara
View profile_management_spec.rb
# spec/features/profile_management_spec.rb
require 'rails_helper'
feature 'Profile Management', type: :feature do
given!(:user) { create(:user) }
scenario 'User updates profile' do
cookie =,
terenceponce /
Last active Jan 2, 2019
Setting up rbenv, Ruby 2.1, Rails 4.1.0.beta1, nginx, Passenger, PostgreSQL 9.1 on Ubuntu 12.04 LTS for Windows Azure

Setting up Ruby, Rails, Nginx, Passenger, PostgreSQL 9 on Ubuntu 12.04 LTS for Windows Azure

Last updated: 12/31/2013

Fix the locale issue

  • Edit /etc/default/locale as sudo.
  • Append LC_ALL="en_US.UTF-8" at the end of the file, save and quit.
  • sudo locale-gen en_US en_US.UTF-8
  • sudo dpkg-reconfigure locales

Install the necessary packages to install rbenv and build Ruby


Keybase proof

I hereby claim:

  • I am terenceponce on github.
  • I am terenceponce ( on keybase.
  • I have a public key ASDrrHc7r8kil2CClC5J7PP00kVX1whnQg4r7pNIquiRIAo

To claim this, I am signing this object:

You can’t perform that action at this time.