Skip to content

Instantly share code, notes, and snippets.

View tachyons's full-sized avatar
🎯
Focusing

Aboobacker MK tachyons

🎯
Focusing
View GitHub Profile
@tachyons
tachyons / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
rails s --trace |pastebinit
/home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1450:in `complete': invalid option: --trace (OptionParser::InvalidOption)
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1448:in `catch'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1448:in `complete'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1261:in `parse_in_order'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1254:in `catch'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1248:in `order!'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1339:in `permute!'
from /home/user/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/optparse.rb:1360:in `parse!'
=> Booting Mongrel
=> Rails 3.0.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.6/lib/active_support/core_ext/module/introspection.rb:70:in `const_get': uninitialized constant ActionView::ActionViewError (NameError)
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.6/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.6/lib/active_support/core_ext/module/introspection.rb:70:in `each'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.6/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.6/lib/active_support/core_ext/module/introspection.rb:68:in `each'

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@tachyons
tachyons / cricinfo
Last active November 8, 2015 20:07
cricinfo status in your desktop
#!/usr/bin/env ruby
require 'date'
require 'rubygems'
require 'libnotify'
require 'net/http'
require 'rexml/document'
require 'xmlsimple'
def every( time )
Thread.new {
loop do

How To: Authlogic to Devise

Step 1: Migration

  1. bin/rails g migration AuthlogicToDevise
  2. (see the file below for the actual migration, authlogic_to_devise.rb)
  3. bin/rake db:migrate

Step 2: Update Gemfile

  1. gem "devise", "~> 2.2.0"
  2. bundle install
@tachyons
tachyons / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@tachyons
tachyons / goals.md
Last active November 28, 2017 04:21
2016 Wish List

2016 Wish List

  • Technology
    • Programming Languages
      • Haskell
      • Rust
      • Elixir
      • Go
    • DBMS
      • Mongo Db
  • PrestoDb
require 'omniauth-oauth2'
# this OmniAuth-Strategy uses the Keyrock Identity Management
# see http://catalogue.fiware.org/enablers/identity-management-keyrock
# The server url is from the public FIWARE Lab instance.
module OmniAuth
module Strategies
class FilabStrategy < OmniAuth::Strategies::OAuth2
option :name, "filab"
option :client_options, {
@tachyons
tachyons / application.amp.erb
Created April 13, 2016 09:51 — forked from ivanyv/application.amp.erb
Easy Google AMP on Rails
<html>
<head>
<link rel="canonical" href="<%= current_uri_sans_amp %>">
</head>
...
</html>