Skip to content

Instantly share code, notes, and snippets.

View bramhaghosh's full-sized avatar

Bramha Ghosh bramhaghosh

  • Google
  • Mountain View, CA
View GitHub Profile
@bramhaghosh
bramhaghosh / gist:4b4a603c4cc50e09da37b54e99bdbad7
Created July 24, 2017 18:31
mulitpart range req response
var mpbody bytes.Buffer
mpw := multipart.NewWriter(&mpbody)
defer mpw.Close()
mpw.SetBoundary(m.boundary)
for _, rng := range ranges {
start, end := rng[0], rng[1]
mimeh := make(textproto.MIMEHeader)
mimeh.Set("Content-Type", m.contentType)
mimeh.Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", start, end, len(m.body)))
@bramhaghosh
bramhaghosh / designer.html
Created December 12, 2014 19:36
designer
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-app.html">
<link rel="import" href="../topeka-elements/topeka-datasource.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@bramhaghosh
bramhaghosh / designer.html
Created December 12, 2014 19:27
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@bramhaghosh
bramhaghosh / my_hopes_and_dreams.rb
Created March 25, 2013 20:46
I wish this worked...
template = Template.create_from_zip_file('my_fancy_template.zip', { :company => current_company,
:account => current_account,
:visibility => true,
:approval_statue = > true})
def current_page
#figure out where we currently are and return it
end
def on(page_class, &block=nil)
page_object = page_class.new
page_object.visit unless page_object.url.match(current_page) #or something...
block.call(page_object) if block
end
@bramhaghosh
bramhaghosh / saucelabs_demo.rb
Created October 11, 2012 17:51
saucelabs demo
require 'pry'
require 'watir-webdriver'
include Selenium
def capabilities
opts = {:platform => :any, :javascript_enabled => true}
capabilities = WebDriver::Remote::Capabilities.ie(opts)
end
def set_up_grid_browser
@bramhaghosh
bramhaghosh / gist:1334453
Created November 2, 2011 18:33
something stupid w/ polymorphic associations
class Deal < ActiveRecord::Base
belongs_to :store
has_many :categories, :as => :categorizable
end
class Store < ActiveRecord::Base
has_many :deals
has_many :coupons
has_many :categories, :as => :categorizable
end
def checkbox(name, identifier)
define_method("#{name}") do
send("#{name}_rendered?")
browser.checkbox(identifier)
end
define_method("check_#{name}") do
send("#{name}_rendered?")
times_retried = 0
begin
browser.checkbox(identifier).set