Skip to content

Instantly share code, notes, and snippets.

View markormesher's full-sized avatar
🚀

Mark Ormesher markormesher

🚀
View GitHub Profile
@markormesher
markormesher / GetSmallCapsString.java
Last active November 21, 2023 19:13
Create a small-caps spannable string that will work with any font
/**
* Produce a formatted SpannableString object from a given String
* input, with all lowercase characters converted to smallcap
* characters. Uses only standard A-Z characters, so works with
* any font.
*
* @param input The input string, e.g. "Small Caps"
* @return A formatted SpannableString, e.g. "Sᴍᴀʟʟ Cᴀᴘs"
*/
public static SpannableString getSmallCapsString(String input) {
@markormesher
markormesher / RpsDemo
Created October 9, 2014 19:01
Rock/paper/scissors Python demo
done = False
while (done != True):
their_move = raw_input("What is your move? [r|p|s|q] ")
if (their_move == "r"):
print "You choose rock, I choose paper"
elif (their_move == "p"):
print "You choose paper, I choose scissors"
elif (their_move == "s"):
print "You choose scissors, I choose rock"
elif (their_move == "q"):
@markormesher
markormesher / kcltechpins.php
Created March 28, 2015 11:56
KCL Tech Election PIN Sender
<?php
// init mailer
require('/usr/share/php/Mail.php');
$factory =& Mail::factory('smtp',
array(
// SMTP auth info removed
)
);
$headers['From'] = 'Mark Ormesher <[email protected]>';
@markormesher
markormesher / SyncTest.java
Created May 18, 2015 16:42
Demonstrates deadlock between two objects calling synchronised methods of each other
public class SyncTest {
public static Obj1 obj1;
public static Obj2 obj2;
public static void main(String... args) {
obj1 = new Obj1();
obj2 = new Obj2();
Thread t1 = new Thread(new Runnable() {
@Override
@markormesher
markormesher / all-permissions.txt
Created July 19, 2015 16:57
All current MediaWiki permissions, as of v1.25.1
read, edit, createpage, createtalk, move, movefile, move-subpages, move-rootuserpages, createaccount, upload, reupload, reupload-own, reupload-shared, upload_by_url, editprotected, editsemiprotected, applychangetags, delete, bigdelete, deletedhistory, deletedtext, undelete, browsearchive, mergehistory, protect, block, blockemail, hideuser, unblockself, userrights, userrights-interwiki, rollback, markbotedits, patrol, patrolmarks, changetags, editcontentmodel, editinterface, editusercss, edituserjs, editmyusercss, editmyuserjs, editmywatchlist, viewmywatchlist, editmyprivateinfo, viewmyprivateinfo, editmyoptions, suppressrevision, viewsuppressed, deletelogentry, deleterevision, siteadmin, import, importupload, unwatchedpages, managechangetags, bot, purge, minoredit, nominornewtalk, noratelimit, ipblock-exempt, proxyunbannable, autopatrol, apihighlimits, writeapi, suppressredirect, autoconfirmed
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DbHelper extends SQLiteOpenHelper {
public DbHelper(Context context) {
super(context, Constants.DB_NAME, null, Constants.DB_VERSION);
}
@Override
// increment the ID
++notificationId;
// create a notification
NotificationCompat.Builder builder =
new NotificationCompat.Builder(BasicNotificationActivity.this)
.setContentTitle("This is notification #" + notificationId)
.setContentText("This is the text!")
.setAutoCancel(true)
.setSmallIcon(R.drawable.kcl_tech_logo)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.markormesher.blank_application"
minSdkVersion 15
targetSdkVersion 23
#!/bin/bash
# This script needs to go at the root of your source code.
# This script works with plain old Bash on Ubuntu - YMMV with other shells.
# You'll need to adjust the extensions and files that are included and ignored.
# DO NOT run this in the same folder as any other LaTeX work (look at the last line).
# This script is offered as-is and accept utterly no responsibility for whatever it does.
texFile="source.tex"
touch $texFile
@markormesher
markormesher / doubling-algorithm.md
Last active November 5, 2023 15:06
The Doubling Algorithm for Suffix Array Construction

The Doubling Algorithm for Suffix Array Construction

I'll use x = "banana", m = 6 as an example. The suffixes are:

0:  banana
1:  anana
2:  nana
etc.

First, we'll work out R1, which is the rank of each suffix according to it's first letter only. Because we're just comparing single letters, we can do it in Theta(m) with a bucket sort. There will be some duplicates, and that's fine. We only have three different letters, so we give all of the A's a rank of 0, all of the B's a rank of 1, and all of the N's a rank of 2. We end up with this: