Skip to content

Instantly share code, notes, and snippets.

View f3rdy's full-sized avatar

Fred Thiele f3rdy

  • CDDS - Continuous Delivery and DevOps Services
  • Västernorrlands län
  • 17:00 (UTC +02:00)
View GitHub Profile
@f3rdy
f3rdy / git-largest-files
Created February 6, 2020 05:30 — forked from malcolmgreaves/git-largest-files
Python script to find the largest files in a git repository.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Updated to use Python 3 by Malcolm Greaves.
#
# Python script to find the largest files in a git repository.
# The general method is based on the script in this blog post:
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch
@f3rdy
f3rdy / parse_csv.py
Created January 13, 2018 11:13
How to use Python3 enum to access, index and transform a csv file
#!/usr/bin/env python3
from enum import Enum, unique
import sys, json
@unique
class Columns(Enum):
FOLDERNAME=0
FAVORITE=1
TYPE=2
# This gist is compatible with Ansible 1.x .
# For Ansible 2.x , please check out:
# - https://gist.github.com/dmsimard/cd706de198c85a8255f6
# - https://github.com/n0ts/ansible-human_log
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@f3rdy
f3rdy / foo.rb
Created January 28, 2017 07:49
How to reset admin password in gitlab
# logon at your gitlab server
#
# $ sudo gitlab-rails console production
Loading production environment (Rails 4.2.7.1)
irb(main):001:0> user = User.where(id: 1).first
=> #< USER ADMIN >
irb(main):002:0> user.password = 'my_new_pass'
irb(main):003:0> user.password_confirmation = 'my_new_pass'
@f3rdy
f3rdy / reverse_readline.py
Created August 3, 2016 06:05
reverse readline
import os
# from: http://bit.ly/2arGvvk
def reverse_readline(filename, buf_size=8192):
"""a generator that returns the lines of a file in reverse order"""
with open(filename) as fh:
segment = None
offset = 0
fh.seek(0, os.SEEK_END)
@f3rdy
f3rdy / decorators1.py
Created March 21, 2016 16:13
Decorators
from functools import wraps
def hello(func):
@wraps(func) # fetch attributes from the original function
def proxy(*args, **kwargs):
print("Decorator Action")
return func(*args, **kwargs)
return proxy
@hello
@f3rdy
f3rdy / fibonacci2.py
Created October 23, 2015 17:30
In place on list fibonacci
def fib(maximum):
"""
Calculate the fibonacci numbers below maximum
:param maximum: the maximum number
:return: a list containing fibonacci numbers
"""
result = [1, 1]
while True:
result.append(result[len(result)-2] + result[len(result)-1])
@f3rdy
f3rdy / fibonacci.py
Last active March 21, 2016 15:44
A simple test to provide code for a gist
def fib(maximum):
"""
Calculate the fibonacci numbers below maximum
:param maximum: the maximum number
:return: a list containing fibonacci numbers
"""
a, b = 1, 1
result = [a, b]
while True: