Skip to content

Instantly share code, notes, and snippets.

module Rack
# Redirects to correct domain
class RedirectToDomain
HOST = 'example.com'
def initialize(app)
@app = app
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html' http-equiv='Content-Type' />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript">
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var field1 = $("input[name='field1']");
var field2 = $("input[name='field2']");
field2.attr('maxlength', field1.attr('maxlength'));
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
module MyApp
class Application < Rails::Application
config.encoding = "utf-8"
class ShopRoutesConstraint
def self.matches?(request)
! ADMIN_DOMAIN_NAMES.include?(request.host)
end
end
class AdminRoutesConstraint
def self.matches?(request)
ADMIN_DOMAIN_NAMES.include?(request.host)
end
misza@localhost$ git push heroku master
! App git repo is being migrated. Please try again later.
fatal: The remote end hung up unexpectedly
@misza222
misza222 / gist:3912728
Created October 18, 2012 15:54
US state names and abbreviations regexp
(AL|Alabama|AK|Alaska|AZ|Arizona|AR|Arkansas|CA|California|CO|Colorado|CT|Connecticut|DE|Deleware|FL|Florida|GA|Georgia|HI|Hawaii|ID|Idaho|IL|Illinois|IN|Indiana|IA|Iowa|KS|Kansas|KY|Kentucky|LA|Louisiana|ME|Maine|MD|Maryland|MA|Massachusetts|MI|Michigan|MN|Minnesota|MS|Mississippi|MO|Missouri|MT|Montana|NE|Nebraska|NV|Nevada|NH|New Hampshire|NJ|New Jersey|NM|New Mexico|NY|New York|NC|North Carolina|ND|North Dakota|OH|Ohio|OK|Oklahoma|OR|Oregon|PA|Pennsylvania|RI|Rhode Island|SC|South Carolina|SD|South Dakota|TN|Tennessee|TX|Texas|UT|Utah|VT|Vermont|VA|Virginia|WA|Washington|WV|West Virginia|WI|Wisconsin|WY|Wyoming|AS|American Samoa|DC|District Columbia|District of Columbia|GU|Guam|MP|Northern Mariana Islands|PR|Puerto Rico|VI|United States Virgin Islands|Virgin Islands)
@misza222
misza222 / digital_read_serial.c
Created March 1, 2014 17:33
Arduino DigitalReadSerial
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
Parsing recipes: 100% |#############################################################| Time: 00:00:55
Parsing of 885 .bb files complete (0 cached, 885 parsed). 1227 targets, 44 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.20.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "Ubuntu-12.04"
TARGET_SYS = "i586-poky-linux"
MACHINE = "clanton"
@misza222
misza222 / digital_read_serial.py
Created March 3, 2014 11:58
Digital Read Serial - Intel Galileo example in python
# This is a simple example of interacting with digital input of Intel Galileo board
# See http://arduino.cc/en/Tutorial/DigitalReadSerial
# and http://www.itsudo.com/galileo/2014/03/01/reading-digital-input-from-galileo-via-sysfs.html
import os
import time
button_gpio = 17 # maps to digital PIN5 on the board
# Export gpio port so we can interact with it