Skip to content

Instantly share code, notes, and snippets.

View papanito's full-sized avatar

Adrian Wyssmann papanito

View GitHub Profile
@nerdalert
nerdalert / Netfilter-IPTables-Diagrams.md
Last active April 9, 2024 09:18
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@xero
xero / irc.md
Last active May 3, 2024 23:19
irc cheat sheet

IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
  • Leaves the specified channel.
foreach($level in "Machine","User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if($_.Name -match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -split ';' | Select -unique) -join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
@wesleyit
wesleyit / bashprompt.sh
Created November 2, 2014 16:20
Improved bash prompts (I wanna be a oh-my-zsh)
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# From: http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt 02-nov-2014
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@sangeeths
sangeeths / github-to-bitbucket
Created March 10, 2014 15:24
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@styx
styx / glpr.sh
Last active June 20, 2019 05:39
Create Gitlab pull request from command line
#!/bin/bash
BROWSER='google-chrome'
#GITLAB_SECRET=''
ENDPOINT='http://gitlab.activeby.net/api/v3'
PROJECT='activebilling/core'
#curl --header "PRIVATE-TOKEN: xxx" "http://gitlab.activeby.net/api/v3/projects/activebilling%2Fcore" | awk '{match($1,"[0-9]+",a)}END{print a[0]}'
PROJECT_ID=177
ACTION="projects/$PROJECT_ID/merge_requests"
CURRENT_BRANCH=`git branch | grep '^\*' | awk '{ print $2; }'`
@rothgar
rothgar / main.yml
Last active March 8, 2024 07:16
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@rb2k
rb2k / gist:8372402
Last active April 15, 2024 19:30
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
@esycat
esycat / PrettyPrinter.groovy
Last active December 19, 2023 16:20
A simple way to pretty print nested lists and maps in Groovy.
import static groovy.json.JsonOutput.*
def config = ['test': 'lalala']
println prettyPrint(toJson(config))