Skip to content

Instantly share code, notes, and snippets.

@pfrozi
pfrozi / copy.sh
Created March 1, 2021 15:23
Create image file from clipboard on ubuntu
xclip -selection clipboard -t image/png -o > 00-login.png
@pfrozi
pfrozi / main.go
Created March 2, 2021 03:21
Truncate time from now
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(time.Now())
fmt.Println(time.Now().Truncate(24*time.Hour))
@pfrozi
pfrozi / set-cron.md
Last active October 28, 2021 17:25
Setting up a cron job in linux

CRONTAB SYNTAX

m h d M w /directory/command output

{m h d M w} specify the time/date and recurrence of the job

  • m(inunte) h(our) d(ay) M(onth) (day of)w(eek)
  • {/directory/command} specifies the location and comand you want to run
  • {output} is a optional segment. It defines how system notifies the user of the job completion
@pfrozi
pfrozi / bash-to-zsh-hist.py
Created May 6, 2021 20:36 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@pfrozi
pfrozi / query.sql
Created May 12, 2021 13:17
Get the statistics of the most executed queries on the Microsoft SQL Server Database.
SELECT TOP 100
DatabaseName = db_name(dest.dbid),
OBJECT_NAME(objectid) AS ObjectName,
last_execution_time,
execution_count,
total_cpu_time = total_worker_time / 1000,
avg_cpu_time = (total_worker_time / execution_count) / 1000.0,
min_cpu_time = min_worker_time / 1000.0,
max_cpu_time = max_worker_time / 1000.0,
last_cpu_time = last_worker_time / 1000.0,
@pfrozi
pfrozi / TestFlags.cs
Created June 22, 2021 16:37
Flags example
using System;
public class Program
{
public static void Main()
{
var e = Teste.Cliente | Teste.Documentos;
Console.WriteLine(e.HasFlag(Teste.Cliente));
Console.WriteLine(e.HasFlag(Teste.Liberacoes));
Console.WriteLine(e.HasFlag(Teste.Documentos));
@pfrozi
pfrozi / testregex.cs
Created June 23, 2021 17:44
Regex to test repeated character in C#
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
var hasRepeatedCharacter = new Regex(@"^([0-9]+)\1$");
string text = "123123";
@pfrozi
pfrozi / locks.sql
Last active March 18, 2024 21:26
Get all sessions with some statistics on sqlsever
USE master
go
SELECT
sdes.session_id
,sdes.login_time
,sdes.last_request_start_time
,sdes.last_request_end_time
,sdes.is_user_process
,sdes.host_name
,sdes.program_name
@pfrozi
pfrozi / test.sh
Created October 20, 2021 20:12
FortiClient on ubuntu
# Add fortisslvpn repository
sudo add-apt-repository ppa:ar-lex/fortisslvpn
sudo apt-get update
sudo apt-get install
# Calling
openfortivpn vpn.xxxxxx.com.br:10443 -u pedro.xyz -p ****** --trusted-cert xyz
@pfrozi
pfrozi / opelssl.cnf
Created November 1, 2021 18:37
How to configure a openssl.cnf
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
openssl_conf = default_conf
####################################################################
[ default_conf ]