Skip to content

Instantly share code, notes, and snippets.

@davidebettio
davidebettio / ipip.sh
Created November 19, 2021 11:23 — forked from perfecto25/ipip.sh
IPIP Tunnel Maker
#!/bin/bash
# this script creates an IPIP Tunnel
# tested for CENTOS 6 & 7
#----------------------------
# CONFIGURATION
#----------------------------
# name of tunnel
name='tun_test'
print(`// Backup indexes of : ${db.getName()} : database`);
print(`use ${db.getName()};`);
db.getCollectionNames().forEach(function (collection) {
indexes = db.getCollection(collection).getIndexes().forEach(function (index) {
if (index.name === '_id_') return; // skip defalut _id indexes
const keys = tojsononeline(index.key);
delete index.id; delete index.key; delete index.v; delete index.ns;
print(`db.${collection}.createIndex(${keys}, ${tojsononeline(index)});`);
});
@davidebettio
davidebettio / mongodb-s3-backup.sh
Created December 16, 2019 21:04 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@davidebettio
davidebettio / limt_req_zone_whitelist
Created June 24, 2018 23:04 — forked from skaag/limt_req_zone_whitelist
A way to whitelist certain IP ranges from limit_req_zone in nginx
geo $limited {
default 1;
# Wordpress Jetpack ranges:
192.0.0.0/16 0;
66.135.0.0/16 0;
66.155.0.0/16 0;
76.74.0.0/16 0;
}
# -*- encoding: utf-8 -*-
import sys
#print sys.argv
if len(sys.argv) < 3:
print "usage: %s [start] [end]" % sys.argv[0]
sys.exit(1)
start = int(sys.argv[1])
@davidebettio
davidebettio / RXMoya.swift
Created September 8, 2017 20:11 — forked from dmitryshliugaev/RXMoya.swift
RXMoya renew token
//MARK: – Renew token
public extension ObservableType where E == Response {
/// Tries to refresh auth token on 401, 403 errors and retry the request.
/// If the refresh fails, the signal errors.
public func retryWithAuthIfNeeded() -> Observable<E> {
return catchError { error -> Observable<Response> in
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@davidebettio
davidebettio / 50-i2c_start.rules
Created July 12, 2016 12:26 — forked from Lahorde/0_README.md
Initialize an external I2C RTC module on raspberry using udev and systemd
# /etc/udev/rules.d/rtc-i2c.rules
#
#
#I2C hardware device driver
ACTION=="add", KERNEL=="i2c_bcm2708", SUBSYSTEM=="module", TAG+="systemd"
@davidebettio
davidebettio / rtc-i2c
Created July 12, 2016 12:26 — forked from h0tw1r3/rtc-i2c
Initializing I2C RTC (DS3231) on Raspberry PI bootup with Systemd without recompiling the kernel or devicetree support.
# /etc/conf.d/rtc-i2c
#
# My chip is actually a ds3231n, but ds1307 driver works fine (ds3232 does not!)
#
CHIP="ds1307"
ADDRESS="0x68"
BUS="1"
@davidebettio
davidebettio / .eslintrc
Created March 4, 2016 07:45 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names