Skip to content

Instantly share code, notes, and snippets.


Skanda Kaashyap kaashmonee

View GitHub Profile
kaashmonee /
Created Sep 19, 2018
Creates a user on a linux system using the first command line arg, sets a temporary password, and adds them to the root and Docker groups.
# Ensure that script is being run as root.
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root!"
exit 1
# Getting username from cmd line
kaashmonee /
Created Apr 12, 2018
finding gcd with the euclidean algorithm
def gcd(a, b):
if (a == 1 or b == 1):
return 1
elif (a == 0): return b
elif (b == 0): return a
# print(a, b)
return gcd(b, a % b)
kaashmonee /
Created Dec 23, 2017
Solution to Leaf of the Tree challenge in PicoCTF. Traverses all directories in path and retrieves flag file.
# picoCTF leaf of the tree
import os
path = "/problems/5da315e9c7f1c9886ea371abee5ae8d0"
def getPath(path):
if not os.path.isdir(path):
return path
for dir in listdir_fullpath(path):
kaashmonee /
Created Dec 17, 2017
Copies and shortens code from one file to another
import argparse
def cp(inp, out):
with open(out, "w") as output, open(inp, "r") as inp:
lines = []
for line in inp:
# ignores new lines
if line == "\n":
kaashmonee /
Last active May 4, 2020
3 body problem simulation in Python
from visual import *
scene = display(title="Earth's Orbit", width=500, height=500, range=3.e11)
scene.autoscale = 0 # Turn off auto scaling of display.
# Define the Sun and the Earth objects.
sun = sphere(color=color.yellow)
View helloworld.rb
$i = 100
$n = 3
while $n < $i do
puts("inside the loop i = #$n")
$n += 1
#checks to see if n is prime in one line
def oneLineIsPrime(n): return False if (n % 2 == 0 and n > 2) or n < 2 or 0 in [n%factor for factor in range(3, round(n ** 0.5))] else True
kaashmonee /
Created Oct 16, 2017
Counts the number of times you have to carry when you add 1 to a binary number.
def countCarries(number):
number = str(number)
number = list(number)
carries = 0
for x in range(len(number)-1, -1, -1):
if int(number[x])==2:
if number[x-1]:
kaashmonee /
Created Jul 11, 2017
Google foobar challenge -- gearing up for destruction recursive implementation
from fractions import Fraction
def answer(pegs):
def find_rn(num):
if num == 1:
return 0
return pegs[num-1]-pegs[num-2]-find_rn(num-1)
ans = find_rn(len(pegs))
if len(pegs)%2 == 0: #if it's even
You can’t perform that action at this time.