Skip to content

Instantly share code, notes, and snippets.

View damiankw's full-sized avatar

Damian West damiankw

View GitHub Profile
@damiankw
damiankw / nl2sql2nl-dev01.py
Created October 29, 2025 01:27
A very basic python script to query Ollama with a natural language prompt and have it return a natural language response after querying a database for information.
import os, re, json, requests, mysql.connector
from textwrap import dedent
MYSQL_CONFIG = {
"host": "127.0.0.1",
"port": 3306,
"user": "mydbuser",
"password": "mydbpassword01",
"database": "mydb",
}
@damiankw
damiankw / kill-vscode-server.sh
Created October 22, 2025 10:18
A quick script to delete those pesky vscode node servers polluting a Remote-SSH
#!/bin/bash
# kill-vscode-server.sh - Script to kill VS Code server processes
# Configure:
# nano kill-vscode-server.sh
# chmod +x kill-vscode-server.sh
# Usage:
# Interactively, with confirmation prompt
# ./kill-vscode-server.sh
@damiankw
damiankw / git.php
Last active May 29, 2023 12:35
PHP Git Version
<?php
// git.php
class git {
function mini_hash() {
return substr(file_get_contents('.git/'. trim(explode(' ', file_get_contents('.git/HEAD'))[1])), 0, 7);
}
function hash() {
return trim(file_get_contents(".git/". trim(explode(" ", file_get_contents(".git/HEAD"))[1])));
@damiankw
damiankw / usr_mode.tcl
Last active December 29, 2018 02:11
svr_user.tcl/usr_modechange
proc usr_mode {nick target mode args} {
call usr:rawmode $nick $target $mode $args
# this happens when a mode is changed (for channel or user) in the form of:
# MODE <target> +mo-de arg arg arg
# it then breaks it up and sends it to usr_modechange in the form of:
# MODE <target> +m
# MODE <target> +o arg
# MODE <target> -d arg
# MODE <target> -e arg
<?php
// details for your database
$DB = array(
'hostname' => 'localhost',
'username' => 'gamedb',
'password' => 'gamedb1234!',
'database' => 'gamedb'
);
<?php
$val1 = $_REQUEST ['val1']; // calc.php?val1=<num> (or POST/COOKIE)
$val2 = $_REQUEST ['val2']; // calc.php?val2=<num> (or POST/COOKIE)
$calc = $_REQUEST ['calc']; // calc.php?calc=<add|sub|mul|div> (or POST/COOKIE)
if (is_numeric ($val1) && is_numeric ($val2)) { // check if we have a number for val1/val2
$result = 0; // set the default result to 0
switch ($calc){ // check the value of calc
case "add" : // if calc is 'add', add up the two numbers
package net.nictitate.boredBOT;
public class GetServer {
private boredBOT client;
public static void process(boredBOT client, String read_data) {
System.out.println("<- " + read_data);
if (read_data.length() == 0) {
// just some santising, in case nothing comes through
@damiankw
damiankw / ModifyDateTaken.vb
Created April 18, 2017 09:01
Comes up with a DateTaken if there isn't already one.
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Text
Module ModifyDateTaken
Private DATE_TAKEN = &H132 ' Code for date taken
Private DateNull = DateTime.ParseExact("1000/01/01 01:01:01", "yyyy/MM/dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) ' A 'Null' type thing, because I couldn't be bothered working how to Null a date..
Sub Main()
<?php
/* ssl.php
* ssl lookup
*
* Needs to be stored in DB, Run via Cron and Have a front end to allow users to add/remove and run manually -
*
*/
// check the ssl expiry dates for certain sites
@damiankw
damiankw / list.php
Created October 10, 2016 08:22
assisting /u/NotYourIT
<?php
/* list.php
* Assisting /u/NotYourIT
* URL: https://www.reddit.com/r/PHPhelp/comments/53aah1/php_reading_text_file_with_eol_marker_and_eof/
*/
// your grades file
$FILE = 'grades.txt';
// open the grades file