Skip to content

Instantly share code, notes, and snippets.

View jasny's full-sized avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / sha256-hmac.md
Last active January 6, 2026 23:12
Hashing examples in different languages

Example inputs:

Variable Value
key the shared secret key here
message the message to hash here

Reference outputs for example inputs above:

| Type | Hash |

@jasny
jasny / magic_8_ball.php
Last active October 22, 2025 22:48 — forked from happy-box/magic_8_ball.py
Simple magic 8-ball game written in PHP
#!/usr/bin/env php
<?php
/**
* Magic 8 Ball IRC bot
* Created by Lance Brignoni
* Converted to PHP by Arnold Daniels
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@jasny
jasny / mysql_splitdump.sh
Last active February 27, 2025 17:45
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@jasny
jasny / ai-translate
Created October 8, 2024 19:20
Python script to translate a text using OpenAI GPT 4o-mini
#!/bin/env python
from openai import OpenAI
import sys
import os
import argparse
def translate_stdin_to_stdout(target_language, translate_lines=False, translate_po=False, instructions=""):
client = OpenAI()
@jasny
jasny / flip.js
Created March 27, 2014 13:32
Turn text upside down with JavaScript
//this script is based on coding by Reverse Fad http://www.revfad.com
function flip() {
var result = flipString(document.f.original.value.toLowerCase());
document.f.flipped.value = result;
}
function flipString(aString) {
var last = aString.length - 1;
var result = new Array(aString.length)
for (var i = last; i >= 0; --i) {
var c = aString.charAt(i)
@jasny
jasny / HTMLToXMLFilter.php
Created June 26, 2014 10:41
Stream filter to convert HTML5 to XML
<?php
/**
* Stream filter to convert HTML5 to XML.
*
* <code>
* $dsn = "php://filter/read=htmltoxml/resource=" . $url;
* $xml = XMLReader::open($dsn);
* </code>
*
@jasny
jasny / CMakeList.txt
Created October 7, 2019 01:21
CMake configuration for php-src
cmake_minimum_required(VERSION 3.8)
project(php C)
# 32bit or 64bit
set(BITNESS 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
endif()
# Global definitions
@jasny
jasny / linkify.php
Last active May 26, 2024 20:40
PHP function to turn all URLs in clickable links
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @return string
*/
public function linkify($value, $protocols = array('http', 'mail'), array $attributes = array())
@jasny
jasny / index.html
Created March 12, 2024 14:43
Ice Breaker (LangChain course)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ice Breaker</title>
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@chgibb/css-spinners@2.2.1/css/spinner/three-quarters.min.css">
</head>
<body>
<header>
@jasny
jasny / .htaccess
Created May 30, 2012 14:53
Thumbnail creator in PHP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ../thumb.php [QSA,L]
</IfModule>