Skip to content

Instantly share code, notes, and snippets.

View johnrc's full-sized avatar

John Cragun johnrc

View GitHub Profile
@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@oleg-nenashev
oleg-nenashev / jenkins-merge-pr.sh
Last active June 19, 2017 17:02
Simple git merge with squash for Jenkins repos
#!/bin/bash -ex
REPO_NAME=${PWD##*/}
TARGET_ORG="jenkinsci"
#TODO: fetch from GitHib API
#TODO: if no, process parameters correctly
GITHUB_PR_NUMBER=${1}
FROM_USER=${2}
BRANCH=${3}
@tjanczuk
tjanczuk / xpub-xsub.js
Created August 24, 2015 23:59
How to connect 5 publishers with 5 subscribers over TCP using ZeroMQ's XPUB/XSUB proxy
// How to connect 5 publishers with 5 subscribers
// over TCP using ZeroMQ's XPUB/XSUB proxy.
// sub (connect)
// <-8701->
// (bind) xpub <---> xsub (bind)
// <-8700->
// (connect) pub
var zmq = require('zmq');
@reichert621
reichert621 / app.js
Last active May 21, 2019 07:57
Upload files to Amazon S3 with loopback, loopback-component-storage, angular, ng-file-upload
// bower dependency: "ng-file-upload"
// npm dependency: "loopback-component-storage"
'use strict';
angular
.module('app', [
'ngFileUpload'
])
.controller('UploadController', function(Upload) {
@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

@tamitutor
tamitutor / osx-mongodb-rlimits-fix.md
Last active November 8, 2023 09:23
Fix Mongodb "soft rlimits" Warning On Mac OS X (Yosemite)

If you are seeing Mongo soft rlimits warnings in your logs, or a WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 when you login to mongo shell via mongo from the commandline, or any mysterious/unexplained mongo connection errors... follow this how-to exactly and it will resolve the issue for you.

(Source of this how to found at basho/basho_docs#1402)

First file: sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

...containing:

@mosabua
mosabua / init.gradle
Last active January 21, 2020 04:15
init.gradle file for proxying all repositories with Sonatype Nexus
/**
* init.gradle file for development using Nexus as proxy repository
*
* @author Manfred Moser <manfred@simpligility.com
*/
apply plugin:NexusRepositoryPlugin
class NexusRepositoryPlugin implements Plugin<Gradle> {
@renier
renier / mongodb_logrotate.cron
Last active December 14, 2016 09:33
Rotate and compress mongodb logs
#!/bin/bash
# To be used as a cron job weekly (or other) placed under /etc/cron.weekly
# Will use mongodb's logrotate function, but then will compress and keep at most 12 weeks worth of rotate logs.
killall -SIGUSR1 `cat /var/run/mongodb/mongod.pid`
gzip /var/log/mongodb/*20[0-9][0-9]-*-[0-9][0-9]
logs_total=`ls -tx1 /var/log/mongodb/ | egrep "20[0-9][0-9]-.*\.gz" | wc -l`
if [ "$logs_total" -gt 12 ]; then
logs_difference=`expr $logs_total - 12`
logs_to_remove=`ls -tx1 /var/log/mongodb/ | egrep "20[0-9][0-9]-.*\.gz" | tail -n $logs_difference`
for log_file in $logs_to_remove; do
@learncodeacademy
learncodeacademy / gist:ebba574fc3f438c851ae
Created July 24, 2014 14:47
Nginx Node Frontend / Load Balancer / Static Assets Caching
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];