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
JS_PATH = "app/assets/javascripts/**/*.js"; | |
Dir[JS_PATH].each do |file_name| | |
puts "\n#{file_name}" | |
puts Uglifier.compile(File.read(file_name)) | |
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
promiseBasedConfirmPopup = new Promise((resolve) => { | |
// Show a nice popup and resolve to true/false | |
setTimeout(() => resolve(true), 2000) | |
}) | |
$("a[data-confirm]").on("confirm", function(evt) { | |
// evt.target hold the clicked anchor from where | |
// can be extracted some data to build the popup |
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
# /etc/NetworkManager/dnsmasq.d/hosts.conf | |
address=/dev/127.0.0.1 | |
address=/spk/192.168.1.98 | |
address=/nfx/192.168.1.99 | |
address=/spk2/192.168.1.97 |
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
#!/bin/bash | |
parse_yaml() { | |
local prefix=$2 | |
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') | |
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | |
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | | |
awk -F$fs '{ | |
indent = length($1)/2; | |
vname[indent] = $2; |
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
# Reference: http://guides.rubyonrails.org/v2.3.11/rails_on_rack.html#rackup | |
# | |
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] | |
# Require your environment file to bootstrap Rails | |
require ::File.dirname(__FILE__) + '/config/environment' | |
# Serve static assets from RAILS_ROOT/public directory | |
# use Rails::Rack::Static | |
# Dispatch the request | |
run ActionController::Dispatcher.new |
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
CREATE TABLE messages ( | |
title text, | |
body text, | |
tsv tsvector | |
); | |
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE | |
ON messages FOR EACH ROW EXECUTE PROCEDURE | |
tsvector_update_trigger(tsv, 'english', title, body); |
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
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem. | |
# We want them to make an array, and do it lazily so we don't have to keep the items in memory! | |
class Enumerator | |
def to_json(state) | |
state.depth += 1 | |
string = "[\n" | |
first_item = true | |
self.each do |item| |
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
# | |
# Examples: | |
# color_luminance("#69c", 0); # returns "#6699cc" | |
# color_luminance("6699CC", 0.2); # "#7ab8f5" - 20% lighter | |
# color_luminance("69C", -0.5); # "#334d66" - 50% darker | |
# color_luminance("000", 1); # "#000000" - true black cannot be made lighter! | |
# | |
# based on code from | |
# http://www.sitepoint.com/javascript-generate-lighter-darker-color/ | |
# |
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
## Useful Collections | |
def a_array | |
(1..6).to_a | |
end | |
def a_hash | |
{hello: "world", free: "of charge"} | |
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
#encoding: UTF-8 | |
require 'rubygems' | |
require "pismo" | |
require 'punkt-segmenter' | |
require 'htmlentities' | |
require './markov.rb' | |
CLEAN_TEXT = <<-EOF |