Skip to content

Instantly share code, notes, and snippets.

View ChrisAkridge's full-sized avatar

Chris Akridge ChrisAkridge

View GitHub Profile
@ChrisAkridge
ChrisAkridge / suppressionData.cs
Created February 20, 2016 05:26
suppressionData
public class suppressionData
{
// ... properties go here ...
public override void Equals(object obj)
{
if (!(obj is suppressionData))
{
return false;
}
@ChrisAkridge
ChrisAkridge / Bookmarklet
Last active April 9, 2023 13:28
Rebuild the Universe scripts
javascript:(function()%7Bfunction%20callback()%7Binit()%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fcdn.rawgit.com%2FCelarix%2Fcd009edde135c196f6a8%2Fraw%2F54297cb3fc7d30220676224e444e7ab61a144ae5%2Frtu_scripts.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()
string[] names = new string[userlist.Length] // or however Java handles array init and array length, idunnolo
for (int i = 0; i < userlist.Length; i++)
{
names[i] = userlist[i].getNick();
}
// use names here
public class IndexerExample1
{
int[] array = new int[] { 1, 2, 3 };
public int this[int index]
{
// like properties, indexers have getters and setters, but the main difference is the index
get
{
return this.array[index];
/// <summary>
/// Returns the cell number for a given position.
/// </summary>
/// <param name="position">The position to return for.</param>
/// <returns>The cell number for the given position.</returns>
public Point GetCellAtPosition(Vector2 position)
{
int x = (int)(position.X / this.CellWidth);
int y = (int)(position.Y / this.CellHeight);
@ChrisAkridge
ChrisAkridge / gist:5775292
Created June 13, 2013 16:41
Special command syntax handling.
public string[] SeparateCommandLine(string commandLine)
{
commandLine = commandLine.Trim(); // trim the starting and ending spaces/tabs off the line
string[] words = commandLine.Split(' '); // split the string into "words" by spaces
string command = words[0]; // the first "word" is guaranteed to be the command name
// Now, since the values contain spaces, the remainder of the words array is the values.
// For example, the command line "COMMAND_NAME value value value" would, when split into an array, look like
// { "COMMAND_NAME", "value", "value", "value" }
// To get the value back, we need to combine every string in the array except the first.
// ...
j++;
string searchtext="The Marked for Review status";
int indexToText =richTextBox3.Find(searchtext);
int endIndex =searchtext.Length;
richTextBox3.Select(indexToText, endIndex);
richTextBox3.SelectedFont = new Font(/* args args args */)
// ...
@ChrisAkridge
ChrisAkridge / gist:5673318
Created May 29, 2013 19:55
Generates a set amount of random Double values and places it in a TextBox control.
public void button1_Click(object sender, EventArgs e)
{
// Put a NumericUpDown control somewhere on the form
int numberOfRandomValues = this.numericUpDown1.Value;
Random random = new Random();
StringBuilder stringBuilder = new StringBuilder();
string newLine = Environment.NewLine;
for (int i = 0; i < numberOfRandomValues; i++)
{
if (prio.ShowDialog() == DialogResult.OK)
{
// read the data here
}