Skip to content

Instantly share code, notes, and snippets.

@igniteflow
igniteflow / business-days-in-month.py
Last active March 2, 2024 06:39
Print the number of business days and weekend days in a month
#!/usr/bin/python3
"""
Print the number of business days and weekend days in a month
Example usage:
$ python ./business-days-in-month.py 2024 2
February, 2024 has 21 weekdays and 8 weekend days
Optional: Make the script executable
@igniteflow
igniteflow / gist:e29d11a4d142207b59c6589e26817139
Last active November 2, 2021 11:57
Useful glab commands
# prints list of merge request ids only for a given user and target branch
glab mr list --assignee <gitlab-user-name> --target-branch <target-branch-name> | awk '{ print $1 }' | sed 's/!//g' | while read line; do glab mr update $line --target-branch <target-branch-name>; done
@igniteflow
igniteflow / slack-images.py
Created October 8, 2018 08:48
Download all images from a Slack channel
import datetime
import requests
import os.path
TOKEN = 'xxxx-xxxx'
TARGET_DIR = './images/'
@igniteflow
igniteflow / rename-files.md
Last active April 18, 2018 14:01
Google Drive: fix dotfile renaming

Google Drive replaces the leading dot in dot-filenames with an underscore. To undo this after downloading the files as a zip run

  # replaces leading underscores with dots
  rename -n 's/^_/./g' *  # first check
  rename 's/^_/./g' *  # now execute

After downloading the files be sure to set the correct permissions

@igniteflow
igniteflow / .gitautouser
Created February 13, 2018 10:56
Git auto user. Switch git user/email based on active directory
#!/usr/bin/env python
"""
Checks and sets git username and email based on dir root matching
1. Add the following to ~/.bashrc
function cd {
builtin cd "$@"
if [ -d ".git" ] ; then
@igniteflow
igniteflow / python-command-line.md
Last active May 13, 2018 11:48
Creating a command-line app with Python
  1. Create a setup.py:
  #!/usr/bin/env python

  from distutils.core import setup

  setup(
      name='My Thing',
 version='1.0',
@igniteflow
igniteflow / git-commands.sh
Last active December 14, 2023 06:31
Git commands
# pull changes from a single file inside a commit (useful when hotpatching)
git diff ..<hash> -- <filename> | git apply
# view changes in a file historically
git diff 'HEAD@{3 weeks ago}'..HEAD -- foo/my_module.py
# view commits with patches in this branch only (assuming it was branched from master and is up-to-date)
# useful when reviewing tickets
git log master.. --patch --reverse
@igniteflow
igniteflow / linux-commands.md
Created November 25, 2016 12:44
Linux commands

Linux Commands

Networking

traceroute - print the route packets take to network host

ifconfig - interface configurator. view ip address and mac address

ping - (Packet INternet Groper) test connectivity between two nodes

@igniteflow
igniteflow / connection-issues.md
Created November 7, 2016 12:29
Debugging connection issues

nmap github.com -p http,git

@igniteflow
igniteflow / mock-object-property.py
Created October 3, 2016 11:03
How to mock an object property in Python
import mock
with mock.patch('path.to.ObjectClass.my_property', new_callable=mock.PropertyMock) as mock_my_property:
mock_my_property.return_value = 'my value'