Skip to content

Instantly share code, notes, and snippets.

@bertomartin
bertomartin / README.md
Created March 3, 2016 20:10 — forked from derwiki/README.md
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@bertomartin
bertomartin / Gemfile
Created January 12, 2016 18:01 — forked from cjbell/Gemfile
Sir Trevor Image Uploader (Rails + Carrierwave)
# Upload gems
gem "carrierwave"
gem "mini_magick", "~> 3.3"
gem "fog", "~> 1.3.1"
@bertomartin
bertomartin / index.html
Created October 16, 2015 03:54 — forked from JavascriptMick/index.html
Thinking in React
<html>
<head>
<script src="bower_components/react/react.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" type="text/css"/>
</head>
<body>
<div class="container" id="container">
</div>
@bertomartin
bertomartin / bigml.py
Last active September 9, 2015 15:52 — forked from alexcasalboni/bigml.py
BigML - Generate a new Prediction with Model and Ensemble
from bigml.api import BigML
from bigml.model import Model
from bigml.ensemble import Ensemble
USE_ENSEMBLE = False
labels = {
'1': 'walking', '2': 'walking upstairs',
'3': 'walking downstairs', '4': 'sitting',
'5': 'standing', '6': 'laying'

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@bertomartin
bertomartin / Vagrantfile
Last active August 28, 2015 16:18 — forked from sailor/Vagrantfile
Vagrantfile for Rails development environment
VAGRANTFILE_API_VERSION = '2'
$install = <<SCRIPT
curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > /usr/local/bin/fig
chmod +x /usr/local/bin/fig
SCRIPT
$build = <<SCRIPT
cd /vagrant
fig build
@bertomartin
bertomartin / test.js
Created February 27, 2015 01:25
Testing Gist
var test = 5;
@bertomartin
bertomartin / _.md
Created February 24, 2015 00:43
sin waves
@bertomartin
bertomartin / Matlab
Last active August 29, 2015 14:14 — forked from gramian/matlab-octave.m
A(1:N+1:end) = 1; % set square N-dim matrix diagonal to one
a = A(A>0); % get all elements greater than zero
d = diag(1./(diag(D))); % invert diagonal matrix
[U,D,V] = svd(A,'econ'); % faster singular value decomposition for non square matrices
[U,d,v] = svds(X,1); % principal POD mode (in U)
@bertomartin
bertomartin / _.md
Last active August 29, 2015 14:14
tributary_test2