- 1
We’ve heard your feedback that you want Visual Basic on .NET Core
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
We’ve heard your feedback that you want Visual Basic on .NET Core
https://devblogs.microsoft.com/vbteam/visual-basic-support-planned-for-net-5-0/
0
for course_id in COURSES: #конфиги для слабаков, реальные пацаны хардкодят константы
participants = {}
print(f'Downloading course {course_id}...')
assignments = M.get_modules(course_id, 'assign')
captions = {item['instance'] : item['name'] for item in assignments}
rawsubs_per_assignment = M.get_submissions(captions.keys())
files = []
print('\tParsing assignments... ',end='')
for i,assign in ProgressBar.each(rawsubs_per_assignment, length=50, donefmt='[OK]\n', errorfmt='[FAIL]\n'):
#самописный прогресс-бар. В скрипте, который 90% времени запускается как демон.
assign_id = assign['assignmentid']
if assign_id not in participants:
lst = M.list_participants(assign_id)
participants[assign_id] = {i['id'] : i['fullname'] for i in lst}
for rs in assign['submissions']:
subfiles = M.get_submission_files(rs)
for sf in subfiles:
f = StoredFile( #самописный псевдо-ORM
id = None,
url = sf['fileurl'],
filename = sf['filename'],
downloaded = False,
size = sf['filesize'],
mimetype = sf['mimetype'],
timestamp = sf['timemodified'],
course = course_id,
instance = assign_id,
submission = rs['id'],
userid = rs['userid'],
username = participants[assign_id][rs['userid']])
files.append(f)
print('\tTotal of {0} assignments and {1} files.'.format(len(participants), len(files)))
print('\tUpdating database... ', end='')
with DB:
for i,f in ProgressBar.each(files, captionfunc = (lambda f:f.filename),
length=25, valuefmt='{ratio:.0%} ', donefmt='[OK]\n', errorfmt='[FAIL]\n'):
DB.update_file(f) #execute_many()? зачем? И так сойдёт.
files_to_download = list(DB.get_nonready_files())
if not files_to_download:
print('All files are up to date.')
else:
ok_count = 0
error_count = 0
print('Downloading missing files... ',end='')
for i,f in ProgressBar.each(files_to_download,
captionfunc = (lambda f: f'[{error_count} errors] {f.filename}'),
length=25, valuefmt='{ratio:4.0%} ', donefmt='[OK]\n', errorfmt='[FAIL]\n'):
#исчо один прогрессбар
path = localpath(f)
dir = os.path.dirname(path)
os.makedirs(dir, exist_ok = True)
if not verify(f):
try:
with open(path, "wb") as dest:
#зачем проверять размер скачиваемого файла или наличие контента?
source = M.get_download_fileobj(f.url)
shutil.copyfileobj(source, dest)
DB.mark_downloaded(f)
except:
error_count += 1
else:
ok_count += 1
else:
ok_count += 1
if error_count > 0:
print(f'{error_count} files failed to download!')
comparisons = list(DB.get_files_to_match())
if comparisons:
print('Matching non-compared files... ',end='')
log = open('errors.txt', 'wt', encoding='utf-8') #logging для слабаков
for i,(f1,f2) in ProgressBar.each(comparisons, length=25, valuefmt='{pos}/{max}', donefmt='[OK]\n', errorfmt='[FAIL]\n'):
#оптимизировать цикл, чтобы не читать один и тот же файл по 50 раз? Нафиг, работает же.
path1, path2 = localpath(f1), localpath(f2)
ok = True
if not verify(f1):
ok = False
DB.mark_downloaded(f1, False)
if not verify(f2):
ok = False
DB.mark_downloaded(f2, False)
if ok:
content1, content2 = None, None
try:
content1 = extract_content(path1)
content2 = extract_content(path2)
similarity = compare_content(content1, content2)
except Exception as E:
if content1 is None:
log.write(path1+'\n')
elif content2 is None:
log.write(path1+'\n')
else:
log.write('Comparison error!\n')
log.write(str(E)+'\n')
else:
DB.save_diff(f1, f2, similarity)
finally: #пусть сборщик мусора порадуется
del content1
del content2
log.close()
Написал тут скрипт, самому стыдно.
Но работает.
0
https://ru.wikihow.com/%D0%B8%D0%B7%D1%83%D1%87%D0%B8%D1%82%D1%8C-PHP-%D0%B8-MySQL
+1
from selenium import webdriver
import time
import telegram
def A():
код парсера
while True:
browser = webdriver.Chrome()
browser.maximize_window()
browser.get('ссылка')
try:
BOT_TOKEN = 'токен'
number2 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[5]/div/div[1]/div[1]/div').text
SS = number2.split()
if SS[0] == '0' and SS[1] == '0':
browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[5]/div/div[1]/div[1]/a').click()
time.sleep(5)
A()
except Exception:
pass
try:
BOT_TOKEN = 'токен'
number2 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[4]/div/div[1]/div[1]/div').text
SS = number2.split()
if SS[0] == '0' and SS[1] == '0':
browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[4]/div/div[1]/div[1]/a').click()
time.sleep(5)
A()
except Exception:
pass
try:
BOT_TOKEN = 'токен'
number2 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[3]/div/div[1]/div[1]/div').text
SS = number2.split()
if SS[0] == '0' and SS[1] == '0':
browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[3]/div/div[1]/div[1]/a').click()
time.sleep(5)
A()
except Exception:
pass
try:
BOT_TOKEN = 'токен'
number2 = browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[6]/div/div[1]/div[1]/div').text
SS = number2.split()
if SS[0] == '0' and SS[1] == '0':
browser.find_element_by_xpath('//*[@id="games_content"]/div/div[1]/div/div/div[6]/div/div[1]/div[1]/a').click()
time.sleep(5)
A()
except Exception:
pass
browser.close()
time.sleep(15)
Вопросик с хабра)
+1
https://infostart.ru/public/72175/
1C.Net:Предприятие + DirectX = 3D-графика на формах 1С:Предприятие
Зачем? Зачем?
+3
Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.
МОЭК запустила дополнительный информационный сервис для москвичей о сроках отключения горячей воды
https://online.moek.ru
+1
Если НЕ Объект.Валютный Тогда
Объект.ПересчитыватьВалютнуюСумму=Ложь;
Иначе
Объект.ПересчитыватьВалютнуюСумму=Истина;
КонецЕсли;
Типовая УХ
0
#include <iostream>
#include <chrono>
#include <thread>
#include <fstream>
#include <string>
using namespace std;
float Cheking = 0;
void read_file()
{
string line;
ifstream file("text.bin");
if (file)
{
while (getline(file, line))
{
file >> Cheking;
}
file.close();
}
}
void write_file()
{
ofstream myfile("text.bin");
if (myfile.is_open())
{
myfile << "\n";
myfile << Cheking << "\n";
myfile.close();
}
else
{
cout << "Unable to open file";
myfile.close();
}
}
int main()
{
using namespace chrono;
using namespace this_thread;
setlocale(LC_ALL, "ukr");
read_file();
cout << "Число: " << Cheking << "\t\t";
cout << endl;
if (Cheking == 0)
{
cin >> Cheking;
}
write_file();
sleep_for(milliseconds(1000));
return 0;
}
Простой гавнокод для храненния переменных в файле.
+5
Скоро Новый год. Високосный год Крысы.
А ты уже загадал желание? ^_
https://www.youtube.com/watch?v=RpDfkJD4PYU
0
procedure TForm1.Button1Click(Sender: TObject);
var
RequestBody,SResponseBody: TStringStream;
ResponseBody: string;
begin
try
RequestBody := TStringStream.Create('{"login":"user","password":"pass999"}') ;
httpconn.HandleRedirects:=TRUE;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method:=sslvSSLv23;
//httpconn.Host:='api.owencloud.ru';
httpconn.Request.Accept:='application/xml';
httpconn.Request.ContentLength:=68;
httpconn.Request.ContentType:='application/x-www-form-urlencoded';
ResponseBody:=httpconn.Post('https://api.owencloud.ru/v1/auth/open', RequestBody);
SResponseBody:=TStringStream.Create(httpconn.Post('https://api.owencloud.ru/v1/auth/open', RequestBody));
memo1.Text:=utf8toansi(ResponseBody);
xmldocument1.LoadFromStream(SResponseBody);
finally
RequestBody.Free;
SResponseBody.Free;
end;
end;
Передача в мемо волшебна, а в xml так вообще виртуозна