Skip to content

Instantly share code, notes, and snippets.

@ZuluPro
ZuluPro / user_factory.py
Created May 31, 2018 23:47
Django User model Factory
import factory
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'myapp.User'
django_get_or_create = ('username',)
username = factory.Faker('user_name')
first_name = factory.Faker('first_name')
@ZuluPro
ZuluPro / mdd.sh
Last active August 29, 2015 14:18
Launch dd against block device with multiple jobs
#!/bin/bash
[[ -z "$1" ]] && echo "No given device" && exit 1
[[ -z "$2" ]] && echo "No given mode (read|write)" && exit 1
device=$1
mode=$2
cpu_num=$(cat /proc/cpuinfo | grep proc | wc -l)
bytes_to_write=$(fdisk -l $device | grep -E 'Disk .* bytes$' | awk '{print $(NF-1)}')
process_num=$((cpu_num*2))
count_by_process=$((bytes_to_write/1024/1024/process_num))