Skip to content

Instantly share code, notes, and snippets.

@vinaghost
vinaghost / screenshot_selenium_headless.cs
Created February 8, 2025 04:05
C# screenshot selenium headless
var originalSize = browser.Driver.Manage().Window.Size;
var requiredWidth = (long)browser.Driver.ExecuteScript("return document.body.parentNode.scrollWidth");
var requiredHeight = (long)browser.Driver.ExecuteScript("return document.body.parentNode.scrollHeight");
browser.Driver.Manage().Window.Size = new System.Drawing.Size((int)requiredWidth, (int)requiredHeight);
var formattedDate = DateTime.UtcNow.ToString("yyyy-MM-dd");
var filename = $"{formattedDate}-{targetId}.png";
var profileElement = browser.Driver.FindElement(By.CssSelector("#playerProfile"));
@vinaghost
vinaghost / travian_buildings.py
Last active August 15, 2024 16:44
travian data in python array
buildings = [
{'cost': [40, 100, 50, 60], 'cp': 1, 'cu': 2, 'gid': 1, 'k': 1.67, 'maxLvl': 22, 'name': 'Woodcutter'} ,
{'cost': [80, 40, 80, 50], 'cp': 1, 'cu': 2, 'gid': 2, 'k': 1.67, 'maxLvl': 22, 'name': 'Clay Pit'} ,
{'cost': [100, 80, 30, 60], 'cp': 1, 'cu': 3, 'gid': 3, 'k': 1.67, 'maxLvl': 22, 'name': 'Iron Mine'} ,
{'cost': [70, 90, 70, 20], 'cp': 1, 'cu': 0, 'gid': 4, 'k': 1.67, 'maxLvl': 22, 'name': 'Cropland'} ,
{'cost': [520, 380, 290, 90], 'cp': 1, 'cu': 4, 'gid': 5, 'k': 1.8, 'maxLvl': 5, 'name': 'Sawmill', 'breq': {'1': 10, '15': 5}} ,
{'cost': [440, 480, 320, 50], 'cp': 1, 'cu': 3, 'gid': 6, 'k': 1.8, 'maxLvl': 5, 'name': 'Brickyard', 'breq': {'2': 10, '15': 5}} ,
{'cost': [200, 450, 510, 120], 'cp': 1, 'cu': 6, 'gid': 7, 'k': 1.8, 'maxLvl': 5, 'name': 'Iron Foundry', 'breq': {'3': 10, '15': 5}} ,
{'cost': [500, 440, 380, 1240], 'cp': 1, 'cu': 3, 'gid': 8, 'k': 1.8, 'maxLvl': 5, 'name': 'Grain Mill', 'breq': {'4': 5}} ,
{'cost': [1200, 1480, 870, 1600], 'cp': 1, 'cu': 4, 'gid
@vinaghost
vinaghost / villagecrawler_migration.sql
Last active July 16, 2024 16:53
migrate db village crawler
alter table "Alliances" add column "PlayerCount" int NOT NULL after "Name";
update Alliances
set Alliances.PlayerCount = (select count(*) from Players where AllianceId = Alliances.Id)
where Alliances.Id >= 0;
CREATE TABLE "AlliancesHistory" (
"Id" int NOT NULL AUTO_INCREMENT,
"AllianceId" int NOT NULL,
"Date" datetime(6) NOT NULL,
@vinaghost
vinaghost / cost_travian_building.js
Last active March 20, 2024 10:29
construct cost travian data to c#
var buildings = [
{name:"Woodcutter", cost: [ 40, 100, 50, 60], k:1.67, cu:2, cp:1, time:new TimeT3(1780/3,1.6, 1000/3),maxLvl:22, extra:1, type:1, desc:"Maximum level is 10, except capital — limited by stockyards there.", req: {capital: 10}},
{name:"Clay Pit", cost: [ 80, 40, 80, 50], k:1.67, cu:2, cp:1, time:new TimeT3(1660/3,1.6, 1000/3),maxLvl:22, extra:1, type:1, desc:"Maximum level is 10, except capital — limited by stockyards there.", req: {capital: 10}},
{name:"Iron Mine", cost: [ 100, 80, 30, 60], k:1.67, cu:3, cp:1, time:new TimeT3(2350/3,1.6, 1000/3),maxLvl:22, extra:1, type:1, desc:"Maximum level is 10, except capital — limited by stockyards there.", req: {capital: 10}},
{name:"Cropland", cost: [ 70, 90, 70, 20], k:1.67, cu:0, cp:1, time:new TimeT3(1450/3,1.6, 1000/3),maxLvl:22, extra:1, type:1, desc:"Maximum level is 10, except capital — limited by stockyards there.", req: {capital: 10}},
{name:"Sawmill", cost: [ 520, 380, 290, 90], k:1.80, cu:4, cp:1, time:new TimeT3( 54
@vinaghost
vinaghost / mysql_processlist.sh
Created February 3, 2024 03:11
show query stuck mysql
mysqladmin processlist -u root -p
mysqladmi kill id -u root -p
@vinaghost
vinaghost / drop_database.sql
Last active July 25, 2024 11:11
drop database
select CONCAT('drop database `', schema_name,'`;') as database_name from information_schema.schemata where schema_name like '%DATABASES_TO_REMOVE%' order by schema_name;
@vinaghost
vinaghost / .netpublishhommand.md
Created August 18, 2023 07:32
publish to my vps

dotnet publish MapSqlAspNetCoreMVC -c Release -p:PublishSingleFile=true -o bin/MapSqlAspNetCoreMVC -r linux-arm64 --self-contained

@vinaghost
vinaghost / setup_nginx.md
Created August 16, 2023 16:25
Setup Nginx
sudo mkdir -p /var/www/vinaworld.dynu.net/html
sudo chown -R $USER:$USER /var/www/vinaworld.dynu.net/html
sudo chmod -R 755 /var/www/vinaworld.dynu.net
sudo nano /var/www/vinaworld.dynu.net/html/index.html
<html>
    <head>
 Welcome to vinaworld.dynu.net!
@vinaghost
vinaghost / mysql_sizeInMB.txt
Created August 16, 2023 09:39
how many mb did my database use ? (mysql)
select table_schema "DB name (table_schema)",
sum( data_length + index_length ) / 1024 / 1024 "DB size in MB" from
information_schema.tables group by table_schema;
@vinaghost
vinaghost / tbs_changelogs.md
Last active August 12, 2025 04:52
TravianBotSharp Changelogs