Skip to content

Instantly share code, notes, and snippets.

View adambarthelson's full-sized avatar
🐢

Adam Barthelson adambarthelson

🐢
  • Washington, D.C.
View GitHub Profile
@adambarthelson
adambarthelson / create_hsm_user.sh
Last active August 18, 2019 21:29
An Expect script to automate creating a new user for CloudHSM and activating the HSM initially by updating the admin password
#!/usr/bin/expect -f
set adminpassword [lindex $argv 0]
set newusername [lindex $argv 1]
set newuserpwd [lindex $argv 2]
set timeout 5
spawn /opt/cloudhsm/bin/cloudhsm_mgmt_util /opt/cloudhsm/etc/cloudhsm_mgmt_util.cfg
expect -re "aws-cloudhsm*" {
@adambarthelson
adambarthelson / Dockerfile
Created June 27, 2016 18:47
Example Dockerfile for Angular Fullstack
FROM node
MAINTAINER Adam Barthelson
RUN npm cache clean -f
RUN npm install -g grunt-cli
RUN npm install -g bower
# Install Ruby
ADD http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz /tmp/
@adambarthelson
adambarthelson / api models Locations.js
Created November 25, 2015 02:23 — forked from juanpasolano/api models Locations.js
seed database on sails js
/**
* Locations.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
seedData:[
@adambarthelson
adambarthelson / nmea2gps.js
Created April 23, 2015 19:44
Convert NMEA GPS data from decimal-decimal format to decimal-degree
function NMEA2GPS(num, pole){
var poles = {'N':1,'S':-1,'W':-1,'E':1};
var s = parseFloat(num).toString();
var deg = s.substring(0,2);
var min = s.substring(2);
return (parseInt(deg) + parseFloat(min)/60) * poles[pole];
}
// NMEA2GPS(07721.2060, 'W') => -77.35347
@adambarthelson
adambarthelson / app.js
Last active August 29, 2015 14:06
HTML5 mode with Rails and UI-Router for handling hard GET's
.state('root.index', {
url: '/?redirectTo',
views: {
'content@':{
controller: 'MainCtrl',
templateUrl: 'templates/main.html'
}
},
authenticate: false,
onEnter: function(Redirect, $stateParams){
@adambarthelson
adambarthelson / controller.js
Created August 20, 2014 18:06
Directive to recompile a template if data does change and the one-time binding doesn't do this for you.
$scope.things = [];
$scope.hasChanged = {
mySuperAwesomeStuff: false,
};
$scope.$watch('things', function () {
$scope.hasChanged.mySuperAwesomeStuff = true;
});
@adambarthelson
adambarthelson / example.html
Created August 12, 2014 16:41
Element background image preloader directive
<div bg-preload-src="http://31.media.tumblr.com/tumblr_mac0i9xIMf1rzupqxo1_500.png"></div>
@adambarthelson
adambarthelson / gmap-directive.js
Created June 11, 2014 00:48
Custom Angular directive for geocoding and storing location data from search. http://hpneo.github.io/gmaps/examples/geocoding.html
app.directive("gmap", function() {
return {
restrict: "E",
scope: false,
replace: false,
templateUrl: "map.html",
link: function(scope){
map = new GMaps({
div: '#map',
lat: scope.latitude,
@adambarthelson
adambarthelson / gist:5378971
Last active December 16, 2015 04:39
Automatically highlight color strings in the form of #rrggbb or #rgb when opening a file with Vim, regardless of file types.
@adambarthelson
adambarthelson / gist:5376300
Created April 13, 2013 00:47
Efficiency breakdown of Python files.
import os
import pstats
def testeff(path):
try:
os.remove('rep.prof')
except:
os.system('python -m cProfile -o rep.prof {}'.format(path))
p = pstats.Stats('rep.prof')
p.sort_stats('cumulative').print_stats(10)