Skip to content

Instantly share code, notes, and snippets.

View gcrbr's full-sized avatar

giancarlo gcrbr

View GitHub Profile
@gcrbr
gcrbr / main.c
Last active September 14, 2025 20:20
Tris
#include "tris.h"
int main() {
printf("New game - you are X\n");
char *stati[4] = {"Running", "Draw", "X Wins", "O Wins"};
Game *game = NULL;
if(new_game(&game) > -1) {
while(1) {
int row, col = 0;
printf("Your move (row,col): ");
@gcrbr
gcrbr / gaiola.sh
Created July 25, 2025 07:45
Script che controlla posti disponibili alla spiaggia dell'Area Marina Protetta Gaiola
# Utilizzo: ./gaiola.sh DATA TURNO
# Data: formato DD/MM (es. 28/01)
# Turno: 1 (mattina), 2 (pomeriggio)
year=$(date +"%Y")
fixed_date=$(echo $1 | awk -F'/' '{print $2"-"$1}')
date="$year-$fixed_date"
turno=$2
@gcrbr
gcrbr / duck.sh
Last active July 15, 2025 09:17
Use DuckDuckGo's AI chat from terminal. Only requires curl
vqd=""
current_payload=""
send_chat_message() {
out=$(curl -s -v -X POST 'https://duckduckgo.com/duckchat/v1/chat' -H "Cookie: dcm=3; dcs=1" -H "Referer: https://duckduckgo.com/" -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" -H "x-vqd-4: $vqd" -H 'Content-Type: application/json' -d "$current_payload" 2>&1)
req_body=$(echo "$out" | awk 'BEGIN{a=0;b=0;}{if($1=="<"){a=1;} if(a==1&&$1=="{"){b=1;} if(b>0){b+=1;} if(b>3){print $0}}')
if [[ ! "$req_body" =~ \{\"action\":\"error\" ]]; then
msg=""
append=""
@gcrbr
gcrbr / ddgaichat.py
Last active February 20, 2025 00:58
Simple python module to use DuckDuckGo's free AI chat.
import requests, json
'''
API Exception class
'''
class APIException(Exception):
def __init__(self, status, _type):
super().__init__(f'[{status}] {_type}')
self.status = status
self.type = _type