Skip to content

Instantly share code, notes, and snippets.

View mjnaderi's full-sized avatar
📖
Always Learning...

Mohammad Javad Naderi mjnaderi

📖
Always Learning...
View GitHub Profile
@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']
@mattiaslundberg
mattiaslundberg / arch-linux-install
Last active March 29, 2024 08:38
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap
@sloria
sloria / bobp-python.md
Last active April 17, 2024 09:35
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@Swop
Swop / jail.local
Created July 21, 2013 17:53
Adds Nginx DOS detection to Fail2ban
# /etc/fail2ban/jail.local
# [...]
[nginx-dos]
# Based on apache-badbots but a simple IP check (any IP requesting more than
# 240 pages in 60 seconds, or 4p/s average, is suspicious)
# Block for two full days.
# @author Yannick Warnier
enabled = true
@garethrees
garethrees / gist:5591027
Last active October 14, 2020 19:44
Ansible set timezone on Ubuntu host
- name: Group by Distribution
hosts: all
tasks:
- group_by: key=${ansible_distribution}
- name: Set Time Zone
hosts: Ubuntu
gather_facts: False
tasks:
- name: Set timezone variables
@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@jskripsky
jskripsky / BigIntSqrt.fs
Created October 11, 2011 10:07
Square root for BigInteger in F# (taken from http://www.codeproject.com/KB/recipes/BigIntSqrRoot.aspx)
module Roots
open System
open System.Numerics
@stammy
stammy / Rakefile
Created January 24, 2011 08:01
rake task for creating a new jekyll post.
# ignore the "bit" stuff.. only relevant to my custom jekyll fork
desc 'create new post or bit. args: type (post, bit), title, future (# of days)'
# rake new type=(bit|post) future=0 title="New post title goes here" slug="slug-override-title"
task :new do
require 'rubygems'
require 'chronic'
type = ENV["type"] || "bit"
title = ENV["title"] || "New Title"
@uogbuji
uogbuji / gruber_urlintext.py
Created November 18, 2010 18:28
John Gruber's regex to find URLs in plain text, converted to Python/Unicode
#See: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
import re, urllib
GRUBER_URLINTEXT_PAT = re.compile(ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))')
for line in urllib.urlopen("http://daringfireball.net/misc/2010/07/url-matching-regex-test-data.text"):
print [ mgroups[0] for mgroups in GRUBER_URLINTEXT_PAT.findall(line) ]