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
#!/bin/bash | |
echo [$(date +"%Y-%m-%d %H:%M:%S")] Flush temporary files begins. | |
SOURCE="${BASH_SOURCE[0]}" | |
ROOT_DIR=$( dirname "${SOURCE}") | |
CONFIG=${1} |
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
-module(file_utils). | |
-export([recursively_list_dir/1, | |
recursively_list_dir/2, | |
recursively_del_dir/1, | |
dir_traversal/2, | |
dir_traversal/3]). | |
% @type name() = string() | atom() | binary(). |
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 TestCyrillic | |
class << self | |
RUSSIAN_CODES = (1040..1103).to_a + (32..64).to_a + (91..96).to_a + (123..126).to_a + [1025, 1105, 8470] | |
def cyrillic?(string) | |
result = true | |
string.force_encoding("UTF-8").each_char{|c| result &&= RUSSIAN_CODES.include?(c.ord)} | |
result | |
end |
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
window._collect_css = (function(){ | |
var ALPHABET_SIZE=36, classnames={}, | |
data = { | |
total_elements: null, | |
total_classes: null, | |
avg_length: null, | |
compressed_length: null, | |
total_class_length: 0, | |
total_class_count: 0, | |
total_size: 0, |
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
gem 'pry-byebug' | |
GEMFILE | |
system 'bundle' |
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 | |
CONVERT_COMMAND = "ffmpeg -i ':input' -vn -ar 44100 -ac 2 -ab 320 -f mp3 ':output'" | |
def is_audio?(filename) | |
filename =~ /\.(wav|flac|aac)$/ | |
end | |
def extract_name(filename) | |
File.basename(filename, File.extname(filename))+".mp3" |
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 | |
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze | |
changed_files = `git status --porcelain`.split(/\n/) | |
unstaged_files = `git ls-files -m`.split(/\n/) | |
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED } | |
changed_files = changed_files.map { |f| f.split(" ")[1] } |
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 'benchmark' | |
_methods = ("a".."z").to_a | |
module A | |
module B | |
module C | |
module D | |
module E | |
class X |
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
# Activate the gem you are reporting the issue against. | |
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'activerecord', '4.2.0' | |
gem 'pg', '0.18' | |
gem 'pry-byebug' | |
GEMFILE | |
system 'bundle' |
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
# Suppose we updated our hash_data for Paperclip | |
OLD_HASH = ":class/:attachment/:id/:style" | |
NEW_HASH = ":class/:attachment/:id/:style/:updated_at" | |
ACL = :public_read | |
def restore(r) | |
return unless r.file.exists? | |
new_key = r.file.path[1..-1] | |
r.file.options[:hash_data] = OLD_HASH; |
OlderNewer