Skip to content

Instantly share code, notes, and snippets.

View Davidblkx's full-sized avatar

David Pires Davidblkx

View GitHub Profile
@Davidblkx
Davidblkx / new_work_pc.ps1
Last active March 9, 2022 18:04
script install new pc
# login in windows store
######## install and reload ########
winget install scoop
winget install vscode
####################################
winget install Microsoft.WindowsTerminal
winget install cpu-z
winget install SlackTechnologies.Slack
winget install mozilla.firefox
@Davidblkx
Davidblkx / windefender.ps1
Created July 21, 2021 08:03
Enable disable windows defender real time protection
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" +$myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$status = (-Not (Get-MpPreference).DisableRealtimeMonitoring)
Set-MpPreference -DisableRealtimeMonitoring $status
$status
@Davidblkx
Davidblkx / DELETE_ALL_TABLES.sql
Created October 30, 2020 14:18
Delete all tables in a SQL SERVER database
DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR
SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_SCHEMA + '].[' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + '];'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME
OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql
WHILE (@@FETCH_STATUS = 0)
@Davidblkx
Davidblkx / mmove.py
Created October 14, 2020 22:58
python script to keep pc alive
# /bin/python
import mouse
import time
(X, Y) = mouse.get_position()
mov = False
while True:
X = X + 1 if mov else X - 1
@Davidblkx
Davidblkx / keyboard.sh
Created May 18, 2020 22:43
Enable/Disable laptop keyboard using XINPUT
#/bin/bash
#######################################
# Enables or disables laptop keyboard #
#######################################
# Keyboard name to work with
KB_NAME="AT Translated Set 2 keyboard"
# Grab keyboard ID
KB_ID=$(xinput list | grep "$KB_NAME" | awk '{ print $7 }' | sed -r 's/id=//g')
#/bin/bash
# install docker in Fedora 32
# add repo
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
# use 31 version (There are no official support for 32)
sudo sed -i 's/$releasever/31/g' /etc/yum.repos.d/docker-ce.repo
@Davidblkx
Davidblkx / fizz-buzz.ts
Created September 30, 2019 20:50
Simple FizzBuzz in typescript
console.log('A basic FizzBuzz in typescript')
const START_NUMBER = 1;
const LAST_NUMBER = 100;
const FIZZ = 'Fizz';
const BUZZ = 'Buzz';
function calcFizzBuzz(n: number): string | number {
let toPrint = '';
@Davidblkx
Davidblkx / traefik.sh
Last active September 14, 2019 20:41
Install traefik for DOCKER + LET'S ENCRYPT
#!/bin/bash
# Install traefik for DOCKER + LET'S ENCRYPT
# RUN (./start.sh [DOMAIN] [EMAIL]) or change domain and email vars
DOMAIN=$1
EMAIL=$2
echo "running config for domain: ${DOMAIN} and email: ${EMAIL}"
read -p "Are you sure? " -n 1 -r
echo
@Davidblkx
Davidblkx / now-playing.sh
Created September 6, 2019 09:42
grabs and print the current playing song
#!/bin/bash
pacmd list-sink-inputs |\
grep media.name |\
sed -n -e 's/^.*media\.name = //p' |\
sed 's/"//g' |\
sed "s/'//g" |\
sed 's/playback stream//ig' |\
sed 's/playback//ig' |\
sed 's/AudioCallbackDriver//ig' |\
sed 's/AudioStream//ig' |\
@Davidblkx
Davidblkx / LevenshteinDistance.cs
Created November 10, 2016 17:45
Levenshtein Distance in c#
using System;
namespace Algorithms
{
public static class LevenshteinDistance
{
/// <summary>
/// Calculate the difference between 2 strings using the Levenshtein distance algorithm
/// </summary>
/// <param name="source1">First string</param>