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 / css-nav-tabs.html
Last active August 29, 2015 14:01
Pure CSS tabs with checkbox hack
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head></head><body>
<style>
.tab-area p {
font-size: 11px;
color: #666;
}
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 / gist:5258272
Created March 27, 2013 21:40
Problem, we need to trim strings in javascript but its not implemented in all browsers Since new Browsers (IE9+) have trim() already implemented, you should only implement trim() if it is not already available on the Prototype-Object (overriding it is a huge performance hit). This is generally recommended when extending Native Objects! Note that…
if (!String.prototype.trim) {
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
}
@BenjaminAdams
BenjaminAdams / Split string on words.php
Last active December 19, 2015 17:29
Splitting a string between multiple lines. When you are splitting a string to go on multiple lines we want to split the string where it does not break a word onto different lines. This to to make the string easier to read. In this example I was generating a PDF and needed to split a title of something onto 3 different lines so the text did not s…
public function split_title($title,$maxStr)
{
$newStr = Array();
$maxLines=3;
$lineNum = 1; //to be line 1,2, or 3
$split = explode ( " ", $title);
foreach($split as $str)
{
@BenjaminAdams
BenjaminAdams / main.js
Created September 29, 2013 20:04
How to properly serialize a form into a javascript object
var data = {};
$(".form-selector").serializeArray().map(function(x){data[x.name] = x.value;})
@BenjaminAdams
BenjaminAdams / upload.js
Created October 1, 2013 07:15
Upload image and/or a file with Javascript
uploadImg: function(file, imgPreview, imgUrl) {
var self = this
console.log('file=', file)
imgPreview.html('<i class="icon-spinner icon-spin"></i>')
imgUrl.val('')
reader = new FileReader();
reader.onload = (function(tFile) {
return function(evt, response) {
@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 / 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 / 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 / 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