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
const fs = require('fs'); | |
const path = require('path'); | |
const childProcess = require('child_process'); | |
const directoryToSearch = process.argv[2]; | |
function getAllFilesInDirectory(dirOrFile) { | |
if (fs.statSync(dirOrFile).isDirectory()) { | |
return Array.prototype.concat(...fs.readdirSync(dirOrFile).map((f) => getAllFilesInDirectory(path.join(dirOrFile, f)))); | |
} else if (dirOrFile.indexOf('.js') !== -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
files: | |
"/tmp/proxy.conf": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
proxy_send_timeout 600; | |
proxy_read_timeout 600; | |
send_timeout 600; |
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
/** | |
* @jsx React.DOM | |
*/ | |
'use strict'; | |
var React = require('react/addons'); | |
var _ = require('lodash'); | |
var $ = require('jquery'); | |
var tokenfield = require('bootstrap-tokenfield')($); |
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
directives.directive('headerSwitcher', function() { | |
return { | |
restrict: 'A', | |
scope: { | |
elementType: '=' | |
}, | |
link: function(scope, element, attrs) { | |
var headers = $(element).children(scope.elementType), | |
headerIndex = -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
import time | |
class keyStore: | |
def __init__(self): | |
self.storage = {} | |
def put(self, key, value): | |
# create array if it doesn't exist | |
if key not in self.storage: | |
self.storage[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
# Take a string as input, such as "a3c4b2", and output a new string of the letters | |
# repeated the specified number of times i.e. "aaabbcccc" | |
def parse(string): | |
newString = "" | |
for i in range(0, len(string)): | |
if(string[i].isalpha()): | |
currentChar = string[i] | |
elif(string[i].isdigit()): | |
for j in range(0, int(string[i])): | |
newString += currentChar |
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
import time | |
class Elevator: | |
def __init__(self): | |
self.state = "stand" | |
self.doors = "open" | |
self.currentFloor = 1 | |
self.requests = [] | |
def requestFloor(self, floorNum): |
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 Node: | |
def __init__(self, val): | |
self.val = val | |
self.leftChild = None | |
self.rightChild = None | |
def get(self): | |
return self.val | |
def set(self, val): |
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
exports.get = function(req, res) { | |
var db = new mongo.Db('downloadr', new mongo.Server("127.0.0.1", 27017, {}), {safe: false, strict: false}); | |
db.open(function (err) { | |
if (err) return handleError(err); | |
var gfs = Grid(db, mongo); | |
gfs | |
// create a read stream from gfs... | |
.createReadStream({ _id: req.param('fileId') }) |
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
app.filter('parseUrl', function() { | |
var //URLs starting with http://, https://, or ftp:// | |
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim, | |
//URLs starting with "www." (without // before it, or it'd re-link the ones done above). | |
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim, | |
//Change email addresses to mailto:: links. | |
replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim; | |
return function(text, target, otherProp) { | |
angular.forEach(text.match(replacePattern1), function(url) { |
NewerOlder