Skip to content

Instantly share code, notes, and snippets.

@erikzaadi
erikzaadi / .gitconfig
Last active March 26, 2024 22:23
Drying up your CI/CD with git rebase - an elaboration of the Reversim 2024 Ignite talk
# some git aliases to help out
[alias]
# fetch and merge main/master branch without the need for checkout
fnm = "!f() { WANTED_BRANCH="${1:-master}"; echo "Fetching and merging ${WANTED_BRANCH}";git fetch origin "${WANTED_BRANCH}:${WANTED_BRANCH}"; }; f"
# same as above expect that it fetches from an upstream remote (fork scenario)
fnmu = "!f() { WANTED_BRANCH="${1:-master}"; echo "Fetching and merging ${WANTED_BRANCH}";git fetch upstream "${WANTED_BRANCH}:${WANTED_BRANCH}";git push origin ${WANTED_BRANCH}:${WANTED_BRANCH};}; f"
reset-date = commit --amend --date=now
@erikzaadi
erikzaadi / __init__.py
Created July 3, 2012 13:47
Mocking python imports
#everyone loves a __init__ file
@erikzaadi
erikzaadi / example.js
Created October 22, 2018 14:01
Nested Destructuring
const nestedOriginalObject = {
firstLevel: {
secondLevel: {
key1: 'value1',
key2: 'value2'
}
}
};
from unittest import TestCase
class BaseTestClass(TestCase):
"""
Base test class for the two components.
"""
__test__ = False #important, makes sure tests are not run on base class
component = None
unsorted = {1, 59, 12, 43, 4, 58, 5, 13, 46, 3, 6}
sorted_list = sorted(unsorted)
list_length = len(sorted_list)
if list_length < 2:
print sorted_list
current = [sorted_list[0]]
for index in xrange(1, list_length):
if sorted_list[index - 1] + 1 == sorted_list[index]:
current += [sorted_list[index]]
else:
@erikzaadi
erikzaadi / unwatching_organization.js
Created October 29, 2012 14:24
Unsubscribing to an entire organization at once
var auth_token = $("input[name='authenticity_token']")[0].value;
$("a.repo-name[href^='/THEORG']").each(function($elem){
$.post("/notifications/subscribe", {
authenticity_token : auth_token,
do : 'included',
'repository_id' : $("form.js-unsubscribe-form #repository_id", $(this).parent("li")).val()
});
});
try:
#NOTE:
# This is a terrible hack, but it works ;)
# The version and description from the setup.py are fetched and parsed
# here..
import pkg_resources # part of setuptools
ver = pkg_resources.require("YOUR_PACKAGE_NAME")[0]
thetitle = [line for line in ver.get_metadata('PKG-INFO').split("\n") \
if line.startswith("Summary")][0].split(":")[1].strip()
version = ver.version
@erikzaadi
erikzaadi / tmuxinator_project.yml
Created April 23, 2012 11:04
A sample usage of ssh -t in one of my tmuxinator project files
# ~/.tmuxinator/someproject.yml
# you can make as many tabs as you wish...
project_name: SomeProject
project_root: /path/to/someproject
pre: find . -name "*.pyc" -exec rm -rf {} \#
tabs:
- editor: PYTHONPATH=$PYTHONPATH:$PWD vim
- testAndIShell:
layout: even-horizontal
@erikzaadi
erikzaadi / tmuxinator_project.yml
Created April 4, 2012 07:16
Tmuxinator Project
# ~/.tmuxinator/project.yml
# you can make as many tabs as you wish...
project_name: Guybrush
project_root: /path/to/code
pre: #you can fire up db or env initializations here
tabs:
- editor:
layout: main-vertical
panes:
@erikzaadi
erikzaadi / controller.coffee
Created December 21, 2011 13:01
Rest-ish render for Railway JS
load 'application'
restRender = use('restRender')
action 'fetchMeSomething', () ->
model = { something : 'else' }
restRender model