Skip to content

Instantly share code, notes, and snippets.

require 'auth/oauth2_authenticator'
class HummingbirdAuthenticator < ::Auth::OAuth2Authenticator
CLIENT_ID = 'removed'
CLIENT_SECRET = 'removed'
def register_middleware(omniauth)
omniauth.provider :hummingbird, CLIENT_ID, CLIENT_SECRET
end
Hummingbird.LibraryEntryView = Ember.View.extend
user: Ember.computed.alias('controller.user')
didInsertElement: ->
@set 'reactComponent', LibraryEntryReactComponent(
content: @get('content')
view: this
)
React.renderComponent @get('reactComponent'), @get('element')
package net.vikhyat.circle;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
public class CircleTest extends TestCase {
private Circle circle;
@Before
require 'rubygems'
require 'bundler/setup'
require 'active_model_serializers'
require 'benchmark'
class BadgeType < Struct.new(:id, :name)
include ActiveModel::SerializerSupport
end
class Badge < Struct.new(:id, :name, :badge_type)
:command WQ wq
:command Wq wq
:command W w
:command Q q
@vikhyat
vikhyat / gist:768c4fe883de83a799a4
Last active August 29, 2015 14:02
HABTM Preload Benchmark
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@vikhyat
vikhyat / gist:5569625983b95f99bcc3
Created June 16, 2014 17:37
Manga Information Importer
require 'nokogiri'
require 'date'
require 'json'
def repair_broken_html(html)
rep = html
# Broken UTF-8 encoding.
rep = rep.unpack('C*').pack('U*') unless rep.valid_encoding?
# "<" is not escaped.
rep = rep.gsub(/<([^A-Za-z!\/])/, '&lt;\1')

Keybase proof

I hereby claim:

  • I am vikhyat on github.
  • I am vikhyat (https://keybase.io/vikhyat) on keybase.
  • I have a public key whose fingerprint is 4B56 5241 D57E 05C0 63FC D8BB 93DF 9F5A 4004 802A

To claim this, I am signing this object:

gets.to_i.times do
n = gets.to_i
puts 4*n*n - 3*n
end
a, b = gets.split.map {|x| x.to_i }
data = []
a.times do
data << gets.split.map {|x| x.to_i }
end
gets.to_i.times do
px, py, qx, qy = gets.split.map {|x| x.to_i }
sum = 0