Skip to content

Instantly share code, notes, and snippets.

View trak3r's full-sized avatar

Thomas "Teflon Ted" Davis trak3r

View GitHub Profile

Before Chrome makes a cross-domain AJAX call it makes an OPTIONS check like this:

curl \
'https://fubar.com/users/sign_in' \
-X OPTIONS \
-H 'Access-Control-Request-Method: POST' \
-H 'Origin: http://snafu.com' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' \
-H 'Access-Control-Request-Headers: content-type' \
#!/bin/bash
MINUTES=10
#
# this script pulls the last $MINUTES minutes out of the apache logs
# so cron it to run every $MINUTES minutes
#
SERVER_ALIAS=$(hostname -s)
NAMESPACE="Apache"
METRIC_NAME="RequestsPerMinute"
@trak3r
trak3r / README.md
Created April 24, 2013 12:37 — forked from reinh/README.md

Syntax highlight SQL inside Ruby <<-SQL heredocs

Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL. This will also work to embed other syntaxen, e.g., HTML.

Optional PGSQL enhanced syntax:

(requires https://github.com/exu/pgsql.vim)

 syntax include @SQL syntax/pgsql.vim
doing a big activerecord query with a lot of peripheral objects.
adding ".includes" (preloading) speeds it up dramatically by squashing all the
N+1's.
the page then renders fast and spits this out into the logs:
Completed 200 OK in 504ms (Views: 104.2ms | ActiveRecord: 86.0ms)
however, it is then *** 90 SECONDS *** until the page is actually sent down to
root = exports ? this
root.TedTabs ?= {}
TedTabs.activateFirstNestedTabRecursively = (href, depth = 1) ->
if wrapper = $(document).find(href)
#
# activate the first nested tab link
#
if firstTab = wrapper.find("a[data-toggle=\"tab\"]").first()
firstTab.tab "show"
require "net/http"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
#
this works:
%script= raw render 'show.js.coffee'
but it throws this warning:
DEPRECATION WARNING: Passing the format in the template name is deprecated. Please pass render with :formats => [:js] instead.
--
<!DOCTYPE html>
<html>
<head>
<title>xxx</title>
<link href="/assets/bootstrap.css" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/bootstrap-responsive.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery-1.8.2.js" type="text/javascript"></script>
<script src="/assets/bootstrap.js" type="text/javascript"></script>
</head>
<body>
@trak3r
trak3r / gist:3390368
Created August 18, 2012 23:37 — forked from tankchintan/gist:1335220
Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java
sudo rpm -i jdk-7u1-linux-i586.rpm
# Check if the default java version is set to sun jdk
ruby-1.9.2-p0 :001 > nested_arrays = [[1,2,3],4,5,6]
=> [[1, 2, 3], 4, 5, 6]
ruby-1.9.2-p0 :002 > x = nested_arrays.first.first
=> 1
ruby-1.9.2-p0 :003 > x
=> 1
ruby-1.9.2-p0 :004 > (z,), = nested_arrays
=> [[1, 2, 3], 4, 5, 6]
ruby-1.9.2-p0 :005 > z
=> 1