Skip to content

Instantly share code, notes, and snippets.

View imouaddine's full-sized avatar

Imad Mouaddine imouaddine

  • Measured
  • Casablanca
View GitHub Profile
@imouaddine
imouaddine / Quick sort
Created January 6, 2015 16:33
Quick sort
def partition(a,p,r)
q = 0
pivot = a[r]
if p < r
(0).upto(r-1) do |j|
if a[j] < pivot
a[q],a[j] = a[j],a[q]
q += 1
end
end
csv do
column 'credit id' do |credit|
credit.id.to_s
end
column "account id" do |credit|
credit.account_id.to_s
end
column('enterprise') { |c| c.account && (c.account.enterprise? ? 'yes' : '') || '' }
column "client id" do |credit|
credit.user && credit.user.id.to_s || 'no user'
require "net/http"
uri = URI.parse('https://tlstest.paypal.com')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
begin
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
puts response.body
require 'google/apis/calendar_v3'
class GoogleCalendarController < ApplicationController
def redirect
client = Signet::OAuth2::Client.new(client_options)
redirect_to client.authorization_uri.to_s
end
def fetch_events(start, end, timezone)
Rails.cache.fetch(cache_key, expires_in: 1.hour.from_now) do
GoogleClient.fetch_events
end
end
def cache_key
[
start,
end,