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 UserMediaDetector { | |
// Returns info on all user media devices in successful promise resolve. | |
getDevices() { | |
return new Promise((resolve, reject) => { | |
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) { | |
reject(Error("UserMediaDetector getDevices failed: enumerateDevices is not supported")); | |
return; | |
} |
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
# When ran in the rails console, this code will create and place a | |
# new csv file in the tmp directory of your rails app. Once done, | |
# simply exit the rails console and cd into the tmp directory, cat | |
# the file, and copy its content to a local file. There are probably | |
# better ways to do this but this does work. Be sure to clean up | |
# after yourself by rm'ing the file when youre done with it. | |
require 'csv' | |
zoo = Zoo.find(id) |
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
// In app.js | |
require("./config/routes")(app, passport); | |
// In /config/routes.js | |
module.exports = function(app, passport) { | |
[ | |
"users", | |
"sessions", | |
"stories" | |
].forEach(function (routeName) { |
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
## Bare Bones | |
1. Create your droplet, adding the 1-click install dokku app and giving it at least 1GB memory which Dokku will need for deployment, then navigate to your server's IP and complete the process in the dokku form that will exist there. Also be sure you've followed the guide [here](https://gist.github.com/bradley/0c06d3f2d3c63b097ea5e27befd4beb3) to set up the various accounts youll need on your ubuntu server correctly before proceeding. | |
2. SSH into your droplet: `ssh root@droplet-ip` | |
3. Create your dokku app: `dokku apps:create app-name` | |
4. By default your app is located at myapp.mydomain.com. If you want your app to be accessible via the root domain, then just add the root domain as one of your app's domains. `dokku domains:add app-name mydomain.com`. | |
5. On your local machine, in your project’s Git repository, add your droplet as a remote: `git remote add dokku dokku@droplet-ip:app-name` | |
6. Dokku will start your node app itself by calling `nmp start` but if you want to modify that create a `Procf |
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
= raw (@employee.documents.active.map do |document| | |
- link_to document.display_name, document.file.expiring_url | |
- end.join(", ")) |
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
// =========== Input Field Listener with AJAX Callback ============== | |
function FieldListener(entity){ | |
var t = this; | |
this.typingTimer; // Timer identifier | |
this.doneTypingInterval = 750; // Time in ms. e.g.; 5000 = 5secs | |
this.entity = entity; | |
this.noticeSpan = this.entity.siblings("span"); | |
this.parentForm = entity.parents('form:first'); | |
entity.on("keyup", function(){t.setTimer();}); |
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
/** | |
* The first commented line is your dabblet’s title | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-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
/* requestAnimationFrame polyfill | |
---------------------------------------------------------------------------------*/ | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; | |
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { | |
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; | |
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] | |
|| window[vendors[x]+'CancelRequestAnimationFrame']; |
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
// Playground - noun: a place where people can play | |
import Foundation | |
class Regex { | |
let internalExpression: NSRegularExpression | |
let pattern: String | |
init(_ pattern: String) { | |
self.pattern = pattern |
NewerOlder