Skip to content

Instantly share code, notes, and snippets.

View gudata's full-sized avatar
🏢
Working from office

gudata

🏢
Working from office
View GitHub Profile
@gudata
gudata / mongo_backup.sh
Created September 25, 2019 08:51 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="mongo18"
MONGO_HOST="172.19.0.2"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/opt/mongo-backup/backups/$APP_NAME"
@gudata
gudata / ns-inet.sh
Created May 19, 2019 16:13 — forked from adohe-zz/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
@gudata
gudata / singleton.go
Created May 19, 2019 16:12 — forked from adohe-zz/singleton.go
Golang singleton implementation
package singleton
import (
"sync"
)
type singleton struct {
}
var instance *singleton
@gudata
gudata / ember-cli-deploy.png
Created August 22, 2017 12:38 — forked from kpfefferle/ember-cli-deploy.png
Deployment Options for Ember with Rails
ember-cli-deploy.png
@gudata
gudata / gist:e623699030b722d11b7f84b050ac8d8d
Created May 19, 2017 14:43 — forked from alphazo/gist:3303282
Clone MiFare cards using chinesse UUID writable cards

libnfc supports UUID writable cards and even has some dedicated tools for them.

However it doesn't work with some of the cards found on eBay that are even simpler to use. Sector 0 is unlocked and can be written without any additional commands. libnfc requires a small patch to get it working.

Following has been tested under ArchLinux with modified libnfc 1.5.1, mfoc 0.10.2 and a SCL3711 dongle.

Patch & recompile libnfc

The patch is fairly simple, open libnfc-1.5.1/utils/nfc-mfclassic.c and comment 2 lines (it was lines 384 and 385 for me):

// Try to write the trailer

@gudata
gudata / system_event.rb
Last active May 4, 2017 10:04
state tracking
state_machine :state, initial: :init do
before_transition any => any do |transition|
@status_before_transition = transition.state_name
end
after_transition any => any do |transition|
log = "#{@status_before_transition} -> #{transition.state_name}"
SystemEvent.create(trackable: transition, description: log, tag: "state_change")
end
@gudata
gudata / discover_s3
Created March 1, 2017 09:33 — forked from yokota-shinsuke/discover_s3
Monitor S3 with Zabbix
#!/usr/bin/ruby
require 'rubygems'
require 'aws-sdk'
require 'optparse'
require 'json'
discovery = {'data' => []}
s3 = AWS::S3.new
s3.buckets.each do |bucket|
@gudata
gudata / chef-swap.rb
Last active February 27, 2017 16:38 — forked from priestjim/chef-noatime-and-swap.rb
A quick (hacky) Chef recipe for adding noatime and a swap file in case a swap file does not exist
# Create and enable a swap file
have_file_swap = false
File.open('/etc/fstab',"r") do |fstab|
fstab.each do |line|
# Tokenize each fstab line with a space separator
tokens = line.split
if tokens[2] == "swap" && tokens[0] !~ /\/dev/
have_file_swap = true
@gudata
gudata / chef-noatime-and-swap.rb
Created February 27, 2017 16:29 — forked from priestjim/chef-noatime-and-swap.rb
A quick (hacky) Chef recipe for adding noatime and a swap file in case a swap file does not exist
# Enable noatime on local ext3/4 & xfs filesystems
fstab = File.open('/etc/fstab',"r")
newlines = Array.new
needremount = Array.new
ihaveswap = false
fstab.each do |line|
# Tokenize each fstab line with a space separator
tokens = line.split
if tokens[2] == "swap"
@gudata
gudata / chef-noatime-and-swap.rb
Created February 27, 2017 16:29 — forked from priestjim/chef-noatime-and-swap.rb
A quick (hacky) Chef recipe for adding noatime and a swap file in case a swap file does not exist
# Enable noatime on local ext3/4 & xfs filesystems
fstab = File.open('/etc/fstab',"r")
newlines = Array.new
needremount = Array.new
ihaveswap = false
fstab.each do |line|
# Tokenize each fstab line with a space separator
tokens = line.split
if tokens[2] == "swap"