Skip to content

Instantly share code, notes, and snippets.

View Dzhan85's full-sized avatar

Atadzhan Dzhan85

View GitHub Profile
@buchireddy
buchireddy / modify_sudoers_for_requiretty.sh
Created October 23, 2015 23:45
Shell script to modify the /etc/sudoers file and give sudo permissions for a user and also to turn requiretty off.
# Take a backup of sudoers file and change the backup file.
sudo cp /etc/sudoers /tmp/sudoers.bak
sudo echo "$USER ALL=(ALL) NOPASSWD:ALL
Defaults:$USER !requiretty
" >> /tmp/sudoers.bak
# Check syntax of the backup file to make sure it is correct.
sudo visudo -cf /tmp/sudoers.bak
if [ $? -eq 0 ]; then
# Replace the sudoers file with the new only if syntax is correct.
@bhameyie
bhameyie / haproxy.cfg
Last active December 17, 2024 12:48
Sample haproxy config
##based on Mesosphere Marathon's servicerouter.py haproxy config
global
daemon
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
tune.ssl.default-dh-param 2048
defaults
@mtchavez
mtchavez / disk-check.json
Last active September 27, 2020 17:56
Consul Nagios Example Checks
{
"check": {
"id": "check-disk",
"name": "check-disk",
"script": "/usr/lib/nagios/plugins/check_disk -w 30% -c 5%",
"interval": "1m"
}
}
@heyalexej
heyalexej / gsm-setup.md
Last active June 30, 2024 10:23
SIM Card Management Through GSM Modem On Linux

SIM Card Management Over GSM Modem

A small guide on how to send and receive USSD codes on Linux

I am using the built in GSM (UMTS) modem of my Thinkpad X1 extensively because I am often in places with flaky internet connections. I connect through the standard Network Manager on Ubuntu and everything works fine. There was one major annoyance though. Every time I wanted to top up the SIM balance or book a new package, I needed a phone to send and receive USSD codes. So I took some time to figure out how to do it from the shell. I wrote this down as a help for others and a reminder for myself. Without further ado...

First intsall gammu and picocom.

~  sudo apt-get install -y gammu picocom
@soheilhy
soheilhy / nginxproxy.md
Last active April 11, 2025 06:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

from math import gcd #for gcd function (or easily implementable to avoid import)
import random #for random elements drawing in RecoverPrimeFactors
def failFunction():
print("Prime factors not found")
def outputPrimes(a, n):
p = gcd(a, n)
q = int(n // p)
if p > q:
@JeffreyWay
JeffreyWay / install.sh
Last active July 26, 2023 13:16
Super-fast LAMP + 5.5 install script.
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug
@niksumeiko
niksumeiko / git.migrate
Last active April 10, 2025 01:10
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@PierreZ
PierreZ / Cheatsheet
Last active November 29, 2023 10:49
CISCO Cheat sheet
#configuration of router
conf t
hostname ""
enable secret ""
line console 0
logging synchronous
password ""
login
exit
line vty 0 4
@elliottb
elliottb / fabfile.py
Created December 2, 2013 02:26
Example Python Fabric deployment script. Deploys code from a deployment box to a remote host. Usage from command line on the deployment box: fab deploy.
from fabric.api import local, run, env, put
import os, time
# remote ssh credentials
env.hosts = ['10.1.1.25']
env.user = 'deploy'
env.password = 'XXXXXXXX' #ssh password for user
# or, specify path to server public key here:
# env.key_filename = ''