This file contains hidden or 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 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 |
This file contains hidden or 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 python3 | |
from enum import Enum, unique | |
import sys, json | |
@unique | |
class Columns(Enum): | |
FOLDERNAME=0 | |
FAVORITE=1 | |
TYPE=2 |
This file contains hidden or 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
# 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. | |
# |
This file contains hidden or 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
# 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' |
This file contains hidden or 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 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) |
This file contains hidden or 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 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 |
This file contains hidden or 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
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]) |
This file contains hidden or 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
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: |