Skip to content

Instantly share code, notes, and snippets.

@rbarazi
rbarazi / with_dot_notation.rb
Created June 10, 2010 16:43
Hash with dot notations
class HashWithDotNotation < Hash
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
self.replace(constructor)
else
super(constructor)
end
end
@rbarazi
rbarazi / mobile tags for your '<head>'
Created July 28, 2011 19:25 — forked from chuanxshi/mobile tags for your '<head>'
mobile tags for your '<head>'
<!doctype html>
<!-- Helpful things to keep in your <head/>
// Shi Chuan, https://github.com/shichuan/mobile-html5-boilerplate
-->
<head>
<!-- consider using below meta tags if you want to disable format detection by default -->
<meta name="format-detection" content="telephone=no"/>
<meta name="format-detection" content="address=no"/>
<!-- consider using below link tag if the page is duplicate content of a desktop version -->
@rbarazi
rbarazi / example.html
Created July 28, 2011 19:43 — forked from kylebarrow/example.html
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@rbarazi
rbarazi / css-responsive-images.html
Created August 2, 2011 22:46 — forked from necolas/css-responsive-images.html
Idea for CSS-only responsive images using CSS3 generated content and attr() function. No browser implementation as of May 2011
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS responsive images</title>
<style>
/* Doesn't stop original source image being
downloaded too */
@media (min-device-width:600px) {
<!-- include shared libs here... -->
<script src='./javascripts/lib/jquery-1.6.2.min.js' type='text/javascript'></script>
<script src='./javascripts/lib/underscore-min.js' type='text/javascript'></script>
<!-- include source files here... -->
<script src='./javascripts/pressly.js/pressly.core.js' type='text/javascript'></script>
<script src='./javascripts/pressly.js/pressly.mipmap.js' type='text/javascript'></script>
<script src='./javascripts/pressly.js/pressly.gesture.js' type='text/javascript'></script>
<script src='./javascripts/pressly.js/pressly.swipe.js' type='text/javascript'></script>
<script src='./javascripts/pressly.js/pressly.page.js' type='text/javascript'></script>
(function() {
// Usage:
//
// <script src='http://pressly.com/redirect.js' type='text/javascript'></script>
// <script>Pressly.redirect("http://tablet.domain.com");</script>
//
/* >> Generated code from Issue Config */
// Supported devices to redirect
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
# USAGE:
@rbarazi
rbarazi / how-to-set-up-stress-free-ssl-on-os-x.md
Created January 5, 2016 17:10 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

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

# patch for make ruby error
# % rbenv install 1.8.7-p375
# ...
# ossl_pkey_ec.c:815: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)
# ossl_pkey_ec.c:815: error: (Each undeclared identifier is reported only once
# ossl_pkey_ec.c:815: error: for each function it appears in.)
# make[1]: *** [ossl_pkey_ec.o] error 1
# ...
#
# refs: http://forums.cpanel.net/f5/case-84173-error-installing-ruby-377831.html
@rbarazi
rbarazi / ssl_hack.rb
Created June 15, 2016 13:42 — forked from Papierkorb/ssl_hack.rb
SSL with Capybara and Selenium
# Hack for Capybara to use SSL connections using selenium.
#
### Usage:
# Require this from rails_helper.rb
#
### Steps to generate a SSL certificate on a Linux box:
# 0. Starting from 'Rails.root'
# 1. Generate private key. Type in some password.
# $ openssl genrsa -des3 -out private.key 4096
# 2. Generate certificate sign request