Skip to content

Instantly share code, notes, and snippets.

View tastycode's full-sized avatar

Sasha Devol tastycode

  • Elsewhere Labs
  • New Orleans, LA
View GitHub Profile
@tastycode
tastycode / gist:3da4984004f4b4a483c9
Last active August 29, 2015 14:09
Got a whole bunch of `fails` in your ruby codebase?
module FailClassInference
def fail(*args)
return super unless args.first.is_a?(String)
super(infer_exception_class, *args)
end
def raise(*args)
return super unless args.first.is_a?(String)
super(infer_exception_class, *args)
[ [ { title: 'A Camp with No Name (ACWNN)',
description: 'The dead horse is scarce, and we continue to beat it. Come by and sit in the desert in A Camp With No Name, where you will be told that buttered popcorn is a perfectly fantastic snow cone flavor – why would you think otherwise? (Don’t worry – there are “normal” flavors.) Look for us carting around chai or tidying up the playa with our vacuum cleaner.',
Hometown: 'Denver',
URL: 'https://www.facebook.com/pages/A-Camp-with-No-Name/259880375086?ref=hl' },
{ title: 'A Cosmic Carnivale',
description: 'Come and visit a Cosmic Carnival and may your body never miss a beat to the rhythm of this world.',
Hometown: 'Reno',
Contact: 'cosmiccarnivale@gmail.com' },
{ title: 'A Shack of Sit',
description: 'SIT HAPPENS HERE 24×7. Shady chairs & lounges: refresh, rest, meet Burners. Enjoy iced water, healthy snax, lots of activities & WiFi.',
@tastycode
tastycode / common_constants.rb
Created June 23, 2014 17:14
Common Constants
# Share constants between ruby and javascript
# Setup
# (in application.html.erb, or some place to inject javascript)
# MyApplication.constants = #{CommonConstants.to_json};
#
# Usage
# Ruby
# CommonConstants << "Math::PI"
# Javascript
# MyApplication.constants.MATH_PI
@tastycode
tastycode / globals.scss
Last active August 29, 2015 14:02
Common
@import "bourbon";
@import "neat";
@import "mixins";
html, body {
font-family: $font-proxima-nova;
font-size: $fs-root;
}
input, select, textarea {
@tastycode
tastycode / gist:90a8b38e11be463669ba
Created May 1, 2014 18:08
Convert $http promise to regular promise
Article.prototype.comments = function() {
var url = RouteIndex.comments($scope.article.id).relative();
var deferred = $q.defer();
$http.get(url).success(function(comments) {
deferred.resolve(comments);
});
return deferred.promise;
};
//usage
@tastycode
tastycode / angular service
Created April 10, 2014 19:59
Deferred Event Queue Patterns
'use strict';
angular.module('rallyApp')
.service('EventQueue', function EventQueue($q) {
var eventQueues = {};
var listeners = {};
var triggerEvent = function(queue, event, listener) {
queue.splice(queue.indexOf(event), 1);
listener.cb(event);
(ns shorty-clojure.handler
(:use compojure.core)
(:use ring.util.response)
(:require [compojure.handler :as handler]
[compojure.route :as route]
[ring.util.response :as resp]
[ring.middleware.json :as middleware]
[taoensso.carmine :as car :refer (wcar)]))
@tastycode
tastycode / gist:6499842
Created September 9, 2013 18:49
Sniff out references to symbols in perform methods for resque
it "does not have any symbols" do
perform_source = described_class.method(:perform).source
tokens = Ripper.lex(perform_source).map {|token| SyntaxToken.new(token) }
potential_symbols = ObjectRegex.new('symbeg (ident | kw)').all_matches(tokens)
if potential_symbols.any?
potential_symbols.flatten.each do |token|
next unless token.type == :on_symbeg
source_line = perform_source.lines.to_a[token.line - 1]
warn "Potential symbol found on column #{token.col} of #{described_class}#perform"
warn source_line
@tastycode
tastycode / gist:5946805
Created July 8, 2013 07:16
paste this into your address bar
data:text/html, <html><style>* { color: #f00 }</style><body>meow<a href="data:text/html, <html><style> * { color: #00f}</style><body>bark<a href='javascript:window.history.go(-1)'>go</a></body></html>">go</a></body></html>

Ruby/Python Number Conversion Chart

Ruby
From To Python