This file contains 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
#!/usr/bin/env ruby | |
repo_path = File.expand_path('../../', __FILE__) | |
cache_file_path = File.join(repo_path, '/tmp/cached_routes') | |
cache_mtime = File.exists?(cache_file_path) && File.mtime(cache_file_path) | |
highest_routes_mtime = (Dir[File.join(repo_path,'/config/routes/**')] + [File.join(repo_path,'config/routes.rb')]).map { |f| File.mtime(f) }.max | |
if !cache_mtime || highest_routes_mtime > cache_mtime | |
`#{File.join(repo_path,'bin/rake')} routes > #{cache_file_path}` | |
puts `cat #{cache_file_path}` | |
else |
This file contains 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
import { ApiResponse } from "apisauce" | |
export type GeneralApiProblem = | |
/** | |
* Times up. | |
*/ | |
| { kind: "timeout"; temporary: true } | |
/** | |
* Cannot connect to the server for some reason. | |
*/ |
This file contains 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
require 'fileutils' | |
require 'csv' | |
class ParallelCSV | |
attr_accessor :threads, :header_line, :opts | |
def initialize(file_path, opts = {}) | |
@threads = opts.delete(:threads) || 2 | |
headers = opts.delete(:headers) | |
if headers |
This file contains 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
<h1>What's all this aboot?</h1> |
This file contains 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 Segment < ActiveRecord::Base | |
extend ActsAsTree::TreeView | |
extend ActsAsTree::TreeWalker | |
belongs_to :course | |
belongs_to :section_type | |
has_and_belongs_to_many :chunks, join_table: 'chunks_segments' | |
acts_as_tree order: 'rank' |
This file contains 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
$('.glyphicon-check').map(function(i, e) { | |
var $e = $(e) | |
var variant = $e.parents('.variant'); | |
var snippet = $e.parents('.snippet'); | |
var variant_name = $(variant).find('.variant-name').val(); | |
var snippet_name = $(snippet).find('.panel-title').clone().children().remove().end().text(); | |
return snippet_name + '--' + variant_name; |
This file contains 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 updateCSS(){ | |
$ss.css({ | |
'border-width' : borderWidthString(), | |
'border-image' : borderImageString() | |
}) | |
} | |
function borderWidthString() { | |
return //whatever builds that string here | |
} |
This file contains 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 win(delay) { | |
if($('#box span').length >= 4) { | |
var clicker = $('span','#box').filter(function(e) { return $(this).data('type') == 'a'; }) | |
clicker.click(); | |
setTimeout(win, delay) | |
} | |
} |
This file contains 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 list_template = _.template('\ | |
<% if(items != null) { %> \ | |
<% split_items = items.split(",") %> \ | |
<% for (var i = 0; i < split_items.length; i++) { %> \ | |
<li><%= split_items[i] %></li> \ | |
<% } %> \ | |
<% } %> \ | |
'); |
This file contains 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 CreateCalendarTable < ActiveRecord::Migration | |
def up | |
create_table :calendar, id: false do |t| | |
t.date "_date" | |
t.string :month_name | |
t.integer :month_no | |
t.integer :year | |
t.integer :day | |
t.integer :day_of_week | |
t.integer :day_of_year |
NewerOlder