Skip to content

Instantly share code, notes, and snippets.

@farmanp
farmanp / example.js
Last active July 24, 2016 21:18
Create a variable outside the global scope
// Create a function that holds another function which will "create" a name
function init(){
// Global variable inside the function to be used after initialization
firstName = "FIRST NAME"
// Second function is what returns the global variable
function createName(n){
return n
}
return createName(firstName);
}
@farmanp
farmanp / bill_controller.rb
Last active November 20, 2016 18:38
Secrets
class BillsController < ApplicationController
LEGISCAN_URL = 'https://api.legiscan.com/?key='
LEGISCAN_STATE_SEARCH = 'op=getMasterList&state='
LEGISCAN_STATE_API_CALL = LEGISCAN_URL + LEGISCAN_API_KEY + LEGISCAN_STATE_SEARCH
def show
//ERROR RETUNS NIL ON IMPLICIT STRING CONVERSION FOR API KEY ABOVE
@bill_api = JSON.parse(HTTParty.get('https://api.legiscan.com/?key=77f939393jfjfdcb&op=getBill&id=' + params[:id]).body)
end
@farmanp
farmanp / _form.html.erb
Created December 29, 2016 19:46
Undefined properties from and to
<%= form_for([@post, @comment]) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
<% @comment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
@farmanp
farmanp / comment.rb
Created December 29, 2016 20:58
Posts relationships
class Comment
include Neo4j::ActiveNode
property :name, type: String
property :content, type: String
has_one :out, :post, type: :post
has_one :in, :post, rel_class: :AgreeComment
has_one :in, :post, rel_class: :DisagreeComment
end
@farmanp
farmanp / statements_controller.rb
Created January 4, 2017 15:53
Couldn't find Article by uuid
private
# Use callbacks to share common setup or constraints between actions.
def set_statement
@statement = Statement.find(params[:id])
end
def set_article
@article = Article.find(params[:article_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def statement_params
@farmanp
farmanp / _email_box.js.jsx
Created January 16, 2017 06:56
Finding out how to use Bootstrap in React-Rails
render: function () {
return (
<div bsClass="container-fluid">
<div bsClass="row-fluid">
<div className="email-box">
<EmailList emails={ this.state.emails } />
<hr />
<h2>Add a Email:</h2>
<EmailForm form={ this.state.form } onEmailSubmit={ this.handleEmailSubmit } />
</div>
/* Supporting */
.supporting {
background-color: #1c1c1c;
text-align: center;
padding: 50px 0 80px;
}
.supporting .col {
float: left;
width: 28%;

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@farmanp
farmanp / recipes.txt
Last active January 4, 2018 06:46
List of recipes
https://www.homechef.com/meals/steak-wellington
https://www.homechef.com/meals/adobo-chicken-enchiladas
https://www.homechef.com/meals/brown-butter-shrimp
https://www.homechef.com/meals/umami-burger
https://www.homechef.com/meals/barramundi-beurre-blanc
https://www.homechef.com/meals/acapulco-steak-tacos
https://www.homechef.com/meals/sirloin-steak-pad-thai
https://www.homechef.com/meals/baked-french-onion-penne
https://www.homechef.com/meals/wood-fired-bbq-chicken-pizza
https://www.homechef.com/meals/new-england-cod-chowder
"Beef Demi-Glace => 10,
"Green Onions => 10,
"Red Onion => 11,
"Heavy Whipping Cream => 12,
"Cremini Mushrooms => 12,
"Sirloin Steaks => 16,
"Shallot => 17,
"Boneless Skinless Chicken Breasts => 21,
"Garlic Cloves => 27,
"Butter => 28