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 / example.js
Created October 22, 2018 14:01
Nested Destructuring
const nestedOriginalObject = {
firstLevel: {
secondLevel: {
key1: 'value1',
key2: 'value2'
}
}
};
@erikzaadi
erikzaadi / Vagrantfile
Created May 17, 2014 18:15
Example DevBox Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu13.04"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
@erikzaadi
erikzaadi / outdated.js
Last active August 29, 2015 13:57 — forked from shaharke/outdated.js
#!/usr/bin/env node
var npm = require('npm');
npm.load('./package.json', function () {
npm.outdated(function (err, outdated) {
if (outdated.length > 0) {
outdated.forEach(function (p) {
console.log(p[1] + '\t' + p[2] + ' => ' + p[3]);
});
process.exit(1);
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:
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 / 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()
});
});
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
@erikzaadi
erikzaadi / __init__.py
Created July 3, 2012 13:47
Mocking python imports
#everyone loves a __init__ file
@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