Skip to content

Instantly share code, notes, and snippets.

@Arcolye
Arcolye / app-assets-javascripts-photos.js.coffee
Last active January 26, 2017 22:55
GoToStudy - Photo upload
# Selecting a photo to upload shows photo and filename instantly
placeSelectedPhotoPreview = (input) ->
if input.files && input.files[0]
reader = new FileReader()
reader.readAsDataURL(input.files[0])
reader.onload = (e) ->
$(input).closest('.thumbnail').find('img#photo-preview').attr("src", e.target.result)
$(input).closest('.thumbnail').find("#upload-filename").html(input.files[0].name)
# When a photo is selected
@Arcolye
Arcolye / gengo_translation_api_wrapper.rb
Last active January 26, 2017 22:30
GoToStudy - Gengo Translation API wrapper
# Gengo provides an API to their human translation service
# https://gengo.com/developers/
class GengoTranslation
require 'gengo'
attr_accessor :gengo
def initialize(sandbox: false)
sandbox = true unless Rails.env.production?
@Arcolye
Arcolye / spec-features-agency_office_spec.rb
Last active January 26, 2017 22:12
GoToStudy - Agency Office Spec
require 'spec_helper'
feature "AgencyOffice" do
let(:agency) { create(:agency) }
scenario "makes agency visible on relevant country page" do
visit country_path(agency.offices.first.country)
expect(page).to have_content agency.name
@Arcolye
Arcolye / app-views-lessons-show.html.erb
Last active January 26, 2017 21:43
A Ruby on Rails view. Bootstrap is used semantically, with Bootstrap classes included only in the .scss
<%= pgtitle @lesson %>
<%= description @lesson.meta_description.presence || @lesson.description.presence %>
<div class="lesson">
<%= section class: "lesson-header" do %>
<div class="lesson-icon-wrapper">
<div class="lesson-icon">
<%= image_tag @lesson.icon %>
@Arcolye
Arcolye / gist:407371a24d3c27a33045
Created April 28, 2015 09:17
Morse Code Generator for Sonic Pi
#MORSE CODE GENERATOR
#ENTER A MESSAGE AND PRESS RUN
message = 'Morse code is old'
#CUSTOMIZE
words_per_minute = 18 # slow:12, standard: 18, fast: 24
@u = 1.2 / words_per_minute #One time unit (length of 1 dot)
@looped = true #comment out to play message only once
@pitch = 83