Skip to content

Instantly share code, notes, and snippets.

View mxriverlynn's full-sized avatar
🏳️‍🌈
coding while trans

River Lynn Bailey mxriverlynn

🏳️‍🌈
coding while trans
View GitHub Profile
@mxriverlynn
mxriverlynn / 1.js
Last active October 19, 2015 12:48
cleaning up w/ nanit
var mongoose = require("mongoose");
var wascally = require("wascally");
var AWS = require("aws-sdk");
var some = require("some-thing");
var other = require("other-thing");
var more = require("more-things");
mongoose.connect(connStr, function(err)(
if (err) { throw err; }
@mxriverlynn
mxriverlynn / .gitconfig
Created October 6, 2015 19:10
replacing git:// with https:// in git commands
[url "https://github.com/"]
insteadOf = git://github.com/
@mxriverlynn
mxriverlynn / 1.js
Last active October 6, 2015 16:08
hiding backing variable for js props, w/ es6 symbols
var obj = {
get foo(){
return this._foo;
},
set foo(val){
this._foo = val;
}
@mxriverlynn
mxriverlynn / 1.js
Last active September 12, 2017 04:53
when "this" attacks with ES6 arrow functions
FileSchema.method("getDownloadUrl", (cb) => {
var options = {
Bucket: "watchmecode-net",
Key: this.name // <= "this" right here, points at the wrong thing!!!
};
var s3 = new AWS.S3();
s3.getSignedUrl("getObject", options, cb);
})
@mxriverlynn
mxriverlynn / 1.js
Last active April 19, 2018 17:50
sets and array difference in ES6
// initial set created from array
var mySet = new Set([1, 2, 3, 2, 4, 1, 3, 5]);
// add more items
mySet.add(1);
mySet.add(3);
// see what it holds
console.log(mySet); // => Set { 1, 2, 3, 4, 5 }
@mxriverlynn
mxriverlynn / 1.js
Last active September 4, 2015 14:26
how an event becomes a command
$(".edit-button").on("click", (e) => {
someThing.doSomeWork();
});
@mxriverlynn
mxriverlynn / 1.js
Last active September 2, 2015 14:54
code is for coworkers, not compilers
var _0x167d=["\x61","\x62","\x66\x20\x3A\x20","\x67"];function C(_0x5ed1x2){var _0x5ed1x3=0;this[_0x167d[0]]=function(_0x5ed1x4){_0x5ed1x3++;alert(_0x5ed1x2+_0x5ed1x4);};this[_0x167d[1]]=function(){return _0x5ed1x3};}var obj= new C(_0x167d[2]);obj[_0x167d[0]](_0x167d[3]);
@mxriverlynn
mxriverlynn / 1.js
Last active September 1, 2015 01:04
managing javascript this with es6 arrow functions
someFunction( (arg1, arg2, argN) => {
// function body
});
@mxriverlynn
mxriverlynn / 1.js
Last active April 5, 2017 05:48
checking date overlaps
{
start: new Date("January 2, 2003"),
end: new Date("March 12, 2006")
}
@mxriverlynn
mxriverlynn / 1_overlap.js
Last active January 21, 2020 13:59
checking for date range overlap
// 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();