Skip to content

Instantly share code, notes, and snippets.

View angeloped's full-sized avatar

Angeloped angeloped

  • Philippines
View GitHub Profile
@angeloped
angeloped / predict-city-state-coords.py
Last active August 11, 2020 21:20
Geographical City/State prediction. Focc please fix me.
import csv
"""
Download the data here: https://github.com/angeloped/OSDSint/tree/master/geocodes
"""
with open("geocities.csv", 'r') as csv_file:
csv_globe = [a for a in csv.DictReader(csv_file)]
def pos_neg(num1, num2):
@angeloped
angeloped / rsa.py
Created June 21, 2020 08:26
A simple RSA implementation in Python
'''
620031587
Net-Centric Computing Assignment
Part A - RSA Encryption
'''
import random
'''
@angeloped
angeloped / translit_farsi.py
Created August 11, 2020 21:19
Transliterate Persian/Farsi language. Persian/Farsi transliterator.
def translit_farsi(word):
word = word.replace("ا", "a")
word = word.replace("أ", "a")
word = word.replace("آ", "a")
word = word.replace("إ", "e")
word = word.replace("ب", "b")
word = word.replace("ت", "t")
word = word.replace("ث", "th")
word = word.replace("ج", "j")
word = word.replace("ح", "h")
@angeloped
angeloped / online-note.php
Last active September 17, 2020 21:52
A simple note composer web app written in PHP for lazy writers.
<?php
/*
A simple note composer web app written in PHP for lazy writers.
*/
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
if(!isset($_GET["save"])){
@angeloped
angeloped / HTTP-HM-AT.py
Last active November 24, 2020 12:57
(HTTP) HyperMessenger Attack Tool.
#!/usr/bin/python
import sys
import time
try:
import urllib
except ImportError:
@angeloped
angeloped / near_perfect_square.py
Created December 2, 2020 06:19
Determine the nearest perfect square within the range from 0 to n.
def near_square(n):
for i in range(n,0,-1):
if (i**(1.0/2))%1==0: # if perfect square
break
return i
print(near_square(26))
print(near_square(10))
print(near_square(9))
@angeloped
angeloped / is_square.py
Created December 2, 2020 06:20
Determine if the number is perfect square.
def is_square(n):
return (n**(1.0/2))%1==0
print(is_square(25))
print(is_square(24))
print(is_square(8))
print(is_square(2))
print(is_square(1))
@angeloped
angeloped / near_perfect_cube.py
Created December 2, 2020 06:20
Determine the nearest perfect cube within the range from 0 to n.
def near_cube(num):
for i in range(num,0,-1):
if (i**(1.0/3))%1==0: # if perfect cube
break
return i
print(near_cube(730))
print(near_cube(729))
print(near_cube(29))
@angeloped
angeloped / is_cube.py
Created December 2, 2020 06:20
Determine if the number is perfect cube.
def is_cube(n):
return (n**(1.0/3))%1==0
print(is_cube(28))
print(is_cube(27))
print(is_cube(10))
print(is_cube(8))
print(is_cube(3))
@angeloped
angeloped / is_ascii.py
Created December 29, 2020 20:29
Determine whether the string is ASCII or not. Compatible in Python 2 and Python 3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
text = "a♥O◘♦♥O◘♦"
try:
try:
stat = text.decode('ascii')
except UnicodeDecodeError:
stat = False