Skip to content

Instantly share code, notes, and snippets.

View tobybot11's full-sized avatar
🎯
Focusing

Tobias Ford tobybot11

🎯
Focusing
View GitHub Profile
@mikermcneil
mikermcneil / sails-policy-best-practices-and-faq.md
Last active July 11, 2019 09:48
FAQ and best practices for using policies in Sails.js

Policies in Sails.js

Policies are additive. Anything you might do with policies, you could just implement in your custom actions directly. But they can make your life a lot easier.

When should I use policies?

Policies can be used like middleware, meaning you can do almost anything you can imagine with them. That said, our experience using Sails to build all sorts of different apps has taught us that policies are best used for one, very specific purpose: preventing access to actions for certain users (or types of users) where those actions are not accessible in the UI. That is, policies are best used like preconditions-- you can use them to take care of edge cases that are only possible by cheating the UI.

For example, imagine you're building an action called changePassword in your UserController. Its job is to take the new password that was provided, encrypt it, then update the database record for the currently-logged-in user to save the new encryped password. When you implement and test

@jqtrde
jqtrde / cleaned.csv
Last active July 29, 2018 01:28
A (shitty) way to transform a list of coordinates in UTM to Long/Lat, using gdaltransform.
longitude latitude
-67.5667647785632 44.9266200808726
-67.5743171887273 44.9225196819941
-67.4990497512917 44.9318714003755
-67.5030556021784 44.9347506234824
-67.5786140266091 44.9183512942229
-67.6303354677011 44.9853731325686
-67.5162499184765 44.9661867740563
-67.5100731884277 44.9701572281092
-68.069497177844 44.8405511153813
@Bouke
Bouke / gist:10454272
Last active September 22, 2023 17:23
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

@sebkopf
sebkopf / gtk_install.md
Last active February 22, 2024 06:10
Installation information for R with GTK on Windows/Mac OS

Installation information for R with GTK+

Windows

Install the newest version of R. Additionally, I highly recommend R-Studio for working with R regularly (but the basic command line will work just fine for most applications). Once R is installed, you can install GTK directly from within R (details below). In short:

  1. From the R command line (e.g. in R-Studio), install the RGtk2 package by running: install.packages("RGtk2", depen=T)
    This might fail with the warning that package ‘RGtk2’ is not available (for R version xxx) if your version of R has been released very recently. If so, just run install.packages("RGtk2", depen=T, type="source") instead to install the RGtk2 package directly from its source code (this might take a few
@patricksurry
patricksurry / README.md
Last active June 17, 2023 09:48 — forked from mbostock/README.md
D3JS quadtree nearest neighbor algorithm

This example adapts mbostock's quadtree brushing demo to find the nearest neighbor (shown red) of a new point (shown yellow). Choose a new point to classify by clicking on the diagram. (An alternative approach for nearest neighbors of the mouse position is D3's Voronoi polygons, but the idea here would extend to rapidly classifying many new points against a base collection of points.)

We use a data-dependent order of recursion through the quadtree

@ogrrd
ogrrd / dnsmasq OS X.md
Last active May 1, 2024 04:43
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@Diasporism
Diasporism / redis_and_resque.mkd
Last active March 13, 2024 08:37
How to configure Redis and Resque for your Rails app.

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

@masak
masak / explanation.md
Last active April 11, 2024 02:50
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <jnthn@jnthn.net>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@denmarkin
denmarkin / resque.rake
Created September 20, 2011 11:02
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."