Skip to content

Instantly share code, notes, and snippets.

View metacritical's full-sized avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / batman.py
Last active August 29, 2015 14:16 — forked from traeblain/batman.py
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 16 09:30:30 2011
Python Batman Equation
@author: Trae Blain
"""
from __future__ import division
import matplotlib.pyplot as plt
@metacritical
metacritical / batman.py
Last active August 29, 2015 14:16 — forked from traeblain/batman.py
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 16 09:30:30 2011
Python Batman Equation
@author: Trae Blain
"""
from __future__ import division
import matplotlib.pyplot as plt

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@metacritical
metacritical / logicless_brainless_handlebars.js
Last active June 10, 2016 18:32
Logicless and Brainless handlebars implementation in few lines of javascript.
//var template = "<th><td>{{name}}</td><td>{{age}}</td></th>"
//var object = { name: "Pankaj Doharey", age: 30}
//Custom handlebars
var handle_bars = function(template, object){
var keys = []
for (var k in object){
keys.push(k);
};
require 'delegate'
class Base
def foo
"foo"
end
def bar
"bar"
end
end
@metacritical
metacritical / apns.rb
Created October 15, 2013 14:36 — forked from scotttam/apns.rb
require "rubygems"
require "yajl"
require "openssl"
require "socket"
device_token = '39cac56f 986a0e66 3c4fd4f4 68df5598 024d2ca3 8b9f307c 741c180e 9fc30c62'
device_token = device_token.gsub(" ", "")
the_byte_token = [device_token].pack("H*")
file = File.open("ruby_the_byte_token", "wb")
<html>
<head>
<script type="text/javascript">
window.onload = draw;
function draw(){
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
module GeneratePdf
class UserLog
def self.pdf(data)
disp_fields = DisplayField.find_all_by_report_id(yield.id).map do |field|
{ :field_name => field.field_name , :field_label => field.field_label.capitalize }
end
list_field_names = disp_fields.collect{ |names| names[:field_name] }
@metacritical
metacritical / exporter.rb
Created December 5, 2012 10:36 — forked from jcasimir/exporter.rb
Export ActiveRecord Tables to CSV
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end