Skip to content

Instantly share code, notes, and snippets.

View amirsinaa's full-sized avatar
👾

Amirsina Shadkami amirsinaa

👾
View GitHub Profile
@amirsinaa
amirsinaa / angryUpdate-dependencies.js
Last active August 15, 2017 12:09
Nodejs script to force update your outdated local node modules
/***
run : node angryUpdate-dependencies.js && rm -rf node_modules && npm update --save-dev
&& npm update --save && rm -rf node_modules && npm update --save-dev && npm update --save
in ypur project directory
**/
var fs = require('fs'),
angryUpdate = function() {
var file = fs.readFileSync('package.json'),
content = JSON.parse(file);
@amirsinaa
amirsinaa / config.rb
Created September 25, 2017 07:15
A simple compass config.rb
require 'compass/import-once/activate'
add_import_path "Require any additional compass plugins here"
output_style = :compressed
css_dir = "assets/css"
sass_dir = "source/sass"
# To enable relative paths to assets via compass helper functions :
relative_assets = true
@amirsinaa
amirsinaa / rpng.py
Last active January 20, 2021 19:34
A simple python script to generate random phone numbers
from random import randint
def random_with_N_digits(n):
range_start = 10**(n-1)
range_end = (10**n)-1
return randint(range_start, range_end)
for mciNumbers in range(0,100):
print('0912', random_with_N_digits(7))
@amirsinaa
amirsinaa / bulk_git_pull.sh
Created January 4, 2020 20:44
Pull all git repositories located in a directory ( with extra options )
#!/bin/bash
CURRENT_DIRECTORY=$(pwd)
echo $'\e[1;31m'git reset --hard ? $'\e[0m'
read -r -p "[y/N]" reset_changes_bool
case "$reset_changes_bool" in
y|Y)
echo $'\e[1;32m'Pulling latest changes for all repositories ... $'\e[0m'
for repo in $(find . -name ".git" | cut -c 3-); do
cd "$repo";
echo "\033[34m"Pulling : @@ $repo @@"\033[0m";
@amirsinaa
amirsinaa / triangle_area_and_type.py
Last active March 16, 2024 05:59
Python code that calculate the area of a triangle and recognize its type (equilateral - isosceles - different-sided - right-angled)
import math
def calculate_area(a, b, c):
s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
return area
def classify_triangle(a, b, c):
if a == b == c:
return "equilateral"
@amirsinaa
amirsinaa / quadrilateral_type.py
Last active March 16, 2024 05:59
Python code that receives the sides of a quadrilateral and tells its type
def is_square(sides, angles):
return all(side == sides[0] for side in sides) and all(angle == 90 for angle in angles)
def is_rectangle(angles):
return all(angle == 90 for angle in angles)
def is_rhombus(sides):
return all(side == sides[0] for side in sides)
def is_parallelogram(angles):
@amirsinaa
amirsinaa / magic_number_for_the_villagers.py
Last active March 16, 2024 05:59
Python code that calculates the maximum product of two numbers from two time intervals
def calculate_dreamcatcher_number(period1, period2):
a, b = period1
c, d = period2
max_product = max(a*c, a*d, b*c, b*d)
return max_product
if __name__ == "__main__":
@amirsinaa
amirsinaa / format_ampm_to_24H.py
Last active March 16, 2024 05:58
Python code that converts time in am,pm to 24H format and 24H to am,pm
def format_ampm_to_24H(time_str):
time_parts = time_str.lower().strip().split()
try:
hours, minutes = map(int, time_parts[0].split(":"))
except ValueError:
return "Invalid input!"
if len(time_parts) == 2:
meridian = time_parts[1].lower()
if meridian == "a.m.":
@amirsinaa
amirsinaa / alis_rectangle_party.py
Last active March 16, 2024 05:58
Python code that takes three sets of coordinates, representing three vertices of a rectangle, and calculates the fourth vertex
def find_alis_fourth_rectangle_vertex(coord1, coord2, coord3):
x_coords = [coord1[0], coord2[0], coord3[0]]
y_coords = [coord1[1], coord2[1], coord3[1]]
fourth_x = None
fourth_y = None
for x in x_coords:
if x_coords.count(x) == 1:
fourth_x = x