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 / lazyAction.js
Last active April 20, 2018 16:55
Dispatching without making an action creator
// types.js
const REPORTER_PENDING_REPORT_UPDATE = "[reporter] pending report update"
// components/PromptHarm.js
import types from 'types'
const PromptHarm = ({dispatch}) => ( <PromptContainer>
<PromptText>Is anyone at risk of immediate harm to themselves or others?</PromptText>
<PromptButtonsContainer>
@tastycode
tastycode / autoActionLazy.jsx
Last active April 20, 2018 16:55
The arduous way
// types.js
const REPORTER_PENDING_REPORT_UPDATE = "[reporter] pending report update"
// actions/reporter.js
export function reporterPendingReportUpdate() {
return { type: types.REPORTER_PENDING_REPORT_UPDATE }
}
// components/PromptHarm.js
import reporterActions from 'actions/reporter'
console.log('i am running the handler binder');
$(function(event) {
console.log('I am running the redirector');
window.location.replace( "https://www.patreon.com/bePatron?c=947861");
});
@tastycode
tastycode / magic_struct.rb
Created January 10, 2017 17:13
MagicStruct
class MagicStruct
include ActiveModel::Validations
def initialize(hashish)
hashish.each do |key, val|
send(:"#{key}=", val)
end
end
def self.required_params(*required_keys)
#!/usr/bin/env ruby
# Usage: echo "lyrics to a song" | ./sweater.rb
# Usage: ./sweater.rb lyrics.txt
# #Input: Billie Jean Lyrics from https://play.google.com/music/preview/Tkjszhsypodj4rcjo3yfxdzfuxi?lyrics=1&utm_source=google&utm_medium=search&utm_campaign=lyrics&pcampaignid=kp-lyrics&u=0#
# #Output
# lee baas roar pike they booty dean sum grey groovy seen
# lye bred dont mined slut glut crew flew jeanne my dram duh dunne
# chew brill trance john huh drawer chin duh crowned
# v fed cai gram uh mun shoo grill vance hon ca lore when huh found
#
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
'("melpa" . "http://melpa.org/packages/")
t)
@tastycode
tastycode / readme.md
Last active November 4, 2019 22:53
Automating Shipping Through Shyp

Shyp is awesome. They can pick up what you have to ship in minutes and take care of all the packing and addressing. Their rates are as cheap as you can get and they have a custom boxing process that minimizes void space.

This would be great for shipping things in bulk if it weren't for them not having an API, or any other means to enter shipments other than their iPhone app.

I had 100 shipments to make, so I threw together this script to automate the creation of the shipments. This isn't for the faint of heart, you'll have to know how to create a transparent HTTPS proxy and hook your iPhone up to it so you can get your session and authorization headers. I'm not going to go into that, but once you get the appropriate headers, put them in a file called shyp.headers. You'll also need to create a shipment manually through the app in order to get a PICKUP_ID. Once you have that, just add your addresses to the array called addresses and run the script. I also didn't want to figure out

@tastycode
tastycode / gist:f66785f3915772b274ef
Created May 27, 2015 17:33
Find misplaced console.logs
> var ConsoleLogOld = console.log;
undefined
> console.log = function() {
... ConsoleLogOld.apply(null, Array.prototype.slice.apply(arguments))
... console.trace()
... }
[Function]
> console.log("meow")
/*
meow
@tastycode
tastycode / gist:daa84c0bbdb8b2c3a63a
Created December 10, 2014 23:37
Render rails templates from javascript handlebars templates
# config/initializers/sprockets.rb
module Sprockets::Helpers::RailsHelper
def view_renderer
@view_renderer ||= begin
view_paths = Rails::Application::Configuration.new(Rails.root).paths["app/views"]
ActionView::Base.new(view_paths).tap do |renderer|
def renderer.method_missing(name, *args)
router = Rails.application.routes.url_helpers
return router.send(name, *args) if router.respond_to?(name)
@tastycode
tastycode / null.rb
Created November 18, 2014 01:21
My null object
class Null
def !@
false
end
def nil?
true
end
def present?