Skip to content

Instantly share code, notes, and snippets.

_ = require 'lodash'
path = require 'path'
Botkit = require 'botkit'
mongoStorage = require 'botkit-storage-mongo'
mongoose = require 'mongoose'
express = require 'express'
bodyParser = require 'body-parser'
Promise = require 'bluebird'
mongoose.Promise = Promise
var Botkit, DATABASE_URI, Promise, _, bodyParser, bots, dbConnect, express, mongoStorage, mongoose, path, runIt, setupController, setupModels, setupServer, startRTM, trackBot;
_ = require('lodash');
path = require('path');
Botkit = require('botkit');
mongoStorage = require('botkit-storage-mongo');
export default let mergeByObjectProperty = (mainArray, mergingArray, property) => {
// For every entry in the merging array (smaller)
_.each(mergingArray, (mergingArrayEntry) => {
// Find the corresponding object from arrayOne
var mainArrayEntry = _.find(mainArray, (arr1obj) => {
return arr1obj[property] === mergingArrayEntry[property]
})
javascript:window.location='https://web.archive.org/web/*/'+window.location.href
/**
*
* ListItemCheckbox
*
*/
import React from 'react'
import { ListItem } from 'material-ui/List'
import Checkbox from 'material-ui/Checkbox'
@malonehedges
malonehedges / CAH.js
Created November 28, 2017 16:28
Timing of map, reduce, filter
import Game from '../Game'
import cards from './cards'
export default class CAH extends Game {
static getExpansionsPrettyButDumb () {
return cards
.map((card) => card.expansion)
.filter((expansion, index, arr) => arr.indexOf(expansion) === index)
}
@malonehedges
malonehedges / moodleAutoLogin.js
Created February 6, 2018 21:35
Moodle Auto-Login
// ==UserScript==
// @name Moodle Auto-Login
// @namespace https://moodle.oxy.edu/
// @version 0.1.0
// @description Automatically redirect to the login page if logged out.
// @author Malone Hedges (https://malone.io)
// @match https://moodle.oxy.edu/*
// @grant none
// ==/UserScript==
func distributeViewsEvenly(views: [UIView], axis: NSLayoutConstraint.Axis) -> UIView {
let containerView = UIView()
for (index, view) in views.enumerated() {
let previousView = containerView.subviews.last
let isLastView = index == views.endIndex - 1
containerView.addSubview(view)
view.snp.makeConstraints { make in
@malonehedges
malonehedges / TestVC.swift
Created June 25, 2019 01:17
auto-sizing cells with variable height content
import UIKit
import SnapKit
class TestVC: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.estimatedRowHeight = 58
tableView.rowHeight = UITableView.automaticDimension
func isJailbroken() -> Bool {
#if !targetEnvironment(simulator)
if FileManager.default.fileExists(atPath: "/Applications/Cydia.app") ||
FileManager.default.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
FileManager.default.fileExists(atPath: "/bin/bash") ||
FileManager.default.fileExists(atPath: "/usr/sbin/sshd") ||
FileManager.default.fileExists(atPath: "/etc/apt") ||
FileManager.default.fileExists(atPath: "/private/var/lib/apt/") {
return true
}