Skip to content

Instantly share code, notes, and snippets.

View Ashaba's full-sized avatar

Ashaba Ashaba

  • Kampala
View GitHub Profile
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
alias pythonfiles='find . -type f -name "*.py" | xargs git diff --cached --name-only $against'
if [ -n "$(pythonfiles)" ]; then
if pythonfiles | xargs grep --color --with-filename -n "import pdb"; then
echo "Error commiting changes: Please remove pdb and its usage"
exit 1
fi
if pythonfiles | xargs grep --color --with-filename -n "pdb.set_trace()"; then
echo "Error commiting changes: Please remove pdb and its usage"
exit 1
fi
$ mv pre-rebase.sample pre-rebase #renaming sample to pre-rebase.
#!/bin/sh
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
$regex = /\((\w+)\):/
if !$regex.match(message)
puts "[POLICY] Your message is not formatted correctly"
puts "[STANDARD] Your message should be in the format: ‘feat(module): commit message’ "
exit 1
end
#!/usr/bin/env bash
mkdir directory1 directory2 directory3 #create multiple directories
pwd #show the current directory
ls # list contents of a directory
cd directory1 # move to a particular directory
touch script.py # create a file
cp script.py ../directory2 # copy contents a file to another directory
echo "foo" | xargs touch #command with pipes
"""
There are N countries {1,2,3,4....N} and N-1 roads(i.e depicting a tree)
Bishu lives in the Country 1 so this can be considered as the root of the tree.
Now there are Q girls who live in various countries (not equal to 1) .
All of them want to propose Bishu. But Bishu has some condition.
He will accept the proposal of the girl who lives at minimum distance from his country.
package challenge;
/**
* You have 10,000/= bob, and you need to buy exactly 100 animals:
* - cows @1000/-
* - pigs @200/-
* - chicken @50/-
*
* 1. You must have at least one of each animal
* 2. You must use up all Ksh. 10K
package challenge;
import java.util.HashMap;
/**
* You have 10,000/= bob, and you need to buy exactly 100 animals:
* - cows @1000/-
* - pigs @200/-
* - chicken @50/-