This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Three steps to make an https alternative to python -m http.server @kkt | |
1. shell command to generate the files: certificate.pem and key.pem | |
$ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem | |
2. Host the server | |
3. Add to $PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.io import loadmat | |
IMFs = loadmat('IMFData_.mat') | |
# -----< INSPECTING IMFData_ > | |
type(IMFs['IMFData_']),IMFs['IMFData_'].shape | |
IMFData_ = IMFs['IMFData_'] #numpy.ndarray | |
IMFData_.dtype | |
IMFData_.shape # IMFData_ : {2Darray, string} x 200 instances | |
IMFData_[0].shape # 0-199(max) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
pathx = '/root/dirx/'; %---o directory path | |
files = fullfile(pathx,'*.csv'); | |
d = dir(files); clearvars files | |
%% | |
files_with_abs_path = {}; | |
file_name_head ={}; | |
for k=1:numel(d) %---o LOOPING through each filenames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
konsole --noclose -e echo $'Gentoo update copy/paste commands: | |
$ emaint -a sync | |
(optional) $ emerge --oneshot sys-apps/portage | |
$ emerge --ask -uDU --keep-going --with-bdeps=y @world | |
o emaint -a sync \no running in other terminal...' & | |
konsole --noclose -e emaint -a sync & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. | |
For example: | |
unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B'] | |
unique_in_order('ABBCcAD') == ['A', 'B', 'C', 'c', 'A', 'D'] | |
unique_in_order([1,2,2,3,3]) == [1,2,3] | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
There is a queue for the self-checkout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out! | |
input | |
customers: an array of positive integers representing the queue. Each integer represents a customer, and its value is the amount of time they require to check out. | |
n: a positive integer, the number of checkout tills. | |
output | |
The function should return an integer, the total time required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Count the number of Duplicates | |
Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits. | |
Example | |
"abcde" -> 0 # no characters repeats more than once | |
"aabbcde" -> 2 # 'a' and 'b' | |
"aabBcde" -> 2 # 'a' occurs twice and 'b' twice (`b` and `B`) | |
"indivisibility" -> 1 # 'i' occurs six times |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. | |
Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case | |
""" | |
def countBits(n): | |
b = bin(n)[2:] | |
return sum([int(x) for x in b]) | |
#OR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Given an array of ones and zeroes, convert the equivalent binary value to an integer. | |
Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1. | |
""" | |
def binary_array_to_number(arr): | |
# your code | |
return int(''.join([str(x) for x in arr]),2) | |
#OR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Number of people in the bus | |
There is a bus moving in the city, and it takes and drop some people in each bus stop. | |
You are provided with a list (or array) of integer arrays (or tuples). Each integer array has two items which represent number of people get into bus (The first item) and number of people get off the bus (The second item) in a bus stop. | |
Your task is to return number of people who are still in the bus after the last bus station (after the last array). Even though it is the last bus stop, the bus is not empty and some people are still in the bus, and they are probably sleeping there :D | |
Take a look on the test cases. | |
Please keep in mind that the test cases ensure that the number of people in the bus is always >= 0. So the return integer can't be negative. | |
The second value in the first integer array is 0, since the bus is empty in the first bus stop. | |
""" |
NewerOlder