Skip to content

Instantly share code, notes, and snippets.

View akionsight's full-sized avatar
🤔
Think.

AkIonSight akionsight

🤔
Think.
  • Pune, India
View GitHub Profile
@akionsight
akionsight / randint_test.py
Last active October 16, 2020 07:21
Print a random numbers between 1 and 100
import random
print(random.randint(1, 100))
## can give answers such as 45, 97, 12 3, 88 etc
@akionsight
akionsight / random_choice_test.py
Last active October 16, 2020 07:30
test random.choice
import random
list_of_movies_to_watch = ['harry potter', 'percy jackson', 'the matrix', 'men in black']
print(random.choice(list_of_movies_to_watch))
## any of the following movies will printed eg 'the matrix'
@akionsight
akionsight / secrets_token_bytes_example.py
Created October 17, 2020 05:23
secrets.token_bytes example
import secrets
print(secrets.token_bytes(2))
print(secrets.token_bytes(4))
print(secrets.token_bytes(8))
print(secrets.token_bytes(12))
print(secrets.token_bytes(16))
print(secrets.token_bytes(12))
print(secrets.token_bytes(144))
## returned arguments can be
'''
@akionsight
akionsight / secrets_token_hex_example.py
Created October 17, 2020 05:28
secrets.token_hex example
import secrets
print(secrets.token_hex(2))
print(secrets.token_hex(4))
print(secrets.token_hex(8))
print(secrets.token_hex(12))
print(secrets.token_hex(16))
print(secrets.token_hex(12))
print(secrets.token_hex(144))
## returned the following in one random test case
'''
@akionsight
akionsight / secrets_token_urlsafe_example.py
Created October 17, 2020 05:37
secrets.token_urlsafe example
import secrets
print(secrets.token_urlsafe(2))
print(secrets.token_urlsafe(4))
print(secrets.token_urlsafe(8))
print(secrets.token_urlsafe(12))
print(secrets.token_urlsafe(16))
print(secrets.token_urlsafe(12))
print(secrets.token_urlsafe(144))
## returned this in one random test case
'''
@akionsight
akionsight / example.py
Created October 17, 2020 05:58
secrets.compare_digest exaample
import secrets
equal_str = '9oKOSmTqT8Kn2BnpZ7qIs7JjTleGeXa119rMfxFdoDg5zeqInGT5NMWK_y0mI2U_ldbFaiSnsfDtwMSiBGvaKCvBL7wnXkW'
unequeal_str = '74K2Xps1O2om5ujSWxtgq449D4_RmHGSqH2HIJgM_m4YclfhxR0LHJTtnt-9obVC8gJOXLrCzVL63OuK6Qc_BcLJioNPm4Yjz'
print(secrets.compare_digest(equal_str, equeal_str)) ## True
print(secrets.compare_digest(equal_str, unequeal_str)) ## False
@akionsight
akionsight / prevent_space.js
Created October 25, 2020 10:32
A simple script to block space in input boxes (Uses jQuery)
$(document).ready(function() {
$('#test-input').on('keypress', function (e) {
if (e.which == 32) {
console.log('space detected, aborting space');
return false
}
})
})
@akionsight
akionsight / palindrome_checker.py
Created December 7, 2020 12:00
Checks for palindromes
def palindrome_checker(word):
reversed_word = word[::-1]
if reversed_word == word:
return True
else:
return False
# print(palindrome_checker('racecar')) -> returns True
# print(palindrome_checker('Joshua')) -> returns False
@akionsight
akionsight / is_web_rtc_supported.js
Created December 13, 2020 05:47
A small script that detects if a browser supports webRTC or not and if yes, then gets both the video and audio streams. if no, then brings up an alert
function hasUserMedia() {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia || navigator.msGetUserMedia;
return !!navigator.getUserMedia;
}
if (hasUserMedia()) {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia || navigator.msGetUserMedia;
@akionsight
akionsight / map_fizzbuzz.py
Created December 18, 2020 05:42
A small fizzbuzz using map() in python
## FIZZBUZZ
def fizz_buzz_fizzbuzz(number: int):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
elif number % 3 == 0:
return 'Fizz'
elif number % 5 == 0:
return 'Buzz'
else: