🏳️🌈
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 sum = values.reduce(function(sum, value){ | |
return sum + value; | |
}, 0); | |
var avg = sum / data.length; |
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
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
#player { | |
width: 100%; | |
height: 100%; | |
} |
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
// this function takes an array of date ranges in this format: | |
// [{ start: Date, end: Date}] | |
// the array is first sorted, and then checked for any overlap | |
function overlap(dateRanges){ | |
var sortedRanges = dateRanges.sort((previous, current) => { | |
// get the start date from previous and current | |
var previousTime = previous.start.getTime(); | |
var currentTime = current.start.getTime(); |
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 | |
echo "Setting $1 bounds to 720p" | |
# 720p is 1280x720. | |
# Bounds is startX, startY, endX, endY. Adjust size from starting position to account for this | |
osascript -e "tell application \"$1\" to set the bounds of the first window to {250, 220, 1530, 940}" | |
# activate the app, to bring it to the front | |
osascript -e "tell application \"$1\" to activate" |
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
<html> | |
<head> | |
<script src="jquery-1.6.1.min.js"></script> | |
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script> | |
<script src="underscore-min.js"></script> | |
<script src="backbone-min.js"></script> | |
<script src="example.js"></script> | |
<style type="text/css"> | |
fieldset { |
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
// my-repl.js | |
var repl = require("repl"); | |
var replServer = repl.start({ | |
prompt: "my-app > ", | |
}); | |
replServer.context.foo = "bar"; |
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 | |
class HomeController extends BaseController { | |
public function showWelcome() | |
{ | |
$users = User::all(); | |
return View::make('hello')->with('users', $users); | |
} |
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 Mongoid | |
module Document | |
def changes_with_embedded | |
field_data = get_previous_changes_for_model(self) | |
embedded_data = get_embedded_document_changes(self) | |
unless embedded_data.empty? | |
field_data.merge embedded_data | |
end | |
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
MedicationView = Backbone.View.extend({ | |
events: { | |
"click #edit": "editMedication" | |
}, | |
editMedication: function(){ | |
var editView = new AddEditView({model: this.model}); | |
editView.render(); | |
} | |
}); |
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
$("#my-audio").on("canplaythrough", function(e){ | |
var seconds = e.currentTarget.duration; | |
var duration = moment.duration(seconds, "seconds"); | |
var time = ""; | |
var hours = duration.hours(); | |
if (hours > 0) { time = hours + ":" ; } | |
time = time + duration.minutes() + ":" + duration.seconds(); | |
$("#duration").text(time); |