Skip to content

Instantly share code, notes, and snippets.

View Ashaba's full-sized avatar

Ashaba Ashaba

  • Kampala
View GitHub Profile
@Ashaba
Ashaba / merge_arrays.py
Created July 5, 2019 11:08
A function that merges two arrays together at a given length creating one array array
def merge_arrays(a, b, c):
index = 0
b_index = 0
b_len = len(b)
d = []
for i in a:
d.append(i)
index += 1
if index == c:
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/-
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
"""
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.
#!/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
#!/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
$ 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
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