Skip to content

Instantly share code, notes, and snippets.

Avatar

Arnold Daniels jasny

View GitHub Profile
@jasny
jasny / .htaccess
Created May 30, 2012 14:53
Thumbnail creator in PHP
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ../thumb.php [QSA,L]
</IfModule>
@jasny
jasny / image-embed-html.php
Created October 23, 2012 10:40
Create base64 encoded image to embed in HTML
View image-embed-html.php
<?php
$files = array_slice($argv, 1);
foreach ($files as $file) {
$picture = file_get_contents($file);
$size = getimagesize($file);
// base64 encode the binary data, then break it into chunks according to RFC 2045 semantics
$base64 = chunk_split(base64_encode($picture));
@jasny
jasny / magic_8_ball.php
Last active May 11, 2023 11:05 — forked from happy-box/magic_8_ball.py
Simple magic 8-ball game written in PHP
View magic_8_ball.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 / create.php
Created April 23, 2020 02:34
Stripe example PHP code
View create.php
<?php
require 'vendor/autoload.php';
// This is a sample test API key. Sign in to see examples pre-filled with your key.
\Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
# retrieve JSON from POST body
header('Content-Type: application/json');
$json_str = file_get_contents('php://input');
@jasny
jasny / sha256-hmac.md
Last active March 16, 2023 11:53
Hashing examples in different languages
View sha256-hmac.md

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 / linkify.php
Last active February 6, 2023 22:39
PHP function to turn all URLs in clickable links
View linkify.php
<?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 / flip.js
Created March 27, 2014 13:32
Turn text upside down with JavaScript
View flip.js
//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 / mysql_splitdump.sh
Last active December 15, 2022 18:18
Split MySQL dump SQL file into one file per table or extract a single table
View mysql_splitdump.sh
#!/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
View multisig.ride
#define public keys
let alicePubKey = base58'5AzfA9UfpWVYiwFwvdr77k6LWupSTGLb14b24oVdEpMM'
let bobPubKey = base58'2KwU4vzdgPmKyf7q354H9kSyX9NZjNiq4qbnH2wi2VDF'
let cooperPubKey = base58'GbrUeGaBfmyFJjSQb9Z8uTCej5GzjXfRDVGJGrmgt5cD'
#check whoever provided the valid proof
let aliceSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], alicePubKey ) || sigVerify(tx.bodyBytes, tx.proofs[1], alicePubKey )) then 1 else 0
let bobSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], bobPubKey ) || sigVerify(tx.bodyBytes, tx.proofs[1], bobPubKey )) then 1 else 0
let cooperSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey) || sigVerify(tx.bodyBytes, tx.proofs[1], cooperPubKey)) then 1 else 0
@jasny
jasny / lto-tx-csv
Last active October 12, 2022 01:27
LTO get transactions of address as CSV
View lto-tx-csv
#!/bin/bash
ADDRESS="$1"
TOTAL=$(curl -s -I "https://nodes.lto.network/index/transactions/addresses/$ADDRESS" | grep x-total | awk '{printf "%d",$2}')
seq -w 00000 100 $TOTAL | xargs -P 10 -I'{}' curl -s "https://nodes.lto.network/index/transactions/addresses/$ADDRESS?limit=100&offset={}" -o "$ADDRESS.{}.json"
jq -s add $ADDRESS.*.json > "$ADDRESS.json"
rm $ADDRESS.*.json