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
// load environment variables from .env file | |
require('dotenv').config(); | |
// load mongoose and connect to db using env variable | |
const mongoose = require('mongoose'); | |
mongoose.connect(process.env.MONGODB_CONNECTION, { useNewUrlParser: true, useUnifiedTopology: true }); | |
// start the node repl | |
const repl = require('repl'); | |
const context = repl.start().context; |
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
export const Utility = { | |
createElement: function(tagName = 'DIV', className, appendTo) { | |
let element = document.createElement(tagName); | |
element.className = className; | |
if(typeof appendTo !== 'undefined'){ | |
appendTo.appendChild(element); | |
} | |
return element; | |
} | |
}; |
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
export class PubSub { | |
constructor (){ | |
this.subscriptions = {}; | |
} | |
subscribe (event, subscriber) { | |
if (typeof this.subscriptions[event] === 'undefined') { | |
this.subscriptions[event] = new Set(); | |
} | |
this.subscriptions[event].add(subscriber); |
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
export class TabControl { | |
constructor(element){ | |
this.element = element; | |
this.element.addEventListener('click', this.handleClick.bind(this)); | |
let firstOption = this.element.querySelector('.tab-option'); | |
firstOption.classList.add('active'); | |
} | |
handleClick(e){ |
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 ActiveRecord::Base | |
def self.import!(record_list) | |
raise ArgumentError 'record_list not an Array of Hashes' unless record_list.is_a?(Array) && record_list.all? {|rec| rec.is_a? Hash } | |
return if record_list.empty? | |
record_list.in_groups_of(1000, false).each do |record_group| | |
key_list, value_list = convert_record_list(record_group) | |
sql = "INSERT INTO #{self.table_name} (#{key_list.join(', ')}) VALUES #{value_list.map {|rec| "(#{rec.join(', ')})" }.join(' ,')}" | |
self.connection.insert_sql(sql) |
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
log/*.log | |
tmp/**/* | |
tmp/* | |
# IntelliJ | |
*.iml | |
.idea | |
# SASS |
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
# use the capital F flag: | |
# -F => same as -f --retry | |
# --retry keep trying to open a file even if it is inaccessible when tail starts or if it becomes inaccessible later | |
tail -F filename |
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
lsb_release -a |
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
# ubuntu: | |
# add this to your ~/.bashrc | |
cmdstamp(){ | |
which $1 | xargs stat -c '%Y' | |
} |
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
body{ | |
// unfortunately we need to enter each of these browser specific selectors | |
::-webkit-input-placeholder { font-style:italic; } | |
:-moz-placeholder { font-style:italic; } | |
::-moz-placeholder { font-style:italic; } | |
:-ms-input-placeholder { font-style:italic; } | |
} |
NewerOlder