Skip to content

Instantly share code, notes, and snippets.

View sabind's full-sized avatar
👨‍💻
Working on COVID-19 Projects

Dan Sabin sabind

👨‍💻
Working on COVID-19 Projects
  • Owner - FreeThinking IT + REMOVE LLC
  • Los Angeles, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am sabind on github.
  • I am dansabin (https://keybase.io/dansabin) on keybase.
  • I have a public key whose fingerprint is F999 CB15 00DB B34B 4043 90AA 8CE7 D0B7 01E3 543F

To claim this, I am signing this object:

@sabind
sabind / gist:91d8e13ff378767e2640
Last active August 29, 2015 14:24
_.each does not replace async
var _ = require('lodash');
var numbers = [1, 2, 3, 4];
var length = numbers.length;
var hasError = false;
// We write a function that takes longer than the loop to complete.
var blowUp = function (current, callback) {
setTimeout(function() {
if (current === 2) { callback(current) }
@sabind
sabind / README.md
Last active May 5, 2016 18:45
Adding 'grunt test' to SailsJS 0.10.x using grunt and mocha

This is an addition to a full guide on SailsJS + Mocha, but updated for SailsJS 0.10.x

The guide does not belong to me, only this change to support SailsJS 0.10.x using code originally found in the guide written by it's author.

@sabind
sabind / compress.sh
Created May 8, 2014 21:29
Compress files by reading in matchers or names as arg array
shopt -s nullglob
echo "$@"
for f in "$@"
do
echo "$f"
gzip -c "$f" > "$f.gz"
done
@sabind
sabind / ApplicationController.rb
Created February 13, 2014 03:15
Protect your JS variables in case someone copy's your script file. Additionally maintain a high level of re-use relying on application level configurations even in stock javascript files.
class ApplicationHelper
def self.register_js_constant(key, value)
constant = "MyApp.constants.#{key.to_s}=#{value.to_json};"
"<script type=\"text/javascript\">#{constant}</script>"
end
end
@sabind
sabind / Ajax with callback
Last active August 29, 2015 13:56
Wrapping an Ajax call with a callback.
var sendAjaxRequest = function(path, data, callback) {
$.ajax({
url: path,
type: "POST",
data: data,
headers: {accept: 'application/json'}, //optional based what kind of stuff you need
success: function (response) {
// Response is what you get back. it's contents are based on the API you're calling
if (response.success) {
callback(response.success, response.data, response.code);
@sabind
sabind / HelloWorld
Created May 4, 2013 23:30
HelloWorld
println("hello world");