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
def find_best_order(array) | |
array.permutation.map { |p| [p, p.reduce { |a, e| a.to_s + e.to_s }] }.max_by { |e| e[1] }.first | |
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
" add change inside ruby block param list (|x, y|) not currently working | |
" call textobj#user#plugin('rubyblockparam', { | |
" \ 'list': { | |
" \ 'pattern': ['do \|', '\|'], | |
" \ 'select-a': 'aB', | |
" \ 'select-i': 'iB', | |
" \ } | |
" \ }) |
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
# Global Configuration | |
def load_config(file) | |
File.exist?(file) ? YAML.load_file(file) : {} | |
end | |
def rails_platform | |
if Rails.env.production? | |
ENV['PLATFORM'] != 'production' ? :staging : :production | |
else | |
Rails.env.to_sym |
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
find . -type f ! -path "./.git/*" ! -path "./bin/*" -perm 755 -exec chmod 644 {} \; |
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 | |
# encoding: utf-8 | |
require 'benchmark' | |
iterations = 5_000_000 | |
a = 'test a' | |
b = 'test b' | |
c = 'test c' |
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
SELECT DB_NAME() AS DbName, | |
name AS FileName, | |
size/128.0 AS CurrentSizeMB, | |
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB | |
FROM sys.database_files; |
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
SELECT total_worker_time/execution_count AS AvgCPU | |
, total_worker_time AS TotalCPU | |
, total_elapsed_time/execution_count AS AvgDuration | |
, total_elapsed_time AS TotalDuration | |
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads | |
, (total_logical_reads+total_physical_reads) AS TotalReads | |
, execution_count | |
, SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1 | |
, ((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT) | |
ELSE qs.statement_end_offset |
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 | |
# encoding: utf-8 | |
require 'digest' | |
source = ARGV[0] | |
target = ARGV[1] | |
md5 = Digest::MD5 | |
def parse(source, crypt) | |
File.open(source, 'rb').map(&:strip).each_with_object({}) do |line, lines| |
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 bash | |
cat dsl_migrate.txt | cut -d '|' -f 4 | sort | uniq | grep -v 10183 | grep -v 10184 | grep -v 10189 | grep -v 10190 | grep -v 10191 | grep -v 10192 | grep -v 10193 | grep -v 10194 | grep -v 10195 | grep -v 10196 | grep -v 10197 | grep -v 10198 | grep -v 10199 | grep -v 10200 | grep -v 10201 | grep -v 10202 | grep -v 10203 | grep -v 10204 | grep -v 10206 | grep -v 10209 | grep -v 10238 | grep -v 10253 | grep -v 10255 | grep -v 10382 | grep -v 10383 | grep -v 10408 | grep -v 10409 | grep -v 10452 | grep -v 10514 | grep -v 10527 | grep -v 10529 | grep -v 10531 | grep -v 10533 | grep -v 10535 | grep -v 10601 | grep -v 10603 | grep -v 10604 | grep -v 10605 | grep -v 10606 | grep -v 10607 | grep -v 10608 | grep -v 10609 | grep -v 10610 | grep -v 10611 | grep -v 10612 | grep -v 10613 | grep -v 10614 | grep -v 10615 | grep -v 10616 | grep -v 10617 | grep -v 10618 | grep -v 10619 | grep -v 10620 | grep -v 10621 | grep -v 10622 | grep -v 10623 |
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
# api info | |
api = 'dictionaryapi.com/api/v1/references/collegiate/xml' | |
sounds = 'media.merriam-webster.com/soundc11' | |
key = process.env.PRONOUNCE_KEY | |
# xml parser | |
parser = require 'xml2json' | |
# define String#startsWith | |
String::startsWith = (string) -> @.lastIndexOf(string, 0) == 0 |