Skip to content

Instantly share code, notes, and snippets.

View JekRock's full-sized avatar

Yevhen Badorov JekRock

  • Ukraine
View GitHub Profile
@JekRock
JekRock / code.txt
Created November 18, 2023 07:38
Telegram code formatting
```javascript
// code is here
```
@JekRock
JekRock / pom.xml
Created August 10, 2023 08:29
Java build jar with dependencies using maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-project</artifactId>
<version>1.0</version>
@JekRock
JekRock / countLines.go
Created May 4, 2023 08:35
Fast line counter in Go
// source https://stackoverflow.com/questions/24562942/golang-how-do-i-determine-the-number-of-lines-in-a-file-efficiently
func lineCounter(r io.Reader) (int, error) {
buf := make([]byte, 32*1024)
count := 0
lineSep := []byte{'\n'}
for {
c, err := r.Read(buf)
count += bytes.Count(buf[:c], lineSep)
@JekRock
JekRock / userChrome.css
Created April 2, 2022 13:06
Firefox hide tabs bar
#TabsToolbar > .toolbar-items,
#TabsToolbar > .titlebar-spacer{ visibility: hidden }
#nav-bar{ margin-top: -43px;padding: 1px 140px 2px 3px !important; }
@JekRock
JekRock / CopyDirectory.cs
Created September 4, 2017 17:25
Copy directory with directory structure
using System;
using System.IO;
class DirectoryCopyExample
{
static void Main()
{
// Copy from the current directory, include subdirectories.
DirectoryCopy(".", @".\temp", true);
}
@JekRock
JekRock / CopyFolder.ps1
Created September 4, 2017 17:24
Copy files with folder structure
Copy-Item c:\fso –destination \\server1\share -recurse -container
$date = Get-Date -format "yyyyMMdd"
$date | Out-File c:\test.txt
$text = Get-Content c:\test.txt
$date = [datetime]::ParseExact($date, "yyyyMMdd", $null)
@JekRock
JekRock / GetFilesNewerThatDate.ps1
Created September 3, 2017 18:31
Get list of files modified after date
Get-ChildItem -Path . -Recurse| ? {$_.LastWriteTime -gt (Get-Date).AddDays(-4)}
@JekRock
JekRock / CopySharedFile.ps1
Last active September 3, 2017 18:10
Copy files to shared folder with credentials
#Get local credentials
$mycredentials = Get-Credential
#Create credentials object
$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
Start-BitsTransfer -DisplayName MyJob -Credential $mycreds -Source "http://server01/servertestdir/testfile1.txt" -Destination "c:\clienttestdir\testfile1.txt
@JekRock
JekRock / IsFileLocked.cs
Created September 2, 2017 08:02
Check is file locked
protected virtual bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (IOException)
{