Skip to content

Instantly share code, notes, and snippets.

@dimroc
dimroc / Gulpfile.js
Last active August 29, 2015 14:22
complete Gulp setup including asset compilation, compression and revisioning, as well as view minification and the discussed automatic application server rebuild and restart
/*
* Copyright (c) 2015 Martin Donath
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"geojson": {
"type": "Polygon",
"coordinates": [
[
[-87.543978, 41.755152],
[-87.543971, 41.755142],
[-87.543961, 41.755132],
[-87.54396, 41.755131],
[-87.543959, 41.75513],
export EC2_HOME="/usr/local/Cellar/ec2-api-tools/1.6.13.0/libexec"
export JAVA_HOME="$(/usr/libexec/java_home)"
export ES_HOME="/usr/local/opt/elasticsearch"
export GOPATH="/Users/dimroc/go_workspace"
export PATH=$PATH:$GOPATH/bin
#Docker
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
@dimroc
dimroc / ngSingleSubmit.js
Created July 31, 2015 18:19
Angular Directive to only allow forms to submit once. Prevents ppl from double or triple clicking a form.
angular.module('ltApp').
directive('ngSingleSubmit', function () {
return function (scope, element, attrs) {
element.bind("submit", function (event) {
element.find("input[type='submit']").prop('disabled', true);
});
};
});
module HasCsvUpload
extend ActiveSupport::Concern
EXCEL_DATE_REGEX = /\A\d{1,2}[\-\/]\d{1,2}[\-\/]\d{2}\Z/
included do
has_attached_file :upload,
storage: :s3,
:path => 'csv_imports/:class/:id/:basename.:extension',
s3_protocol: :https,
s3_credentials: S3Credentials.to_hash
class Admin::ImpersonationsController < AdminController
respond_to :html
def update
current_user.update_attributes(impersonating_params)
respond_with current_user, location: admin_organizations_path
end
def destroy
current_user.update_attributes(impersonating_id: nil)
@dimroc
dimroc / prettyjson
Created September 28, 2015 14:34
Pretty format json files in place
#!/usr/bin/env ruby
require 'tempfile'
puts "Prettying #{ARGV[0]}"
new_file = Tempfile.new('json-pretty')
`cat #{ARGV[0]} | underscore print > #{new_file.path}`
`mv #{new_file.path} #{ARGV[0]}`
@dimroc
dimroc / analytic.rb
Last active April 23, 2023 20:52
Server side mixpanel analytics implementation in ruby. There are other simple devise controllers that are overridden omitted from gist.
# http://blog.mixcel.io/10-ways-to-get-mixpanel-right-the-first-time-yHNlbz-wbcZz7E7PWMXvRg
class Analytic
module Mixpanelable
extend ActiveSupport::Concern
private
def mp_track(event_name, options = {})
mp_track_for_user(current_user, event_name, options)
end
@dimroc
dimroc / webpack.config.js
Last active December 11, 2015 17:13
webpack configured with stylus, sass, and bootstrap
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var stylusLoader = ExtractTextPlugin.extract(
'style-loader',
'css-loader?module&localIdentName=[name]__[local]___[hash:base64:5]' +
'&disableStructuralMinification' +
'!autoprefixer-loader!' +
'stylus-loader?paths=src/app/client/css/&import=./ctx'