A Pen by Justin Herrick on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compress_before_seeing_avdis_answer(str) | |
| result = str.chars.chunk(&:to_s).map { |char, chars| "#{char}#{chars.length}" }.join | |
| return str if result.length > str.length | |
| result | |
| end | |
| def compress(str) | |
| [ | |
| str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| # Prevent CSRF attacks by raising an exception. | |
| # For APIs, you may want to use :null_session instead. | |
| protect_from_forgery with: :exception | |
| rescue_from NoMethodError, with: :try_to_inflect | |
| def try_to_inflect(err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debugAll() { | |
| [].forEach.call($$('*'), function(a) { | |
| function cr() { return 0|(Math.random() * 255); }; | |
| a.style.outline = '2px solid rgba(' + [cr(), cr(), cr()].join(',') + ', 0.44)'; | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp'); | |
| var sass = require('gulp-sass'); | |
| var connect = require('gulp-connect'); | |
| var jshint = require('gulp-jshint'); | |
| var stylish = require('jshint-stylish'); | |
| gulp.task('lint', function () { | |
| return gulp.src('./app/scripts/*.js') | |
| .pipe(jshint()) | |
| .pipe(jshint.reporter('jshint-stylish')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| var gulp = require('gulp'); | |
| var sass = require('gulp-sass'); | |
| var watch = require('gulp-watch'); | |
| gulp.task('default', function () { | |
| gulp.src('app/styles/*.scss') | |
| .pipe(watch('app/styles/*.scss', function(files) { | |
| return files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Kernel | |
| def c(*) | |
| self | |
| end | |
| def show(&block) | |
| def c(*args) puts args, self; end | |
| block.call | |
| def c(*) self; end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= render :layout => 'shared/content_container' do %> | |
| <% render :layout => 'shared/record_grid', :locals => { records: @grid_things } do |thing| %> | |
| <%= render partial: "grid_thing", locals: { grid_thing: thing} %> | |
| <% end %> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns problem1.core) | |
| (defn- real-numbers-below [x] (range 1 x)) | |
| (defn- multiple-of [x num] (zero? (mod x num)) | |
| (defn- multiple-of-three [x] (multiple-of x 3)) | |
| (defn- multiple-of-five [x] (multiple-of x 5)) | |
| (defn multiple-of-three-or-five [x] | |
| (or (multiple-of-three x) | |
| (multiple-of-five x))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def timer_start(picker) | |
| respond_with(time_entry_from_picker(picker)) | |
| end | |
| private def time_entry_from_picker(picker) | |
| return picker.time_entires.create unless picker.time_entries.last.running? || picker.time_entries.present? | |
| picker.time_entries.last | |
| end |