Skip to content

Instantly share code, notes, and snippets.

View kbakdev's full-sized avatar
👋
dev

Kacper Bąk kbakdev

👋
dev
View GitHub Profile
@kbakdev
kbakdev / node_modules_sync.sh
Created February 5, 2024 14:49
node_modules sync
#!/bin/bash
REMOTE_USER=$1
REMOTE_HOST=$2
REMOTE_PATH="/home/$REMOTE_USER"
LOCAL_PATH=$(pwd)
echo "Zipping node_modules..."
zip -r -q ../node_modules.zip node_modules/*
#!/bin/bash
# Default values
button_count=8 # Total number of buttons
required_presses=-1 # Required number of buttons pressed (-1 means no requirement)
generate=false # Flag to check if we should generate combinations
# Function to display help
show_help() {
echo "Usage: $0 [-b BUTTON_COUNT] [-r REQUIRED_PRESSES] [-g]"
@kbakdev
kbakdev / ExportEventLogsToCSV.ps
Created May 28, 2023 18:34
Script that aggregates and exports event log data (Application, Security) from the last 5 days to a CSV file.
Set-Variable -Name EventAgeDays -Value 1
Set-Variable -Name CompArr -Value @("Localhost")
Set-Variable -Name LogNames -Value @("Security", "Application")
Set-Variable -Name EventTypes -Value @("Information", "Error", "Warning", "FailureAudit", "SuccessAudit")
Set-Variable -Name ExportFolder -Value "C:\"
$el_c = @()
$now = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($(Get-Date), [System.TimeZoneInfo]::Local.Id, 'GMT Standard Time')
$startdate=$now.adddays(-5)
$ExportFile=$ExportFolder + "mx_sugus_poc_" + $now.ToString("yyyy.MM.dd_hh.mm") + ".csv"
@kbakdev
kbakdev / fibonacci_recursive.go
Created May 5, 2023 12:49
Fibonacci Recursive Go
func FibonacciRecursive(n int) int {
if n <= 1 {
return n
}
return FibonacciRecursive(n-1) + FibonacciRecursive(n-2)
}
@kbakdev
kbakdev / binets_formula.go
Created May 5, 2023 12:44
Binet's Formula Go
func FibonacciBinet(n int) int {
sqrt5 := math.Sqrt(5)
phi := (1 + sqrt5) / 2
return int(math.Round(math.Pow(phi, float64(n)) / sqrt5))
}
psql -U username -W -h hostname -d dbname -f db_dump.sql
@kbakdev
kbakdev / main.js
Created May 14, 2022 17:43
screeps v2
var roleHarvester = require('role.harvester');
var roleUpgrader = require('role.upgrader');
module.exports.loop = function () {
for(var name in Game.creeps) {
var creep = Game.creeps[name];
if(creep.memory.role == 'harvester') {
roleHarvester.run(creep);
}
@kbakdev
kbakdev / gist:12b03f014d2cd2cb25b541f6d0ceb18b
Created May 14, 2022 17:36
loop for calling module role.harvester
var roleHarvester = require('role.harvester');
module.exports.loop = function () {
for(var name in Game.creeps) {
var creep = Game.creeps[name];
roleHarvester.run(creep);
}
}
var roleHarvester = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.store.getFreeCapacity() > 0) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
module.exports.loop = function () {
for(var name in Game.creeps) {
var creep = Game.creeps[name];
if(creep.store.getFreeCapacity() > 0) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}