Skip to content

Instantly share code, notes, and snippets.

View IanWold's full-sized avatar
🏠
Working from home

Ian Wold IanWold

🏠
Working from home
View GitHub Profile
@IanWold
IanWold / ThrowArgNullException.cs
Last active December 27, 2015 08:39
When you need to check for null arguments
public static void ThrowArgNullException(params object[] args)
{
for (int i = 0; i < args.Count(); i++)
{
if (args[i] == null) throw new ArgumentNullException("Argument Number " + i);
}
}
public static void ThrowArgNullException(string[] ArgNames, params object[] args)
{
if (joy2_Btn(1) == 1) //If you need to use the second joystick, change it to: Joy2_Btn(1)
{
if (motor[m4] == 0) //If you need to use a different motor, change every "m4" to whichever motor you need
{
motor[m4] = 100; //If you need the motor to go at a different speed, change the "100" here to the speed you need.
//This number is a percentage - 100 is 100% speed, 50 is 50% speed, etc.
}
else
{
motor[m4] = 0;
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, m1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, m2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, m3, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, m4, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c";
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, m1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, m2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, m3, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, m4, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, m5, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, m6, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, m1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, m2, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c";
task main() {
while (true) {
static T GetRandomValue<T>(this T[] array)
{
return array[new Random().Next(0, array.Length)];
}
using System;
using C = System.Console;
namespace MontyHall
{
class Program
{
static void Main(string[] args)
{
//in Parse.cs
public static Parser<U> EnumerateInput<T, U>(IEnumerable<T> input, Func<T, Parser<U>> parser)
{
if (input == null) throw new ArgumentNullException("input");
if (parser == null) throw new ArgumentNullException("parser");
return EnumerateInput(input.ToArray(), parser);
}
public static Parser<U> EnumerateInput<T, U>(T[] input, Func<T, Parser<U>> parser)
<html>
<body>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td width="100%" height="100%" valign="center">
<center>
<img src="image.png"/>
</center>
</td>
</tr>
public static class ClaimsExtensions
{
public static string GetClaimValue(this HttpContext context, string type)
{
if (context.User.Claims.FirstOrDefault(c => c.Type == type) is Claim claim)
{
return claim.Value;
}
else throw new ArgumentException(type + " is not found in claims.");
}