Skip to content

Instantly share code, notes, and snippets.

@droot
droot / zrevpop.lua
Created June 19, 2011 07:27
ZREVPOP Lua script for redis
val = redis.call('zrange', KEYS[1], -1, -1)
if val then redis.call('zremrangebyrank', KEYS[1], -1, -1) end
return val
@droot
droot / zpop.lua
Created June 19, 2011 07:26
ZPOP Lua script for redis
val = redis.call('zrange', KEYS[1], 0, 0)
if val then redis.call('zremrangebyrank', KEYS[1], 0, 0) end
return val
@droot
droot / color_box_main.html
Created April 6, 2011 16:30
color box main HTML implementation
<div id="config-input" style="padding: 20px;">
<div data-role="fieldcontain">
<label for="text" >Enter Color Value (ex. red, green) :</label>
<input id="color-input" type="text" value="blue"> </input>
</div>
<div data-role="fieldcontain">
<label for="text" >Enter Width of the box (ex. 50, 70) :</label>
<input id="width-input" type="text" value="100"> </input>
</div>
</div>
@droot
droot / color_box_template.html
Created April 6, 2011 16:28
color box template
<script type="text/x-jquery-tmpl" id="color-box-template">
<div style="margin: 20px; float: left;height:${width}px; width: ${width}px; background-color: ${color}; border: 2px solid;">
</div>
</script>
@droot
droot / main_handler.coffee
Created April 6, 2011 16:26
Main Handler
init = ->
cbl = new ColorBoxController
$(document).ready init
@droot
droot / color_box_controller.coffee
Created April 6, 2011 16:26
Color Box Controller Implementation
class ColorBoxController extends Backbone.Controller
initialize: ->
model = new ConfigModel
color_input = new ConfigInputView 'el': $('#config-input'), 'model': model
for x in [1..5]
view = new ColorBoxView {model: model}
$('#color-boxes').append view.render().el
@droot
droot / color_box_view.coffee
Created April 6, 2011 16:25
ColorBox View implementation
class ColorBoxView extends Backbone.View
tagName: 'li'
initialize: ->
@template = $('#color-box-template').template()
@model.bind 'change', @render
@model.view = @
render: =>
$(@el).html $.tmpl @template, @model.toJSON()
return @
@droot
droot / config_input_view.coffee
Created April 6, 2011 16:24
Configuration Input View Implementation
class ConfigInputView extends Backbone.View
initialize: ->
@model.view = @
events:
'keyup #color-input': "updateConfig"
'keyup #width-input': "updateConfig"
updateConfig: (e)=>
@model.set 'color': $('#color-input').val() , 'width': $('#width-input').val(), 'height': $('#width-input').val()
@droot
droot / colorbox_config.coffee
Created April 6, 2011 13:46
Model to represent Colorbox configuration
class ConfigModel extends Backbone.Model
initialize: ->
@set 'color': 'blue', 'width': '100', 'height': '100'
@droot
droot / merchant_integration.js
Created January 4, 2011 13:43
Merchant Integration JS
<script language="javascript" type="text/javascript">
ss_mi.add_products(
[{
prod_page_url: 'http://www.merchant.com/ProductPage1.htm', /*EXAMPLE ONLY*/
prod_img_url: 'http://www.merchant.com/Image1.jpg', /*EXAMPLE ONLY*/
prod_img_url_https:'https://www.merchant.com/Image2.jpg', /*EXAMPLE ONLY*/
prod_title:'Snoozeberry Travel Mug', /*EXAMPLE ONLY*/
prod_currency:'USD', /*EXAMPLE ONLY*/
prod_price:'19.99' /*EXAMPLE ONLY*/
},