Skip to content

Instantly share code, notes, and snippets.

View johnculviner's full-sized avatar
💻
Coding, duh

John Culviner johnculviner

💻
Coding, duh
View GitHub Profile
@ffMathy
ffMathy / MongoDB_Median.js
Created August 27, 2019 13:06
Median in MongoDB
db.Transactions.aggregate([
{
"$group": {
"_id": null,
"count": {
"$sum": 1
},
"values": {
"$push": "$INSERT_VALUE_TO_GET_MEDIAN_OF_HERE"
}
@arghav
arghav / Axios.js
Last active August 14, 2021 10:49
React context API with Axios
import * as React from 'react';
import axios from 'axios';
import isEqual from 'lodash.isequal';
class Axios extends React.Component {
constructor(props) {
super(props);
// NOTE: Do not use this.context as React uses it internally
this.axiosContext = React.createContext(this.value);
@drozzy
drozzy / README.md
Last active March 4, 2021 16:31
Docker Compose example of Logspout and OKLog

This is an example of how to automatically log all the messages from docker containers. Logspout listens to containers and automatically routes the logs to OKLog.

To run the example simply issue:

docker-compose up -d

command. The test service here is simply to genereate a "Hello World" message. You would replace this with other services that are in your compose files.

You can browse UI here (there seem to be some issues with UI here, I'm not getting very consistent behavior):

@jonathanconway
jonathanconway / docker-nuke
Last active June 16, 2022 19:59
Nuke all docker images and containers ☢️
#!/bin/bash
docker rm --force $(docker ps --all -q)
docker rmi --force $(docker images --all -q)
@listochkin
listochkin / node-command-line-options.txt
Created April 17, 2014 11:00
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@jeffjohnson9046
jeffjohnson9046 / title-case-filter.js
Created March 26, 2014 18:22
A title-case filter for AngularJs
// Came from the comments here: https://gist.github.com/maruf-nc/5625869
app.filter('titlecase', function() {
return function (input) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
input = input.toLowerCase();
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) {
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&