Skip to content

Instantly share code, notes, and snippets.

View pasim's full-sized avatar

pasim pasim

View GitHub Profile
@pasim
pasim / Sorting_file_list_in_linux.txt
Created August 22, 2023 15:58
Sorting file list in linux
Soppost you have a file list like that
Step 1 on Seller.png Step 14 on Seller.png Step 19 on Seller.png Step 23 on Seller.png Step 28 on Seller.png Step 5 on Seller.png
Step 10 on Seller.png Step 15 on Seller.png Step 2 on Seller.png Step 24 on Seller.png Step 29 on Seller.png Step 6 on Seller.png
Step 11 on Seller.png Step 16 on Seller.png Step 20 on Seller.png Step 25 on Seller.png Step 3 on Seller.png Step 7 on Seller.png
Step 12 on Seller.png Step 17 on Seller.png Step 21 on Seller.png Step 26 on Seller.png Step 30 on Seller.png Step 8 on Seller.png
Step 13 on Seller.png Step 18 on Seller.png Step 22 on Seller.png Step 27 on Seller.png Step 4 on Seller.png Step 9 on Seller.png
You can format the output vertically and sort it like bellow
ls -1 | sort -t' ' -n -k2
@pasim
pasim / static_cache.py
Created July 19, 2021 15:51
Static cache example in python
#
# Run this code to see the result
#
import timeit
def memoize_fib(func):
cache = {}
def inner(arg):
if arg not in cache:
cache[arg] = func(arg)
@pasim
pasim / sortByFrequencyRemoveDuplicates.ts
Last active February 10, 2021 18:47 — forked from niteshpsit1/gist:c90b3336ee639c89ae13b98825c9d9ca
Sorting an array order by frequency of apperance and removing duplicates in javascript and TypeScript.
/**
* Sorting an array order by frequency of occurence and removing Duplicates in javascript
* @param {array} array An array to sort
* @returns {array} array of item order by frequency
**/
function sortByFrequencyRemoveDuplicates(array) {
var frequency = {};
var newArr = [];
array.forEach(function(value) {
<?php
/**
* Have the function SearchingChallenge(str) take the str parameter being
* passed and return the first word with the greatest number of repeated letters.
* For example: "Today, is the greatest day ever!" should return greatest because it has
* 2 e's (and 2 t's) and it comes before ever which also has 2 e's. If there are no words with
* repeating letters return -1. Words will be separated by spaces.
*/
@pasim
pasim / create_aplhabetical_dictionary.py
Created November 13, 2019 16:57
Generates a dictionary of all Capital case latin letters
import string
def _generate_dic_letters():
return dict(zip(list(string.ascii_uppercase),list(range(1, len(list(string.ascii_uppercase))+1))))
@pasim
pasim / findLeapYear.py
Last active October 18, 2019 22:20
Verifies leaf year not
def is_leap(year):
leap = False
if year not in range(1, 10**5):
print("Year must be witin range")
exit()
if(year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
@pasim
pasim / FindOddInRangePython.py
Created October 17, 2019 13:09
Finds and prints on the screen all odd numbers within the range defined by two variables low and high
"""
@param low int
@param high int
Finds and prints on the screen
all odd numbers within the range; defined by to
variables low and high
"""
@pasim
pasim / findOddInRange.php
Created October 17, 2019 12:31
Finds and prints on the screen all odd numbers with in the range defined by two integer variables $low and $high
<?php
/**
* @param $low int
* @param $high int
*
* Finds and prints on the screen
* all odd numbers with in the range provided by two
* variables $low and $high
*
/**
* <author> janis.janovskis@gmail.com
*/
var csv = [
["https://api.soundcloud.com/tracks/910291", "https://api.different-embed.com/12345"],
["https://api.soundcloud.com/tracks/5678", "https://api.different-embed.com/562222278"],
["https://api.soundcloud.com/tracks/12345", "https://api.different-embed.com/89999999"]
]
var strings = [
@pasim
pasim / data.csv
Created September 25, 2019 21:46
Lead developer test task
soundcloud different_url
https://api.soundcloud.com/tracks/910291 https://api.different-embed.com/12345
https://api.soundcloud.com/tracks/5678 https://api.different-embed.com/562222278
https://api.soundcloud.com/tracks/12345 https://api.different-embed.com/89999999