Skip to content

Instantly share code, notes, and snippets.

View joemsak's full-sized avatar

Joe Sak joemsak

View GitHub Profile
@joemsak
joemsak / turing-ish.js
Last active August 19, 2017 13:45
turing-ish machine in js
const X_B = {
"B,s1": ["X", "R", "s2"],
"B,s2": ["B", "L", "s3"],
"X,s3": ["B", "R", "s4"],
"B,s4": ["B", "L", "s1"],
}
var tape = ["B", "B"],
head = 0,
state = "s1";
<form action="https://technovationchallenge.org/" method="GET">
<label for="s">Search:</label>
<input name="s" type="text" />
<p>
<input type="submit" value="Search" />
</p>
</form>
@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 April 9, 2017 15:45
Successful update from rails 4.2.8 to 5.0.2, minus capybara-webkit
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"
# 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'
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)
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 January 30, 2017 21:21 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@joemsak
joemsak / ex.js
Last active January 6, 2017 18:52
(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);
<!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;
}