Skip to content

Instantly share code, notes, and snippets.

View navidanindya's full-sized avatar
💻
Coding away!

Navid Anindya navidanindya

💻
Coding away!
View GitHub Profile
@navidanindya
navidanindya / readme.md
Last active March 29, 2021 19:02
Auto Change Wallpaper from Unplash collection.

Autochange Wallpaper from Unsplash

This simple shell script runs every hour and takes an image from Unplash.com and sets it as a wallpaper. You can choose whatever wallpaper you want by changing the URL in wget of the shell script.

Go to source.unplash.com to know more about the Unplash API.

Installation

  • Place this script in your /bin directory.
import re
MORSE_CODE= {
'.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D', '.': 'E', '..-.': 'F',
'--.': 'G', '....': 'H', '..': 'I', '.---': 'J', '-.-': 'K', '.-..': 'L',
'--': 'M', '-.': 'N', '---': 'O', '.--.': 'P', '--.-': 'Q', '.-.': 'R',
'...': 'S', '-': 'T', '..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X',
'-.--': 'Y', '--..': 'Z',
'-----': '0', '.----': '1', '..---': '2', '...--': '3', '....-': '4',
'.....': '5', '-....': '6', '--...': '7', '---..': '8', '----.': '9',
@navidanindya
navidanindya / StripVowels.js
Created June 9, 2018 09:12
Strip vowels from a string using JavaScript. [ Link: https://repl.it/@nealtheguitaris/TightLawngreenTrapezoid ]
function disemvowel(str) {
return str.replace(/[aeiou]/ig,'');
}
console.log(disemvowel("Hello World!"));
import re
def disemvowel(string):
return re.sub('[aeiou]','',string,flags=re.IGNORECASE)
print(disemvowel("Hello World!"))
@navidanindya
navidanindya / UniqueCharactersSorted.py
Created June 9, 2018 08:55
Get unique characters from two strings and return a sorted substring (Python) [ Link: https://repl.it/@nealtheguitaris/SoggyCruelPipeline ]
def longest(s1, s2):
return ''.join(sorted(set(s1 + s2)))
print(longest('aaaabbbdddccc','aadfafiseitaabbbss'))
@navidanindya
navidanindya / UniqueCharactersSorted.php
Last active June 9, 2018 08:55
Get unique characters from two strings and return a sorted substring (PHP) [ Link: https://repl.it/@nealtheguitaris/PuzzlingVengefulRobot ]
<?php
function getUniqueSortedChars ($a, $b) {
return count_chars($a.$b,3);
}
echo getUniqueSortedChars('aaaabbbdddccc','aadfafiseitaabbbss')."\n";
?>
@navidanindya
navidanindya / URLSafeBase64.php
Created June 2, 2018 13:27
A very simple, quick and dirty way of encoding and decoding URL Safe Base64 strings. Preview: http://sandbox.onlinephpfunctions.com/code/66abd8f5fd2b87bf91a5fba3e9d93dfd190cba09
<?php
echo "Encode BASE64: ----------\n";
$string = 'message:whatsup';
$url = base64_url_encode($string);
echo "Encoded: ".$url."\n";
echo "Now decode! --------------\n";
$decode = base64_url_decode($url);
$getClient = explode(":", $decode);
foreach ($getClient as $str) {
@navidanindya
navidanindya / DirectorySize.py
Created April 9, 2018 12:04
Get a folder/directory size in Python 3. Run: [ python DirectorySize.py '/usr/bin' ] (without braces) to get size in '/usr/bin' folder.
import sys
import os
def calculateSize(path):
totalSize = 0
if len(path) > 2:
print('Extra argument given.')
sys.exit(0)
elif len(path) == 1:
@navidanindya
navidanindya / PrintList.py
Created April 9, 2018 10:39
Prints a list numerically in Python 3.
hobbits = ['Frodo', 'Samwise', 'Merry', 'Pippin']
wizards = ['Gandalf', 'Saruman', 'Radagast']
# Function starts
def printList(lists):
for number, item in enumerate(lists, 1):
print(str(number) + " " + item)
print("\n")
# Function ends
<?php
function factorial($number, $memoize = array(0,1)) {
if ($number == 0 || $number == 1) {
return 1;
}
if (!array_key_exists($number, $memoize)) {
$memoize[$number] = $number * factorial($number-1, $memoize);
}