Skip to content

Instantly share code, notes, and snippets.

View cschmidt's full-sized avatar

Carl Schmidt cschmidt

View GitHub Profile
@cschmidt
cschmidt / install-java
Created September 1, 2016 02:43
Automatically install Oracle Java on Ubuntu
# make sure 'add-apt-repository' is installed
sudo apt-get install -y software-properties-common
# accept the Oracle license agreement
echo debconf shared/accepted-oracle-license-v1-1 \
select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 \
seen true | sudo debconf-set-selections
# add the PPA for Oracle Java
@cschmidt
cschmidt / lambda_node_spawn_test.js
Created March 8, 2016 00:57
Test which version of Node.js is running under AWS Lambda and report if child_process.spawnSync is defined
const child_process = require('child_process');
exports.handler = function(event, context) {
var results = {
version: process.version,
spawn: typeof child_process.spawn,
spawnSync: typeof child_process.spawnSync
};
context.succeed(results);
};
@cschmidt
cschmidt / gist:4577035
Last active December 11, 2015 08:58
Use the MaxMind GeoIP Javascript API to assign the country to a hidden form field
<script src="http://j.maxmind.com/app/country.js" charset="ISO-8859-1" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#country').val(geoip_country_code());
});
</script>
@cschmidt
cschmidt / browser_detect.html
Created April 2, 2012 17:27
jQuery-dependent code to detect browser type and OS, and populate a hidden field named "user_agent". BrowserDetect code from http://snipplr.com/view.php?codeview&id=63137.
<script>
(function () {
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
@cschmidt
cschmidt / mobile-meta.html
Created July 7, 2011 06:05
Typical mobile meta tag
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@cschmidt
cschmidt / unbounce-adwords-gclid.js
Created October 21, 2010 20:37
How to pass the Google Adwords gclid parameter onto your form confirmation page
<script>
<!--
(function() {
function getQueryParam(paramName) {
var query = window.location.search;
var paramValue = null;
var pos = query.indexOf(paramName + '=');
if (pos > -1) {
var start = pos + paramName.length + 1;
var end = query.indexOf('&', start);