A Pen by James Duncombe on CodePen.
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
# | |
# Read a series of XML documents into a large Array of Hashes | |
# export as JSON | |
# | |
# assign some constants to handle file names / paths | |
PATH_TO_XML_FILES, EXPORT_FILE = ARGV.first, ARGV.last | |
# argument validation | |
raise ArgumentError, 'You must specify a path from which to read the XML documents' if PATH_TO_XML_FILES.nil? |
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 | |
# | |
# Keep the external drive spining! | |
# | |
require 'fileutils' | |
# set the name of the file to write | |
FILE = '/Volumes/Drive_Name/.stayawake' |
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
# Ruby's Array operators | |
a = 1,2,3,4 | |
b = 2,3,4,5 | |
# Intersection | |
a & b # => [2, 3, 4] | |
# Union | |
a | b # => [1, 2, 3, 4, 5] |
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
<?php | |
/** | |
* Handling offsets for articles in series using PHP and MySQL | |
* pages is the table for articles | |
*/ | |
$number_of_articles_per_page = 10; | |
$page = 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
class FakerNames | |
FIRST_NAMES = %w(James Nathan Stew John Ben Adrian Will George) | |
LAST_NAMES = %w(Smith Goddard Duncombe Harrason Mandela James Boom Johnson) | |
attr_accessor :used_combos, :used_first_names, :used_last_names | |
def initialize | |
@used_combos = [] | |
@used_first_names = [] |
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
data = """ | |
Make, Model | |
Jag, X-type | |
Merc, CL | |
""" | |
csv = d3.csv.parse(data) | |
columns = Object.keys(csv[0]) | |
# Create the actual body of the table |
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 escript | |
main(_) -> | |
List = [1,2,3,4,5,6,7,8,9], | |
NewList = reverse(List), | |
io:format(NewList), | |
shifter("This should not pass correctly"), | |
%% list comprehension, because they are cool in Erlang | |
Comprehended = [ N bsl 4 || N <- List, N =/= 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
#!/usr/bin/env ruby | |
require 'optparse' | |
options = {} | |
# Markers | |
JPEG_START = 'ffda' | |
JPEG_END = 'ffd9' | |
OptionParser.new do |opts| |
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
gem install html2haml && gem install haml2slim | |
# then... convert and remove original erb files: | |
find ./app/views -name '*.erb' | xargs -I file sh -c \ | |
'html2haml --erb file | haml2slim > $(echo file | sed 's/erb/slim/') && \ | |
rm file' |
OlderNewer