Skip to content

Instantly share code, notes, and snippets.

View jacob-g's full-sized avatar
🚀
All systems go

Jacob Goldberg jacob-g

🚀
All systems go
View GitHub Profile
@jacob-g
jacob-g / DiscussionParser-modified.php
Created December 15, 2023 19:59
Modified MediaWiki Echo DiscussionParser to support ScratchSig
/**
* From a line in the signature, extract all the users linked to
*
* @param string $line Line of text potentially including linked user, user talk,
* and contribution pages
* @return string[] array of usernames, empty array for none detected
*/
public static function extractUsersFromLine( $line ) {
/*
* Signatures can look like anything (as defined by i18n messages
@jacob-g
jacob-g / topicindex.txt
Created December 10, 2013 00:10
This is a list of all of the topics that were on the Scratch 1.X forums. It is designed to find the ID using the subject.
This file has been truncated, but you can view the full file.
100-Pronunciation Analysing-comparing for ESL students
1000-Right Here Waiting Karaoke
10000-subject of projects
100000-iScribble?
100001-PeteCraft [BukkitPro Needed] [Hamachi]
100002-Sprite Problems
100003-Fighting with a different style.
100004-Want to Add one of Your Projects to our Project Library Today?
100005-Basketball Engine Collaboration
100006-Hilarious Video: Team Fortress 2 Meets Wrestler Interview
@jacob-g
jacob-g / acid.au3
Created May 30, 2020 18:54
ACID programming language - this is something I did in about 2010, just posting for historical value
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: jvvg Industries Corporation
Script Function:
To create a programming interface.
Script Title:
Advanced Computer Integrated Development
@jacob-g
jacob-g / LocalSettings-addition.php
Created March 6, 2018 23:01
Hiding Special:BlockList in MediaWiki
<?php
//See https://lists.wikimedia.org/pipermail/mediawiki-l/2009-June/031231.html for what I modeled this after
//add the following code to the end of your LocalSettings.php file
function restrictBlockList(&$list) {
global $wgUser;
if (!$wgUser->isAllowed('block')) {
unset($list['BlockList']);
}
}
$wgHooks['SpecialPage_initList'][]='restrictBlockList';
@jacob-g
jacob-g / wikicounter.php
Created September 16, 2013 00:08
Improved Scratch Wiki Vote Counter (PHP) - algorithm based on blob8108's, but implemented in PHP
<?php
$data = file_get_contents('http://wiki.scratch.mit.edu/w/api.php?action=query&titles=Scratch%20Wiki:Votes%20For%20Admin%202013&prop=revisions&rvprop=content&format=xml&salt=' . md5(time()));
$xml = new SimpleXMLElement($data);
$votes = (string) ($xml->query->pages->page->revisions->rev);
$lines = explode("\n", $votes);
$vote_lines = array();
foreach ($lines as $val) {
if (preg_match('%^\| *[A-z]%msi', $val)) {
$vote_lines[] = $val;
}
@jacob-g
jacob-g / getposts.php
Created September 15, 2013 17:06
This is the code to convert the Scratch Forums into HTML pages. The file topics.txt must be writable and in the same directory as getposts.php, and a writable directory called "res" must also be in the same directory as getposts.php. The results will appear in the format res/*id*/page-*page*.html (e.g. topic 5 page 3 would appear as res/5/page-3…
<?php
function percentbar($pct) {
$pct = floor($pct);
$half = false;
for ($j = 1; $j <= 50; $j++) {
if ($j > 22 && $j < 27) {
if (!$half) {
echo '[' . sprintf('%2d', $pct) . '%]';
$half = true;
}
@jacob-g
jacob-g / hooks.php
Last active August 29, 2015 14:24
A sample of a FutureBB hooks file
<?php //this example requires usernames to be >= 10 characters when registering
$hooks = array();
$hooks['review_registration'] = array(
function($args) {
global $errors;
if (strlen($args['username']) < 10) {
$errors[] = 'Your username must be >=10 characters';
return false;
}
}
<?php
//sherpinski triangle fractal generator for PHP
//Copyright (C)2015 FutureSight Technologies - all rights reserved, do not copy
$iterations = input('Iterations?');;
$squaresize = input('Size?');
function input($prompt) {
echo $prompt . ' ';
$line = fgets(STDIN);
return (int)strtok($line, "\n");