Skip to content

Instantly share code, notes, and snippets.

View SpirosArk's full-sized avatar

Spiros Arkoudelis SpirosArk

View GitHub Profile
@SpirosArk
SpirosArk / count_digit.py
Created April 14, 2021 08:47
A gist that counts from 1 to given number n, how many times "a certain digit -- here is 9 --" will appear
def count_digit(n):
c = 0
for i in range(0, n+1): #For to parse from 0 to given n
for digit in str(i): #For to parse given n's digits
if digit == '9': #Digit's occurence which will be counted
c = c + 1
return c
@SpirosArk
SpirosArk / find.py
Created March 29, 2021 06:00
A python code that searches given files for given strings. Doesn't print the number of the line that 'String_To_Search' was found. Prints the whole line of the string given (if found).
def check_if_string_in_file(file_name, string_to_search):
""" Check if any line in the file contains given string """
# Open the file in read only mode
a = False
with open(file_name, 'r') as read_obj:
# Read all lines in the file one by one
for line in read_obj:
# For each line, check if line contains the string
if string_to_search in line:
import gi
import sys
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
appsrc = Gst.ElementFactory.make("appsrc", "appsrc")
filesink = Gst.ElementFactory.make("filesink", "filesink")
filesink.set_property("location", "test.dat")