Skip to content

Instantly share code, notes, and snippets.

View BenjaminAdams's full-sized avatar
🤠
wrangling up the codes at the wild west corral

Benjamin Adams BenjaminAdams

🤠
wrangling up the codes at the wild west corral
  • Austin, Tx
View GitHub Profile
@BenjaminAdams
BenjaminAdams / test.js
Created August 27, 2019 22:15
Amazon Interview question
A-B-C-D
|/ /
E-F
A-B C-D
|/ /
E F
//social network
@BenjaminAdams
BenjaminAdams / shinra.ahk
Last active November 20, 2017 21:57
Final Fantasy Record Keeper Auto macro for Shinras Finest event
#NoEnv
SetWorkingDir %A_ScriptDir%
;Sets the working directory to be where the script is located.
CoordMode, Mouse, Window
;Lets the finding of X and Y to be determined by the mouse's coordinates on the functions below.
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
@BenjaminAdams
BenjaminAdams / CheckModelForNullAttribute.cs
Created October 13, 2016 18:20
c# Checks all incoming parameters for null in a WebApi Controller
using System;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
namespace Payments.Productization.Process.FilterAttributes
{
[AttributeUsage(AttributeTargets.Class)]
public class CheckModelForNullAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext context)
@BenjaminAdams
BenjaminAdams / Example.cs
Created July 6, 2016 16:15
How to add HTTP headers in a WCF service call
public void PerformSoapCall() {
using (var client = new SomeClient())
using (new OperationContextScope(client.InnerChannel))
{
HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
requestMessage.Headers["Authorization"] = "Basic 521vYmFsUGF5bWVudEdhdGV3YXk6R1BHMTIz22==";
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
var res = await client.SomethingAsync();
}
@BenjaminAdams
BenjaminAdams / create.sh
Created January 9, 2016 22:40
wget download entire website and put the file contents into github so you can host the website for free. I used this to move a bunch of sites from a paid host to free on github. It also modified the DNS on digital ocean
#!/bin/bash
USERNAME="" #github usr
PW="" #github pw
ROOT="/home/ben/websites"
DOAUTH ="" #digital ocean auth header
declare -a arr=("anticristum.com" "imaletyoufinish.com" "mariodonkeykong.com" "miamishark.com" "pacmanflash.com" "pandemicboy.com" "sushicat.org" "welcome.artoffx.com" "batmangame.org" "infectonator.com" "marioflash.org" "necronator.com" "pandemic1.com" "phagewars.com" "sydneyshark.net" "werebox.com" "belowsurfaceskincare.com" "crabbattle.com" "jacuzzijumper.com" "mariones.com" "pandemic2game.com" "rpgflash.com" "zombie3.com" "blosics.com" "embed.redditjs.com" "jigsawfree.net" "mariorom.com" "onlinegamescar.com" "pandemic2.info" "runjesus.com" "undeadend.com" "mario3.org" "mariotetris.com" "onslaught2.org" "pandemic2.org" "saucerstrike.com" "blosics.net" "eternalred.com" "mariocrossover2.com" "megamanflash.com" "originalpacman.com" "pandemic3.com" "bobulous.com" "goblanesh.com" "mariocrossover.com" "metroid2.com" "pacman.asia" "pandemic3.org" "supermariocrossover.com" "warcraftflas
@BenjaminAdams
BenjaminAdams / CountryCodeConverter.cs
Last active February 16, 2021 15:35
C# convert two letter country codes to three letter country codes
public static class CountryCodeConverter
{
public static string ConvertThreeLetterNameToTwoLetterName(string twoLetterCountryCode)
{
if (twoLetterCountryCode == null || twoLetterCountryCode.Length != 2)
{
throw new ArgumentException("name must be three letters.");
}
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
using System;
using Moq;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
namespace SuperImportantNamespace.Tests.Data
{
public static class EntityFrameworkMockHelper
@BenjaminAdams
BenjaminAdams / FemaleNames.js
Created July 7, 2015 21:31
Male and female names in an array
var femaleNames = ["Emily","Hannah","Madison","Ashley","Sarah","Alexis","Samantha","Jessica","Elizabeth","Taylor","Lauren","Alyssa","Kayla","Abigail","Brianna","Olivia","Emma","Megan","Grace","Victoria","Rachel","Anna","Sydney","Destiny","Morgan","Jennifer","Jasmine","Haley","Julia","Kaitlyn","Nicole","Amanda","Katherine","Natalie","Hailey","Alexandra","Savannah","Chloe","Rebecca","Stephanie","Maria","Sophia","Mackenzie","Allison","Isabella","Amber","Mary","Danielle","Gabrielle","Jordan","Brooke","Michelle","Sierra","Katelyn","Andrea","Madeline","Sara","Kimberly","Courtney","Erin","Brittany","Vanessa","Jenna","Jacqueline","Caroline","Faith","Makayla","Bailey","Paige","Shelby","Melissa","Kaylee","Christina","Trinity","Mariah","Caitlin","Autumn","Marissa","Breanna","Angela","Catherine","Zoe","Briana","Jada","Laura","Claire","Alexa","Kelsey","Kathryn","Leslie","Alexandria","Sabrina","Mia","Isabel","Molly","Leah","Katie","Gabriella","Cheyenne","Cassandra","Tiffany","Erica","Lindsey","Kylie","Amy","Diana","Cassidy
@BenjaminAdams
BenjaminAdams / creditCard.sql
Last active March 1, 2022 19:04
Search a SQL server field for a creditcard number
SET ROWCOUNT 10000
SELECT SomeField
FROM tablename
WHERE patindex('%[3|4|5|6][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',SomeField) > 0
or to get the unique numbers
SET ROWCOUNT 50
SELECT distinct SUBSTRING (SomeField ,patindex('%[3|4|5|6][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',SomeField) , 12 )
@BenjaminAdams
BenjaminAdams / dyamicGroupBy
Last active August 14, 2019 00:12
c# doing dynamic GroupBy clause with Linq to SQL
using System.Linq;
using System.Linq.Dynamic;
using System.Linq.Expressions;
ParameterExpression p = Expression.Parameter(typeof(SomeEfClass), "p");
var selector = Expression.Lambda < Func < SomeEfClass,
string >> (Expression.Property(p, input.requestedField), p);