Skip to content

Instantly share code, notes, and snippets.

View bornfree's full-sized avatar

Harsha bornfree

View GitHub Profile
def add_provider(auth_hash)
unless auth_existing = authorizations.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"])
# No auth exists for this provider. Create one and update keys.
auth = Authorization.create :user => self, :provider => auth_hash["provider"], :uid => auth_hash["uid"]
auth.update_access_keys(auth_hash)
else
# Auth already exists but we need to update the access_tokens
auth_existing.update_access_keys(auth_hash)
end
end
@bornfree
bornfree / rg.rb
Last active December 22, 2015 19:49
Talk to Rescuegroups
Rescuegroups.configure do |config|
config.api_key = "AAAAAA"
end
client = Rescuegroups::Client.new :object_type => "animals", :object_action => "publicSearch"
client.set_fields ['animalName', 'animalID', 'animalBreed']
AnimalsData.limit(500).skip(100).each do |animal|
sleep(0.5) # Please suggest value to put here
client.clear_filters
client.set_filter 'animalStatus', :eq, "Available"
diff --git a/workspace.bzl b/workspace.bzl
index 13f29c1..d0cb97a 100644
--- a/workspace.bzl
+++ b/workspace.bzl
@@ -76,7 +76,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
native.new_http_archive(
name = "gmock_archive",
- url = "https://archive.openswitch.net/gmock-1.7.0.zip",
+ url = "http://52.230.1.181:8000/gmock-1.7.0.zip",
मैं रोजाना नाश्ते के लिए पास्ता खाना खा रहा हूं
@bornfree
bornfree / image_using_font.py
Last active April 22, 2023 19:42
Generate an image using TTF font with PIL (pillow)
from PIL import Image, ImageFont, ImageDraw
FONT_SIZE = 40
MAX_PADDING = 4
font_path = "~/Downloads/Roboto.ttf"
font_object = ImageFont.truetype(font_path, FONT_SIZE) # Font has to be a .ttf file
word = "hello"
fg = "#000000" # black foreground
@bornfree
bornfree / google-fonts-protobuf-to-json.py
Last active November 17, 2018 08:26
Convert Google Fonts Protobuf to JSON
"""
This will read through the Google Fonts repo and make unified JSON of it
"""
import os
import sys
import io
from collections import defaultdict
import json
@bornfree
bornfree / intern_test.md
Last active February 23, 2019 06:17
Technical Intern basic test

The two questions are intended to be short and simple that you can implement each in half-an-hour.

Some rules:

The criteria for evaluation are

  • Efficiency of the code
  • Documentation and formatting
  • Separation of concerns
  • A general taste in programming :)
@bornfree
bornfree / python_assignment.md
Last active April 21, 2022 08:16
Python assignment for internship

You are given a text file as input.

Each line contains 2 words separated by a space. Both the words will have the same number of letters and are lowercase. You are required to find linear and circular distances between them.

Linear is when the alphabet in arranged in a list understood. abc....xyz Circular is when we assume after ...xyz we again have abc.... So in some cases, going in a circle might be shorter.