This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Scrape Doh provider URLs from Curl's DNS-over-HTTPS wiki (https://raw.githubusercontent.com/wiki/curl/curl/DNS-over-HTTPS). | |
# | |
# Example usage: ./scrape_doh_providers.py '"{} - {}".format(o["url"], o["name"])' | |
# | |
import argparse | |
import re | |
import urllib.request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import os | |
import sys | |
import threading | |
import boto3 | |
from botocore.exceptions import ClientError | |
def get_buckets(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import tqdm | |
import os | |
import argparse | |
def get_line_count(file): | |
abs_path = os.path.abspath(file) | |
completed_process = subprocess.run(args=['wc', '-l', abs_path], check=True, encoding='utf-8', | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nc towel.blinkenlights.nl 23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* itoa - convert an int to a str with the given base. | |
* My own implementation with LOTS of explanation | |
* | |
*/ | |
char *itoa(int val, int base) { | |
// make sure base is supported | |
if (base < 2 || base > 16) { | |
return NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
test_data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
pstd_dev = lambda data: sqrt(sum([((sum(data) / len(data)) - x)**2 for x in data]) / len(data)) | |
std_dev = lambda data: sqrt(sum([((sum(data) / len(data)) - x)**2 for x in data]) / (len(data) - 1)) | |
print(pstd_dev(test_data)) | |
print(std_dev(test_data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Found this on http://www.december.com/unix/ref/chmod.html - | |
File permissions | |
Use the chmod command to set file permissions. | |
The chmod command uses a three-digit code as an argument. | |
The three digits of the chmod code set permissions for these groups in this order: | |
Owner (you) | |
Group (a group of other users that you set up) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using URLSearchParams | |
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams | |
let urlParams = new URLSearchParams(window.location.search); | |
let something = url_params.get('something'); | |
// other way (also works with window.location.hash) | |
let urlParams = {}; | |
window.location.search.substr(1).split('&').forEach((param) => { | |
let x = param.split('='); | |
urlParams[x[0]] = x[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
@register.simple_tag() | |
def render(field, attrs, val=None): | |
""" | |
Renders a form field as a widget with the attributes you specify (separated by commas) | |
Example usage: {% render field 'class="form-control is-invalid", required' field.value %} | |
""" | |
for attr in attrs.split(', '): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --author="<author_name>" --pretty=tformat: --numstat | awk '{print $1}' | grep "^[0-9]" | paste -sd+ | bc |