Skip to content

Instantly share code, notes, and snippets.

@bhattisatish
bhattisatish / ff.xsl
Created January 6, 2010 18:49 — forked from lindenb/ff.xsl
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<!--
Author:
Pierre Lindenbaum
http://plindenbaum.blogspot.com
Usage :
#!/usr/bin/ruby
require "rubygems"
require "mongo"
require "json/pure"
require "open-uri"
# db config
db = Mongo::Connection.new.db('friendfeed')
col = db.collection('lifesci')
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info = Struct.new(:name, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/
end
import pickle, pprint, time, os
import httplib
import smtplib
def emailAlert(alert,subject='You have an alert'):
fromaddr = "youremail@domain.com"
toaddrs = "youremail@domain.com"
# Add the From: and To: headers at the start!
function parse_to_date_and_string($parse) {
$exclude = array('i', 'at');
$parse_array = explode(" ", $parse);
$date = array();
$data['text'] = array();
$word_count = count($parse_array);
for($i = 0; $i < $word_count; $i++) {
if (strtotime($parse_array[$i]) > 0 && !in_array($parse_array[$i], $exclude)) {
$date[] = $parse_array[$i];
} else {
// Provides the URL for the location of your executing code for a given class.
ProtectionDomain protectionDomain = MyClass.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
location.toExternalForm();
OR
File codeLoc = new File(protectionDomain.getCodeSource().getLocation().getFile());
<!DOCTYPE html>
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<title>Browser Not Supported</title>
<meta content='text/html;charset=UTF-8' http-equiv='Content-Type'>
<style type='text/css'>
body {
color:#fff;
background:#00f;
text-align:center;
font-family: 'Courier New', Courier, monospace;
@bhattisatish
bhattisatish / gist:1199782
Created September 7, 2011 04:36 — forked from cchandler/gist:939951
glpk model for cloud vs colo costs
#Colo Server costs
set ServerTypes;
set InstanceTypes;
param CoreDemand; #How many cores do we need for a workload
param OurMoney; #The maximum upper-bound of what we're willing to spend
param ColoCostPerU; #How much are we paying per U of colocation
param Months; # How many months do we know we need this hardware
@bhattisatish
bhattisatish / yoursite_extension.rb
Created January 15, 2012 00:59 — forked from teeparham/yoursite_extension.rb
Adding new fields to Spree Variant's additional_fields
# Samples for formatting additional Product fields in Spree Admin
# SelectField: adds a select box with values 1..20
# WideField: adds a standard text box, but with a specified size
# HugeField: adds a text area with a specified number of columns
# OptionField: adds an option field
# CheckField: adds a checkbox field.
Variant.additional_fields += [
{ :name => 'SelectField',
:only => [:product],
@bhattisatish
bhattisatish / track_spree
Created January 18, 2012 07:05
TRACKS CHANGES TO PARTS OF SPREE SINCE A GIVEN COMMIT
#!/usr/bin/env zsh
# 1304046900 TRACKS CHANGES TO PARTS OF SPREE SINCE A GIVEN COMMIT
# To be placed at the root of your app.
old_commit="29e3d4f707bdb047a6fabc2543247139027b06fb"
parts=(
core/app/views