Skip to content

Instantly share code, notes, and snippets.

View JoshReedSchramm's full-sized avatar

Josh Schramm JoshReedSchramm

View GitHub Profile
@JoshReedSchramm
JoshReedSchramm / elcap222.txt
Created December 30, 2015 16:14
ruby 2.2.2 w/ openssl on osx el capitan
rvm osx-ssl-certs update all
brew install openssl
brew link openssl --force
<RESTART YOUR CONSOLE>
<If it worked a run of `which openssl` should return /usr/local/bin/openssl>
rvm install ruby-2.2.2 --disable-binary
Then reinstall your gems w/ the new ruby and you should be ok.
### Keybase proof
I hereby claim:
* I am joshreedschramm on github.
* I am joshreedschramm (https://keybase.io/joshreedschramm) on keybase.
* I have a public key whose fingerprint is C487 2D4B DF7B 1769 8C79 273E 2EBB 3A18 7892 0B82
To claim this, I am signing this object:
@JoshReedSchramm
JoshReedSchramm / gist:8693477
Created January 29, 2014 18:05
Setting user data from social
# In registrations controller add a private method
private
def default_data_from_social
defaults = {:user => {}, :identity => {}}
if session["devise.google_data"]
user_data = session["devise.google_data"]
@service = "Google"
elsif session["devise.facebook_data"]
user_data = session["devise.facebook_data"]
@JoshReedSchramm
JoshReedSchramm / collection_check_boxes.html.erb
Created October 27, 2013 00:05
An example of customizing collection_check_boxes in Rails 4. -- I'm working on converting a rails 3.2 app to Rails 4 and noticed that a couple of helpers from simple_form are now in the Rails core. I wanted to move away from dependencies as much as possible including getting rid of simple_form if possible so I went about converting the old view …
<%= f.collection_check_boxes :venue_ids, Venue.all, :id, :name, checked: Venue.all.map(&:id) do |b| %>
<span>
<%= b.check_box %>
<%= b.label %>
</span>
<% end %>
@JoshReedSchramm
JoshReedSchramm / mongo_index_problem
Last active December 26, 2015 11:39
Mongo index issue I can't figure out
I have a pretty complicated query. It looks like this -
db.articles.find({"online_product_id": ObjectId("4e8910b27fd0dc66ef000006"), "draft": { "$ne":true }, "approval_status":"approved", "publish_time": { "$lte":ISODate("2013-10-24T16:45:35.000Z")}, "$or": [{"section":{"$in":["weekender"]}}, {"labels.identifier":{"$in":["weekender", "news local"]}}]}).sort({"publish_time":-1,"rank":1}).hint("article_lookup")
running that on my 2million record articles collection takes about 2 seconds. I added the following index:
{
"v" : 1,
"key" : {
"online_product_id" : 1,
// How you could do what you want in Ember
App.Router.map(function(){
this.resource("userSession", function(){
this.route("new", { path: "/sign-in" });
})
});
// However, any time you create a resource you have an extra layer of routing
// & a model that you may/may not want. In the case of sign-in, which doesn't
/* So I didn't really address the naming piece, but I'd start by going down this route */
public class Task : ActiveRecord
{
public string Name { get; set; }
public int AssignedTo_UserId { get; set; }
public DateTime DueOn { get; set; }
private INotifier _notifier;
@JoshReedSchramm
JoshReedSchramm / gist:3153812
Created July 20, 2012 23:18
Custom data wordpress links
http://wordpress.org/support/topic/limit-search-results-to-custom-post-type
http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
http://www.makeuseof.com/tag/working-custom-database-tables-wordpress/
http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/
@JoshReedSchramm
JoshReedSchramm / tweet_bash
Created August 18, 2011 23:11
Speaking Twitter in Bash
curl http://twitter.com/search.json?q=%23burningriverdevs | grep -Po '"text":.*?[^\\]",' | sed -e 's/\"text\"://g' | sed -e 's/@burningriverdev//g' | sed -e 's/#burningriverdevs/burning\ river\ devs/g'| sed -e 's/RT\ ://g' | sed -e 's/\\\u201C//g' | say
@JoshReedSchramm
JoshReedSchramm / RMagickPrototype.rb
Created April 6, 2011 17:51
Prototyping turning an image into a masked cloud in RMagick
require "RMagick"
class CloudMasker
def initialize(destination)
@src = Magick::Image.new(190, 100)
@dst = Magick::Image.read(destination)[0]
@mask = Magick::Image.read(MASK_PATH)[0]
end
def make_cloud