Skip to content

Instantly share code, notes, and snippets.

Robert Hurst RobertWHurst

Block or report user

Report or block RobertWHurst

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View solution.js
// Given an array, you must increment any duplicate elements until all its elements are unique. In
// addition, the sum of its elements must be the minimum possible within the rules. For example,
// if arr = [3, 2, 1, 2, 7], then arrunique = [3, 2, 1, 4, 7] and its elements sum to a minimal
// value of 3 + 2 + 1 + 4 + 7 = 17.
// Function Description
// Complete the getMinimumUniqueSum function in the editor below to create an array of unique
// elements with a minimal sum. Return the integer sum of the resulting array.
@RobertWHurst
RobertWHurst / toy-rust-emitter.rs
Created Jan 17, 2017
Just messing around with Rust
View toy-rust-emitter.rs
use std::collections::HashMap;
struct Emitter<'a, T> {
handlers: HashMap<&'static str, Vec<Box<Fn(T) + 'a>>>,
}
impl<'a, T> Emitter<'a, T> where
T: Clone {
pub fn new() -> Emitter<'a, T> {
@RobertWHurst
RobertWHurst / recover-files.js
Created Dec 3, 2015
Recover files by extension from a directory
View recover-files.js
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var through = require('through2');
var SOURCE_PATH = '/media/roberthurst/CE543276543260FF';
var DEST_PATH = '/media/roberthurst/478FC40638130E7A/recovered-files';
var MANIFEST_FILE = '/media/roberthurst/478FC40638130E7A/recovered-files.txt';
@RobertWHurst
RobertWHurst / mongoose-soft-remove.js
Created Aug 14, 2015
Mongoose Soft Remove Plugin
View mongoose-soft-remove.js
var Model = require('mongoose').Model;
function softRemove(schema) {
if (!schema.path('isRemoved')) {
schema.add({ isRemoved : { type: Boolean, index: true, default: false } });
}
if (!schema.path('removedAt')) {
View keybase.md

Keybase proof

I hereby claim:

  • I am RobertWHurst on github.
  • I am roberthurst (https://keybase.io/roberthurst) on keybase.
  • I have a public key whose fingerprint is 3361 7376 33B4 EF4C B635 7BA5 1E39 A3EE D59E 2E6F

To claim this, I am signing this object:

@RobertWHurst
RobertWHurst / less2styl.js
Created Jun 1, 2013
Convert less to stylus files. Note that less scoping will not work in stylus as stylus does not have scoping.
View less2styl.js
var fs = require('fs');
function less2stylus(source, mixinNames) {
return source
// @var => $var
.replace(/@([a-zA-Z0-9-_]+)[\s\t]*(:?)[\s\t]*/g, function(str, key, sep) {
// do not convert import or media keywords
if(['import', 'media'].indexOf(key) > -1) { return str; }
@RobertWHurst
RobertWHurst / cookie.js
Created Dec 18, 2012
A simple function for getting and setting cookies. If false is set as a cookie's value, the cookie will be deleted.
View cookie.js
View Spring.js
(function(factory) {
if(typeof define === 'function' && define.amd) {
define(factory);
} else {
window.SpringJS = factory();
window.s = window.SpringJS;
}
})(function() {
You can’t perform that action at this time.