Skip to content

Instantly share code, notes, and snippets.

@comandrei
comandrei / db.json
Created February 22, 2024 17:52
db.json
[{"model": "auth.group", "fields": {"name": "Manager", "permissions": [["add_produs", "app", "produs"], ["change_produs", "app", "produs"], ["view_produs", "app", "produs"]]}}, {"model": "auth.user", "fields": {"password": "pbkdf2_sha256$720000$H1Nh9zmRf07llikyOTqiJW$h6LH3AYc7EdfS5/9UW+3jQATqMPHyfI5Lf497JajbGg=", "last_login": "2024-02-20T18:26:20.598Z", "is_superuser": true, "username": "admin", "first_name": "", "last_name": "", "email": "[email protected]", "is_staff": true, "is_active": true, "date_joined": "2024-01-16T17:50:18.780Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "fields": {"password": "pbkdf2_sha256$720000$Hp9E9OxVS8ULsNFzFH8eP0$lV/1jgU7jysd4WXL3sZY4jbNMzSCXWn47kxNtC1qK8k=", "last_login": "2024-02-08T17:15:39.107Z", "is_superuser": false, "username": "user", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2024-02-08T17:15:18.608Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "fields": {"password": "pb
import unittest
def sort_dicts(dicts):
result = []
for index, item in enumerate(dicts, 1):
lowest_key = sorted(item.keys())[0]
result.append((index, lowest_key, item[lowest_key]))
sorted_result = sorted(result, key=lambda x: (x[1], x[2]))
return [key[0] for key in sorted_result]
@comandrei
comandrei / workflow.sh
Last active February 27, 2018 12:22
Common git workflows
# My git workflow
# 1. Who the heck wrote this ?? .. aa me 6 months ago
# Track down the whys of weird code ... links to commits -> commit messages -> JIRA (tool of choice) tickets
git blame
# 2. Q: Hey can we do a quick hotfix? Everything's on fire on production
# A: But .. but ... I'm working on a new feature
git stash
git checkout release-branch
git checkout -b hotfix
# type away .. work work
#!/usr/bin/env bash
# Hard coded hashes. Should change to capturing stdout from hash-object and openssl calls
rm -rf .git # cleanup
rm test.txt
set -x
git init
# ls -l .git
# HEAD -> points to the latest commit (ref)
# config -> per repository overrides of global .gitconfig; remote definitions; remote branch mapping definitions
# description -> ?
@comandrei
comandrei / rand_input.py
Created April 14, 2016 10:18
Random string generators
import random
import string
def random_string(length):
return ''.join(random.sample(string.ascii_uppercase + string.digits, length))
def random_digits(lengthOfDigits):
return ''.join(random.sample(string.digits, lengthOfDigits))
@comandrei
comandrei / 1-How to Setup
Last active August 29, 2015 14:00 — forked from pcreux/complete.sh
Bamboo Github Commit Status integration
Environment variables
GITHUB_TOKEN="token" OWNER="ownername" REPO="reponame"
Set pending.sh after Source Code Checkout
Set complete.sh after Parsing test results as a final task
@comandrei
comandrei / mtar.c
Created January 27, 2014 08:46
Basic tar pack/unpack utility
#include <stdio.h>
#include <string.h>
long filesize(char * filename){
FILE * f;
f=fopen(filename,"rb");
if(!f){
printf("Eroare la deschiderea fisierului %s\n",filename);
return 0;
}
fseek(f,0,SEEK_END);
@comandrei
comandrei / gist:5611826
Created May 20, 2013 11:58
Use slave connections for certain queries
from django.db import connections
connection = connections['slave']
connection.cursor.execute("SHOW PROCEDURE STATUS") # This is executed on the slave
results = connection.cursor.fetchall()