Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@davepcallan
davepcallan / ChatGPTAPIExample.cs
Created March 7, 2024 13:02
Simple example of integrating with ChatGPT API from .NET
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Text;
using System.Text.Json;
namespace Samples;
public class ChatGPTAPIExample(ILogger<ChatGPTAPIExample> logger, IConfiguration configuration)
{
private string Prompt = "Please explain the following code :";
@olmosleo
olmosleo / postfix_admin_tools.txt
Last active April 23, 2024 00:30
Postfix Admin Tools - Comandos para administración de POSTFIX
# Deleting mail from MAIL-DAEMON in queue
for i in `mailq | grep MAILER-DAEMON | cut -f 1 -d " "`; do postsuper -d $i ; done
# So you get the number of all active mails with the command:
postqueue -p | egrep -c "^[0-9A-F]{10}[*]"
# and the number of all deferred mail with:
postqueue -p | egrep -c "^[0-9A-F]{10}[^*]"
# muestra cola
@leocomelli
leocomelli / git.md
Last active April 23, 2024 00:28
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@gioamato
gioamato / gdcr.gs
Last active April 23, 2024 00:18
Google Apps script to restore Google Drive files to a previous version after a cryptolocker attack
// GDCR - Google Drive Cryptolocker Restore
// Ref. https://stackoverflow.com/questions/67374118/revert-all-files-in-a-google-drive-directory-to-old-version
// Configuration
// Note: Add Drive to the Services area and login with your account on the first run
var folderId = '0AIwBM53EGRt-Uk9PVA' // Enter folder Id here (from browser, after .../folders/ path)
var virusAttackDate = new Date("2022-11-11"); // Attack date in "YYYY-MM-DD" format
var virusExtension ='h777XRgNVM777xM'; // Enter cryptolocker file extension
@dawidof
dawidof / optimization.rake
Created February 6, 2023 17:29 — forked from merqlove/optimization.rake
PostgreSQL optimization tasks for ActiveRecord
namespace :optimization do
desc "Provide DB vacuum for production environment"
task :vacuum => :environment do
begin
tables = ActiveRecord::Base.connection.tables
tables.each do |table|
ActiveRecord::Base.connection.execute("VACUUM FULL ANALYZE #{table};")
end
rescue Exception => exc
Rails.logger.error("Database VACUUM error: #{exc.message}")
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 22, 2024 23:58
set -e, -u, -o, -x pipefail explanation
@sainnhe
sainnhe / gruvbox-material-alacritty.yml
Last active April 22, 2024 23:51
Gruvbox Material for Alacritty
# The definition of color schemes.
schemes:
gruvbox_material_hard_dark: &gruvbox_material_hard_dark
primary:
background: '0x1d2021'
foreground: '0xd4be98'
normal:
black: '0x32302f'
red: '0xea6962'
green: '0xa9b665'
@riipandi
riipandi / linux-cmd-cheatsheet.md
Created July 12, 2012 12:16
Linux Command Cheat Sheet

#Linux Cheat Sheet

##File Commands:

  • ls – directory listing
  • ls -al – formatted listing with hidden files
  • cd dir - change directory to dir
  • cd – change to home
  • pwd – show current directory
  • mkdir dir – create a directory dir
  • rm file – delete file
[
"1185030898148724777",
"956131521733984287",
"956097947727179806",
"1185045871478448242",
"932096380879667253",
"956246550152118374",
"928549000431407164",
"976786710836944936",
"956128945227567145",
@Jibbarth
Jibbarth / 1.PHP_OAuth_CLI.md
Last active April 22, 2024 23:34
⚡Recreate Github CLI OAuth feature in a Symfony command ⚡

⚡Recreate Github CLI OAuth feature in a Symfony command ⚡

Github recently released a CLI tool to manage issues and PR directly from your terminal. As I work on some open source projects, I downloaded it to give a try.

And at first launch, the CLI ask to connect by using OAuth. It propose to press "Enter" to open github.com in my browser, and catch correctly the access_token.

That .. blown my mind 🤯 I didn't expect we can connect through terminal like this. So, as it's open source, I dived into the code source.