Posted in Apache Bash CLI Linux Python SysAdmin WebAdmin

Instaliraj LAMPY

  #!/bin/bash # LAMP + Python + SQLite stack sa pipx/pipenv (Ubuntu Server) set -e sudo apt update sudo apt upgrade -y sudo apt install…

Posted in Python

ib_insync error ‘The API interface is currently in Read-Only mode’

Kôd ib.connect ( ‘127.0.0.1’ , 4002 , clientId = 1 ) Pogreška Error 321, reqId 2147483647: Error validating request.-‘cG’ : cause – The API interface…

Posted in Python

Pretvori HTML tablicu iz datoteke u .CSV tablicu u datoteci

python.py # -*- coding: utf-8 -*- from bs4 import BeautifulSoup import pandas as pd with open("datoteka.html", "r", encoding="utf-8") as file: html_content = file.read() soup =…

Posted in Python

Pretvorba: HTML tablice u text (html2txt;table2txt)

from bs4 import BeautifulSoup with open("datoteka.html", "r", encoding="utf-8") as html_file: html_content = html_file.read() soup = BeautifulSoup(html_content, ‘html.parser’) tables = soup.find_all(‘table’) table_texts = [] for table…

Posted in Python Windows

IBKR API error warning

Problem [13:22:55] ERROR ERROR 1 10314 End Date/Time: The date, time, or time-zone entered is invalid. The correct format is yyyymmdd hh:mm:ss xx/xxxx where yyyymmdd…

Posted in Python

IBKR API error warning

Problem [HH:MM:SS] ERROR ERROR 1 2176 Warning: Your API version does not support fractional share size rules. Please upgrade to a minimum version 163. Trimmed…

Posted in Fuckery Linux Python

Gajim – Ubuntu – Omemo fuckery

Poruka TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must…

Posted in Powershell Python

Varijabla – Je li “prazna”?

powershell.ps1 IF ($Varijabla.Length -eq 0) {Write-Host "Prazno"} python.py try: varijabla except: print("Prazno") varijabla xvarijabla prazna xprazna variable xvariable empty xempty check xcheck provjeri xprovjeri

Posted in Python

Python – Integer – Dolar EUR – Točka za tisućice – Poravnaj udesno

python.py import locale OperatingCashFlow = 1234567890123.45 width = 35 locale.setlocale(locale.LC_ALL, "hr-HR") print ("hr-HR") print ( locale.format_string( "%.2f", OperatingCashFlow, grouping=True ) . rjust ( width )…

Posted in Python

Python – Varijable operacijskog sustava

python.py import os TempFolder = os.environ[‘TMP’]) python os xos environment xenvironment system xsystem user xuser variables xvariables

Posted in Python

Python Selenium predložak

  # pip install –upgrade selenium # pip install –upgrade webdriver-manager from selenium import webdriver from selenium.webdriver.firefox.service import Service from selenium.webdriver.firefox.options import Options from webdriver_manager.firefox…

Posted in Python

Python Pandas dataframe – Primjeri

Primjeri Dodaj nulti stupac koji postaje pandas dataframe index DeijtaFreijm = DeijtaFreijm.reset_index() Prebroj recorde u dataframetu (počinje od 0, dakle od “0 do 9” je…

Posted in Python

Python – Virtual environment

pip install virtualenv virtualenv ovdje source ./ovdje/bin/activate deactivate virtualenv xvirtualenv venv xvent xpython

Posted in Python

Python – Sortiraj listu, bez duplikata

Pretvori multiline string u listu da možeš sortirati: lista = sadrzaj.strip().split(‘\n’) lista = [ "jedan", "dva" , "tri", "dva", "cetiri" ] unik = set (…

Posted in Python

Python – Format – String; Integer; Postotak

String Ispiši točno određen broj znakova stringa string="….-….1….-….2….-….3….-….4….-….5….-….6….-….7….-….8" sirinaStupca=17 string[0:sirinaStupca].ljust(sirinaStupca) Ispuni razmacima, lijevo poravnato string[0:sirinaStupca].ljust(sirinaStupca * 2) Ispuni razmacima, desno poravnato string[0:sirinaStupca].rjust(sirinaStupca * 2) Ispuni…

Posted in Powershell Python

Epoch date time u ljudski oblik

powershell.ps1 $UnixTime = 1711000300 $epoch = [DateTime]::new(1970, 1, 1, 0, 0, 0, [DateTimeKind]::UTC) $date = $epoch.AddSeconds($UnixTime).ToLocalTime() python.py (hex epoch) import datetime VrijemeHex = "61a73207" VrijemeDec…

Posted in Python

Python – Pandas – u/iz CSV datoteke

DeijtaFreijm = pandas.read_csv ( "datoteka.csv" , encoding="utf-8-sig" , header = 0 , sep=";" , decimal="," ) DeijtaFreijm = pandas.read_csv ( "datoteka.csv" , encoding="utf-8-sig" , sep=";"…

Posted in Python

Python – Random string

import string import random LeRandom = ”.join ( random.choice ( string.ascii_letters + string.digits ) for x in range(16) ) print ( ‘Random:’ , LeRandom )…

Posted in Firefox Linux Python

Python Selenium Firefox Geckodriver webdriver_manager

Situacija Kradeš informacije s interneta korištenjem pythona seleniuma firefoxa webdriver-managera te geckodrivera. Problem Na naredbu driver = webdriver.Firefox ( options=options , service=Service(GeckoDriverManager().install())) browser se sruši…

Posted in Python

Python – Django – Kreiranje, pokretanje, rušenje projekta – ALLOWED_HOSTS išju

Problem Kreiraš Džango projektum %NazivProjekta% naredbom django-admin startproject %NazivProjekta% te pokreneš istoimeni Đango projekt naredbom python manage.py runserver 0.0.0.0:8000 te se spojiš s klijenta na…