Skip to content

Instantly share code, notes, and snippets.

View sometowngeek's full-sized avatar

Robert sometowngeek

View GitHub Profile
@sometowngeek
sometowngeek / git-sparse-checkout.zsh
Last active March 15, 2022 00:43
Git Sparse Checkout example
(base) ➜ test-sparse-checkout git:(main) ✗ la
total 0
drwxr-xr-x 5 townie user 160 Mar 14 19:35 .
drwxr-xr-x 14 townie user 448 Mar 14 07:45 ..
drwxr-xr-x 13 townie user 416 Mar 14 07:35 .git
-rw-r--r-- 1 townie user 0 Mar 14 07:35 .gitignore
-rw-r--r-- 1 townie user 0 Mar 14 07:26 text.txt
# Clone a repo I want to sparse checkout
(base) ➜ test-sparse-checkout git:(main) ✗ git clone \
public class SanitizeThat {
public static String sanitizeIntegerToString(String input) {
if (input == null)
return "";
String result = "";
// Rule: Only digits except for "%" and "_"
result = input.replaceAll("[^\\d\\%\\_]", "");
result = stripInvalidWildcards(result);
public class TicTacToe extends JFrame {
private boolean initialized; // Default = false
private XOButtons buttons;
private int scorePlayer1;
private int scorePlayer2;
// Reset the board
// Reset the markers, etc.
public void resetGame() {
# Create a dictionary with one key-value pair
d = dict()
d["ABS"] = "Anti-lock Braking System"
# The previous block could be simplified to:
# d = {"ABS": "Anti-lock Braking System"}
# Get input from user
s = input("Enter something: ")
@sometowngeek
sometowngeek / board.py
Last active February 24, 2018 18:24
More OOP-like version of Hangman
from random import choice
class board:
_HANGMAN = (
"""
------
| |
|
namespace YouNameThisNamespace
{
public class ExampleClass
{
public static int GetGCF(int num1, int num2)
{
// Declare variables
int a = num1;
int b = num2;
int r = 0;
@sometowngeek
sometowngeek / Class1.cs
Last active February 24, 2018 18:30
Scoping Example
public class Class1
{
// These are global variables
// because they are declared outside of all methods inside of this class.
// Therefore, they can be accessed in any functions defined in this class.
public int GlobalIntVariable;
public string GlobalStringVariable;
public void Foo()
@sometowngeek
sometowngeek / AnObject.cs
Last active February 24, 2018 18:35
Indexer Example
public class AnObject
{
public int Id { get; set; }
public string Name { get; set; }
public AnObject(int id, string name)
{
this.Id = id;
this.Name = name;
}
@sometowngeek
sometowngeek / LinqExample.cs
Last active February 24, 2018 18:34
LINQ Example
public class LinqExample
{
public static void Main(String[] args)
{
List<SomeMap> mapList = new List<SomeMap>();
mapList.Add(new SomeMap(1, "Main Office"));
mapList.Add(new SomeMap(2, "Bedroom"));
mapList.Add(new SomeMap(3, "Art Room"));
using System;
namespace StackOverflow.Playground
{
public class GetSetExample
{
public static void Main(String[] args)
{
// I am creating an instance of a class or in C# term, an entity or a view model.
Something sv = new Something();