Skip to content

Instantly share code, notes, and snippets.

View PPartisan's full-sized avatar
:octocat:
Focusing

Tom Calver PPartisan

:octocat:
Focusing
View GitHub Profile
@PPartisan
PPartisan / roky_help.md
Last active October 18, 2024 19:35
Roky Markdown Sample

Roky Help


The Roky parser supports very simple markdown, specifically headers (all headers are treated the same), italics, bold, hyperlinks and "hard" line breaks, which are denoted by an empty line beginning with a back-slash.
Crucially, all formatted words and phrases will render in Roky on separate lines. This is because the renderer does not allow for formatting distinct sections of text, but must instead create new containers and apply the formatting to that container. Should you wish to add some formatted text, which includes headers, itatlics, bold, hyperlinks and hard line breaks, then place each one on its own line.
GitHub - Roky GitHub - roky_help.md

Chat App

Project Description

"Chat App" is a desktop command-line application that allows small groups of authorized users to securely communicate. Version 1 will start with simple features, but the app is designed to easily grow into a GUI desktop or mobile application as we develop it further. Planned features include group collaboration tools, such as polling systems, calendar scheduling, and APIs for data gathering and research.

Features

  • Users can authenticate and sign in.
  • Authenticated users can join a single chat room to communicate.
  • Chat history is retained remotely for access at each login.
@PPartisan
PPartisan / HiLo.java
Last active January 14, 2024 15:31
HiLo.java
import java.util.*;
public class HiLo {
int random;
int guess;
public void generateNumber() {
random = (int)(Math.random()*100)+1;
}
@PPartisan
PPartisan / FileUtils.java
Last active April 4, 2023 10:39
StackOverflow sample for file traversal and a few tests
public final class FileUtils {
//Private constructor
static List<File> fetchSongs(File rootDir){
final File[] files = rootDir.listFiles();
if(isEmpty(files))
return Collections.emptyList();
return fetchSongs(files);
}
@PPartisan
PPartisan / MainActivity.java
Created November 2, 2016 22:05
Quick sample layout for a login screen using support libraries
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
@PPartisan
PPartisan / SwitchCompatStateListUtils.java
Last active September 10, 2018 10:56
Utility methods that create a ColorStateList for use with SwitchCompat. Allows for dynamic colour changes.
private static final int SWITCH_STATE_LIST_ALPHA = (int)(0.3f*255);
public static ColorStateList buildSwitchCompatColorStateListFromResId(
Context context, int activatedColorResId) {
return buildSwitchCompatColorStateList(
context, ContextCompat.getColor(context, activatedColorResId)
);
}
public static ColorStateList buildSwitchCompatColorStateList(Context context, int activatedColor) {
@PPartisan
PPartisan / DataModel.java
Created October 13, 2016 19:11
Supporting code for a Quora question regarding how to notify a caller that a method must be run off the UI thread.
%package com.github.ppartisan.watchface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.Asset;
import com.google.android.gms.wearable.DataItem;
@PPartisan
PPartisan / AndroidManifest.xml
Created September 19, 2016 11:02
Demo for an Android app that interacts with the browser and its bookmarks (API < 22)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.ppartisan.bookmarklet">
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@PPartisan
PPartisan / SpannedStringUtils.java
Created July 21, 2016 09:32
Method for converting text to a SpannableString, depending on
private static SpannableString getSpannedString(String text, char... triggers) {
SpannableString spanString = new SpannableString(text);
for (int i = 0; i < spanString.length(); i++) {
for (char trigger : triggers) {
if (spanString.charAt(i) == trigger) {
spanString.setSpan(new ForegroundColorSpan(Color.CYAN), i, i+1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
public static char[] reverseCharArray(char[] input){
char[] output = new char[input.length];
char temp;
int index = 0;
for (int i = (output.length - 1); i >= (output.length/2); i--) {
temp = input[i];
output[i] = input[index];
output[index] = temp;