Skip to content

Instantly share code, notes, and snippets.

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 Aug 27, 2019
Amazon Interview question
View test.js
A-B-C-D
|/ /
E-F
A-B C-D
|/ /
E F
//social network
@BenjaminAdams
BenjaminAdams / shinra.ahk
Last active Nov 20, 2017
Final Fantasy Record Keeper Auto macro for Shinras Finest event
View shinra.ahk
#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 Oct 13, 2016
c# Checks all incoming parameters for null in a WebApi Controller
View CheckModelForNullAttribute.cs
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 Jul 6, 2016
How to add HTTP headers in a WCF service call
View Example.cs
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 Jan 9, 2016
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
View create.sh
#!/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 Feb 16, 2021
C# convert two letter country codes to three letter country codes
View CountryCodeConverter.cs
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);
View EntityFrameworkMockHelper.cs
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 Jul 7, 2015
Male and female names in an array
View FemaleNames.js
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 Mar 27, 2019
Search a SQL server field for a creditcard number
View creditCard.sql
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 Aug 14, 2019
c# doing dynamic GroupBy clause with Linq to SQL
View dyamicGroupBy
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);