Skip to content

Instantly share code, notes, and snippets.

View srayhan's full-sized avatar

Syed Rayhan srayhan

View GitHub Profile
@srayhan
srayhan / gchart
Last active August 29, 2015 14:08
Basic Google Chart Wrapper in Coffee Script
class @Chart
constructor: (@data, @options) ->
google.setOnLoadCallback(this.drawCharts)
drawCharts: =>
table = google.visualization.arrayToDataTable(@data)
options = $.extend(true, {
title: 'Weekly Trends',
explorer: { axis: 'horizontal' },
legend: 'top',
@srayhan
srayhan / gist:10760944
Created April 15, 2014 19:11
Update Random Rows in a Table based on a Join Condition (PostgreSQL)
UPDATE table1 SET table1.col1 = 'some value' WHERE id IN (SELECT table1.id FROM table1, table2 WHERE table1.table2_id = table2.id and table2.colm2 = <some value> ORDER BY RANDOM() LIMIT 20
@srayhan
srayhan / effective-logging.rb
Created August 19, 2011 18:14
Effective logging example
#This is an example code showing a good mix of 4 levels (error, warn, info, and debug) of log messages
#follow the comments to understand the motivation behind each log messages
#please ignore the business logic or coding style, this is only meant to showcase logging only...:-)
#Language used is Ruby
def descope_multiple
begin
logger.debug("entering debug_multiple()...")
wis_to_descope = @project.work_items.find(params[:id])
@wis_descoped = []
@wis_not_descoped = []