Skip to content

Instantly share code, notes, and snippets.

array_a=[1,4]
array_b=[2,3]
ary = [array_a,array_b]
a = ary[0]
b = ary[1]
sorted = []
until ary.empty? do
if a.empty?
@AndyDangerous
AndyDangerous / gist:2a885b24452c4a6a31d0
Last active August 29, 2015 14:05
Storing State in Sessions
  1. What's the difference between a cookie and a session?
  • A cookie is a file stored on a user's computer that stores some information (including session information) - a session is something accessible in your app which can store information (albiet a ver small amount of it) - it's a hash
  1. What's serialization and how does it come into play with cookies?
  • Serialization is the encryption that turns your session into a (JSON, for rails) cookie that is sent back with the HTTP response. State in a STATELESS land.
  1. Can a cookie be shared by more than one user? How/why?
  • Nope. The cookie is some encrypted shit that is specific to one computer-server connection
  • I guess, maybe, if the users are on the same computer? That's a dumb idea.
  1. What would it mean to store a shopping cart in a cookie?
  • It would mean that you are storing a bunch of data in/as a hash and then "inflating" it as necessary into your objects
  1. What advantages/disadvantages are there between cookie-stored carts and
1. What does it mean for an application to be multi-tenant?
2. Why would you want to build an application to be multi-tenant?
3. How do you implement multi-tenancy at the data / database level?
4. How do Active Record scopes help keep tenant data segregated?
5. Why is multi-tenancy dangerous from a security/privacy perspective?
1. The app will work well for multiple users using the same stuff.(database and structures)
2. Your app should be able to handle multiple tenancy
3.
4. They are really good at holding tenants to a specific scope.
Dinner Dash:
I used to love endangered animals, but now I just want to enable people to change their lives through micro loans!
Our git problems:
* Big commits
* Not pushing changes often enough
* Communicating what people are working on
  • tomato sauce
  • white flour
  • peaches
  • 'cados
  • banananas
  • chips
  • beans
@AndyDangerous
AndyDangerous / gist:a83b9a9ffc8428081017
Created September 29, 2014 15:07
Oauth original thoughts
Why do we use passwords?
Passwords are an easy way to handle authentication with a modicum of security
What does it mean to say we then trust the service provider?
We asusme that people aren't doing anything nefarious with our passwords and that they instead are storing salted hashes
Why does having more and more systems with logins make the average person less secure?
1. When you submit a file to upload, how does that data get to the server?
-isn't that what the gems are for? It gets sucked up into the chasm that is amazon s3, I think.
2. Why do you think Heroku doesn't allow file uploads?
-because they don't want to deal with that. It would be pretty easy to overwhelm them
3. Both CarrierWave and Paperclip nest the files uploaded into folders, one file
per folder. Why would they do that?
-I'm not sure, but I'd guess it is to help with the indexing or something
4. Why do both libraries need database migrations to add columns to the database?
-They need to be able to know where their stored fils live
5. Have you used CarrierWave, Paperclip, or both? If both, do you have a preference?
What's the job of a controller in Rails?
Web bullshit, duh.
Why do controllers tend to get complicated?
It's super-easy to put a ton of logic in them, it's also easy to engodden* them
What is the Single Reponsibility Principle about?
Making sure your things know what they're supposed to know, nothing more or less.
*to make godlike
1. What jobs have you used a worker for in the past?
* All my geolocation stuff in ColoBackcountry
2. How does a worker know to do its work?
* I call `Worker.perform_async(arg)`
3. What kind of jobs could your current project do in a worker?
* All our social media bullshit.
<iframe width="420" height="315" src="//www.youtube.com/embed/LYN8BXmb6h4" frameborder="0" allowfullscreen></iframe>
There are some tutorials out there to help you get started with pairing the excellent Ember front end javascript framework with a Rails back end API. It can be a little harder to find a condensed source to help you go beyond simple GET requests.
This tutorial is based off of a project called [Snowcial](www.snowcial.pw), and will cover implementing CRUD actions for an existing `groups` model. You can substitute this with whatever model makes sense for your project. Requirements include a working app* with `index` and `show` actions. We will go over adding `create`, `update`, and `destroy`. I'll also assume that you are comfortable with Ruby and Rails already though you'll only need passing understanding of javascript and Ember.
*App, in this case, means a Rails app providing a JSON API and an Ember front end consuming it. [This set of tutorials](http://reefpoints.dockyard.com/2014/05/07/bui