Skip to content

Instantly share code, notes, and snippets.

View luvpreetsingh's full-sized avatar
🏠
Working from home

Luvpreet Singh luvpreetsingh

🏠
Working from home
  • GoHighLevel
  • Bengaluru, India
View GitHub Profile
@jfriv
jfriv / prod-rds-snap-restore-to-dev-temp.sh
Created August 16, 2016 20:03
RDS manual snapshot and restore script
#!/bin/bash
# set up some variables
NOW_DATE=$(date '+%Y-%m-%d-%H-%M')
RESTORE_FROM_INSTANCE_ID=<source name>
TARGET_INSTANCE_ID=<target name>
TARGET_INSTANCE_CLASS=db.m4.large
VPC_ID=<vpc subnet id>
NEW_MASTER_PASS=<root password>
@jackl0phty
jackl0phty / ansible_create_aws_sg_and_name_tag
Last active December 3, 2021 14:08
Use Ansible to create AWS Security Group, Create Name tag, Open TCP port 80, and Only Allow Access From Your Home External Ip Address.
---
- hosts: localhost
connection: local
gather_facts: no
vars:
region: us-east-1
route_prefix: /32
tasks:
- command: curl --silent --fail http://checkip.amazonaws.com/
register: external_ip
@rponte
rponte / get-latest-tag-on-git.sh
Last active December 9, 2024 00:27
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@taylorhughes
taylorhughes / run-worker.sh
Last active January 15, 2025 19:33
Celery example with tasks of varying length + -Ofair
# tested with celery[redis]==3.1.17
# to run with default configuration -- tasks will take 14 seconds to complete the 20 tasks in start_all() below
celery worker -A cluster_project.celery_app -Q tester -lINFO --concurrency=4
# to run with -Ofair -- tasks will take 10 seconds to complete
celery worker -A cluster_project.celery_app -Q tester -lINFO --concurrency=4 -Ofair
@afrachioni
afrachioni / timing.c
Created January 27, 2015 00:31
Example of timing using gettimeofday
#include <sys/time.h>
#include <stdio.h>
unsigned long get_time();
int main(int nargs, char **args) {
fprintf (stdout, "The current epoch time / ms: %ld\n", get_time());
long start_time = get_time();
int i;
for (i = 0; i < 1e8; ++i);
@jctosta
jctosta / screen_cheatsheet.markdown
Last active April 28, 2025 11:10
Screen Cheatsheet

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
@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

@bee-keeper
bee-keeper / Django: Programmatically add permissions to groups
Created March 29, 2014 16:57
Django: Programmatically add permissions to groups
content_type = ContentType.objects.get(app_label='', model='')
#get all permssions for this model
perms = Permission.objects.filter(content_type=content_type)
group = Group.objects.get(name='')
for p in perms:
group.permissions.add(perms)
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@FZambia
FZambia / rsyslog.conf
Last active September 29, 2017 01:50
Configuring django to work with rsyslog
# rsyslog v5 configuration file
#### MODULES ####
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
#$ModLoad immark # provides --MARK-- message capability
# Provides UDP syslog reception
$ModLoad imudp