Skip to content

Instantly share code, notes, and snippets.

@gregorymostizky
gregorymostizky / gist:2892352
Created June 7, 2012 23:26
PlayerV3 - Message Bus Usage Example
<html>
<head>
<!-- Load Ooyala Player -->
<script src='http://player.ooyala.com/v3/replace_with_player_branding_id'></script>
</head>
<body>
<!-- Player Placement -->
@gregorymostizky
gregorymostizky / gist:2286176
Created April 2, 2012 18:38
PlayerV3 Embed Example
<html>
<head>
<!-- Load Ooyala Player -->
<script src='http://player.ooyala.com/v3/replace_with_player_branding_id'></script>
<!-- Load additional custom modules -->
<script src='/mymodule.js'></script>
</head>
@gregorymostizky
gregorymostizky / gist:2231099
Created March 28, 2012 22:28
Basic Mjolnir Integration
<html>
<head>
<script src='http://player.ooyala.com/player/v2/bootstrap.js?pc=espn_main_player'></script>
</head>
<body>
<div id='playerwrapper' style='width:480px;height:360px;'></div>
@gregorymostizky
gregorymostizky / cook.patch
Created July 25, 2011 20:29
Patch for httrack cookie support
--- httrack-3.44.1/src/htsglobal.h 2011-02-28 16:48:54.000000000 +0200
+++ httrack-3.44.1.fixed/src/htsglobal.h 2011-07-25 23:53:35.000000000 +0300
@@ -487,7 +487,7 @@
// surveillance de la connexion
#define CNXDEBUG 0
// debuggage cookies
-#define DEBUG_COOK 0
+#define DEBUG_COOK 1
// d?buggage hard..
#define HTS_WIDE_DEBUG 0
@gregorymostizky
gregorymostizky / array_nil_compare_hack.rb
Created April 28, 2011 13:45
Allows comparing arrays with nils
#usage
a = [1,2]
b = [1,nil]
a.extend(ArrayWithNilCompareHack)
b.extend(ArrayWithNilCompareHack)
a<=>b # works
# code
module ArrayWithNilCompareHack
def <=>(other)
@gregorymostizky
gregorymostizky / jquery-custom-event.js
Created April 13, 2011 13:44
Bind and trigger custom events for specific element
var self = $('#mydiv');
// define
self.unbind('my-event');
self.bind('my-event', function() {alert('yes')});
// trigger
self.trigger('my-event');
@gregorymostizky
gregorymostizky / jquery-custom-fn.js
Created April 13, 2011 13:42
Adding custom function to JQuery
// definition
$.fn.customFunction = function(options) {
var defaults = {
width: 650,
height: 450
};
var opts = $.extend(defaults, options);
var self = $(this[0]); // if working on first/single element
// functionality here
@gregorymostizky
gregorymostizky / hpricot.rb
Created March 2, 2011 13:39
Simple web scraping in few lines of code
require 'hpricot'
require 'open-uri'
doc = open('http://www.articlesbase.com/investing-articles/tips-for-successful-private-placement-trading-4339216.html') {|f| Hpricot(f)}
doc.search("script").remove
doc.search("style").remove
puts doc.search("body").text
@gregorymostizky
gregorymostizky / commas.rb
Created February 10, 2011 16:35
Insert commas into a number string
str.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/,'\1,').reverse
@gregorymostizky
gregorymostizky / mysql2_connection_pool.rb
Created February 1, 2011 15:06
Simple connection pool for evented mysql2
require 'mysql2'
require 'mysql2/em'
class MysqlConnectionPool
def initialize(conf)
@pool_size = conf[:size] || 10
@connections = []
@query_queue = EM::Queue.new
start_queue conf