Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Sak joemsak

View GitHub Profile
View missing_from_clause.rb
@events = RegionalPitchEvent.in_region_of(current_ambassador)
.joins(:divisions, :judges, teams: { team_submissions: :submission_scores })
@event.teams.order("teams.name") # OKAY
@event.teams.order("LOWER(teams.name)") # NOT OKAY
#PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
#LINE 1: ..._event_id" = $1 AND (divisions.name = 0) ORDER BY LOWER(team...
^
@joemsak
joemsak / Gemfile
Created Apr 9, 2017
Successful update from rails 4.2.8 to 5.0.2, minus capybara-webkit
View Gemfile
source 'https://rubygems.org'
ruby "~> 2.3.1"
gem 'rails', '~> 5.0'
gem 'puma', '~> 3.8'
gem 'pg', '~> 0.20'
gem 'uglifier', '~> 3.1'
gem 'jquery-rails', "~> 4.3"
gem 'lodash-rails', "~> 4.17"
View Gemfile
# Rubygems v. 2.6.11
# Bundler v. 1.14.6
# NOTE the gems without version constraints -- had to remove the constraints due to dependency resolving
# NOTE ALSO - you don't see two gems I removed because trying to run bundle update wouldn't find compatible dependencies:
# sass-rails
# sinatra (in test group for a network stubbing helper)
source 'https://rubygems.org'
View gist:298e213dd53ae52373ff799b629791cd
rails (~> 5.0.2) was resolved to 5.0.2, which depends on
actionpack (= 5.0.2) was resolved to 5.0.2, which depends on
rack (~> 2.0)
rails (~> 5.0.2) was resolved to 5.0.2, which depends on
sprockets-rails (>= 2.0.0) was resolved to 2.0.0, which depends on
sprockets (~> 2.8) was resolved to 2.8.0, which depends on
rack (~> 1.0)
View subscribe_mentor.rb
class MentorProfile < ActiveRecord::Base
# ... omitted
def enable_searchability
# called ONLY from a consent waiver model being saved and
# when a background check model is saved
update_attributes(searchable: can_enable_searchable?)
if can_enable_searchable?
RegistrationMailer.welcome_mentor(account).deliver_later
@joemsak
joemsak / states_hash.json
Created Jan 30, 2017 — forked from mshafrir/states_hash.json
US states in JSON form
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
View ex.js
(function() {
var forms = document.getElementsByClassName('new_submission_score');
function handleSuccessfulSave(evt, xhr, status, error) {
debugger;
createFlashNotification("success", "Saved!");
}
for (var i = 0; i < forms.length; i++) {
$(forms[i]).on('ajax:success', handleSuccessfulSave);
View google-font.html
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans" rel="stylesheet">
<title>Change the font!!!!!</title>
<style type="text/css">
html {
font-family: 'Nunito Sans', sans-serif;
}
View hello-world.html
<!-- This is a COMMENT in HTML ... it doesn't appear in the browser window. I can use it to explain the parts to you -->
<!-- EXAMPLE HTML BELOW: -->
<!DOCTYPE html>
<!-- DOCTYPE tells the browser what version of HTML you are using. The latest spec is just 'html' -->
<!-- The most basic tag is the HTML tag. It surrounds everything except the DOCTYPE -->
<html>
<head>
View moment-clock.jsx
import React, { Component } from 'react';
import moment from 'moment';
class Clock extends Component {
constructor() {
super()
this.state = {
formattedDateTime: moment().format('MMMM Do YYYY, h:mm:ss a'),
};
}