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 all = document.getElementsByTagName("*"); | |
var body; | |
for (var i = 0; i < all.length; i++) { | |
if (all[i].tagName === 'BODY') { body = all[i]; break; } | |
} | |
function highlightInElement(element, text){ | |
var elementHtml = element.innerHTML; | |
var tags = []; | |
var tagLocations= []; |
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 FileDownloader { | |
func downloadFile(_ fileType: FileType, from urlString: String, as fileName: String, completion: @escaping (String?) -> Void) -> DownloadTask? { | |
let filePath = LocalStorage.documentPath(of: fileType).appendingPathComponent(fileName) | |
if !LocalStorage.fileExists(of: fileType, fileName: fileName) { | |
#if DEBUG | |
print("file not found at \(filePath)") | |
#endif | |
let storage = Storage.storage() | |
let storageRef = storage.reference(forURL: urlString) |
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
# Tools for making inherited interfaces private to a class. | |
module FigLeaf | |
module Macros | |
# Given a list of classes, modules, strings, and symbols, compile | |
# a combined list of methods. Classes and modules will be queried | |
# for their instance methods; strings and symbols will be treated | |
# as method names. | |
# | |
# Once the list is compiled, make all of the methods private. | |
# |
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 DragNDrop = React.createClass({ | |
// this set the data your want to transfer to the drop-zone | |
handleDragStart: function (e) { | |
e.dataTransfer.setData("text", e.target.id); | |
}, | |
// not important | |
handleDragEnd: function (e) { | |
e.preventDefault(); | |
}, |
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
namespace :cloudinary do | |
task :destroy_all => :environment do | |
public_ids = get_ids | |
until public_ids.size <= 1 | |
public_ids = get_ids | |
result = Cloudinary::Api.delete_resources( | |
public_ids, | |
cloud_name: ENV['cloud_name'], | |
api_key: ENV['api_key'], |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\W\[\033[36;1m\]\$(parse_git_branch)\[\033[00m\] $ " | |
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 Board | |
attr_reader :grid | |
def initialize(grid = nil) | |
@grid = grid || self.class.default_grid | |
end | |
def self.default_grid | |
Array.new(10) { Array.new(10) } | |
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
class Board | |
def initialize(grid = nil) | |
@grid = grid || Array.new(3, Array.new(3)) | |
end | |
def grid | |
@grid.each { |row| p row } | |
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
# I/O Exercises | |
# | |
# * Write a `guessing_game` method. The computer should choose a number between | |
# 1 and 100. Prompt the user to `guess a number`. Each time through a play loop, | |
# get a guess from the user. Print the number guessed and whether it was `too | |
# high` or `too low`. Track the number of guesses the player takes. When the | |
# player guesses the number, print out what the number was and how many guesses | |
# the player needed. | |
# * Write a program that prompts the user for a file name, reads that file, | |
# shuffles the lines, and saves it to the file "{input_name}-shuffled.txt". You |