Skip to content

Instantly share code, notes, and snippets.

View ethicalmohit's full-sized avatar

Mohit Shukla ethicalmohit

View GitHub Profile
@jsleetw
jsleetw / gist:3446852
Created August 24, 2012 06:51
ntpdate over http proxy
date -s "$(wget --no-cache -S -O /dev/null google.com 2>&1 | sed -n -e '/ *Date: */ {' -e s///p -e q -e '}')"
@shantanuo
shantanuo / mysql_to_big_query.sh
Last active September 14, 2022 07:12
Copy MySQL table to big query. If you need to copy all tables, use the loop given at the end. Exit with error code 3 if blob or text columns are found. The csv files are first copied to google cloud before being imported to big query.
#!/bin/sh
TABLE_SCHEMA=$1
TABLE_NAME=$2
mytime=`date '+%y%m%d%H%M'`
hostname=`hostname | tr 'A-Z' 'a-z'`
file_prefix="trimax$TABLE_NAME$mytime$TABLE_SCHEMA"
bucket_name=$file_prefix
splitat="4000000000"
bulkfiles=200
@Sapphire64
Sapphire64 / supervisord-example.conf
Last active December 11, 2017 11:35 — forked from didip/supervisord-example.conf
Running virtualenv tornado in supervisord, running virtualenv celery in supervisord
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@amitsaha
amitsaha / ls.rst
Last active June 6, 2024 04:01
How does `ls` work?

How does ls work?

I wanted to be really able to explain to a fair amount of detail how does the program :command:`ls` actually work right from the moment you type the command name and hit ENTER. What goes on in user space and and in kernel space? This is my attempt and what I have learned so far on Linux (Fedora 19, 3.x kernel).

How does the shell find the location of 'ls' ?

@denji
denji / nginx-tuning.md
Last active July 20, 2024 17:33
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@morhekil
morhekil / rsync-incremental-backup.sh
Last active May 16, 2024 23:06
Shell script to handle incremental data backups with rsync. Optimised to handle large number of infrequently changing files, by using hard links to save on used disk space. For more details - http://localhost:4000/2014/01/12/automatic-backups-with-ruby-and-linux-shell-part-3/
#!/bin/bash
# Rsync based file backup script, with hard-linking enabled.
#
# Runtime options:
# -n - dry-run; do nothing, just display what is going to happen on a real run
# -v - verbose output; print out what is being backed up
#
# set to your rsync location
@josue
josue / nginx_s3_proxy.conf
Last active March 7, 2023 07:31
Simple Nginx Proxy to S3 Bucket Asset
server {
listen 80;
listen 443 default_server ssl;
ssl on;
ssl_certificate /etc/ssl/certs/myssl.crt;
ssl_certificate_key /etc/ssl/private/myssl.key;
server_name *.example.com;
root /var/www/vhosts/website;
@jasonkeene
jasonkeene / python_scripting.rst
Last active April 21, 2024 20:09
Get started with writing your own python scripts to automate system tasks.

Python for System Admins / Operators

Installing Python

Most Unix/Linux systems come with python pre-installed:

$ python -V
@aloysius-lim
aloysius-lim / spot-request.py
Last active August 31, 2023 21:52
AWS EC2 Spot Requests with Auto Tagging using Boto
import argparse
import json
import time
import boto.ec2
# Set up argument parser
parser = argparse.ArgumentParser(
description='Request AWS EC2 spot instance and tag instance and volumes.',
@gene1wood
gene1wood / 01_get_aws_account_id.py
Last active June 22, 2018 18:44
Method to determine the AWS account ID of your account using boto
#!/usr/bin/env python
import boto, boto.jsonresponse
conn = boto.connect_sts()
e = boto.jsonresponse.Element()
boto.jsonresponse.XmlHandler(e, conn).parse(conn.make_request('GetCallerIdentity',{},'/','POST').read())
e['GetCallerIdentityResponse']['GetCallerIdentityResult']['Account']