Skip to content

Instantly share code, notes, and snippets.

View andredublin's full-sized avatar
🐝
buzz

Andre Dublin andredublin

🐝
buzz
View GitHub Profile
@andredublin
andredublin / DataUtils.cs
Created February 25, 2014 17:39
csharp helper functions
public static class DataUtils
{
public static List<SelectListItem> ConvertEnumToSelect<T>(params T[] enumObj)
{
List<SelectListItem> enumList = new List<SelectListItem>();
foreach (T data in Enum.GetValues(typeof(T)))
{
enumList.Add(new SelectListItem
{
@andredublin
andredublin / backspace.js
Created February 25, 2014 22:03
prevent the backspace button
var BACKSPACE = 8;
$(document).unbind('keydown').bind('keydown', function (event) {
var doPrevent = false;
if (event.keyCode === BACKSPACE) {
var d = event.srcElement || event.target;
if ((d.tagName.toUpperCase() === 'INPUT' &&
(d.type.toUpperCase() === 'TEXT' ||
d.type.toUpperCase() === 'PASSWORD' ||
d.type.toUpperCase() === 'FILE'))
@andredublin
andredublin / wat.php
Created March 7, 2014 02:54
What the deuce?
<?php
// get the length of your full name (first and last)
// multiply that by M_PI and round it to the third decimal place
// print out the result
// then print out the ceiling value of the result
// Next use your knowledge of strlen(), substr(), and rand() to print a random character from your name
echo 5 * M_PI;
echo '<br>';
@andredublin
andredublin / app.js
Last active August 29, 2015 13:57
http undefined?
var accounts = angular.module('accounts', []),
controllers = {},
factories = {};
controllers.SearchController = function($scope, searchFactory) {
var searchViewModel = {
query: "",
accounts: []
};
@andredublin
andredublin / headerstatus.js
Created April 2, 2014 16:48
status headers as a json object
{
'100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'200': 'OK',
'201': 'Created',
'202': 'Accepted',
'203': 'Non-Authoritative Information',
'204': 'No Content',
'205': 'Reset Content',
<?php
// shorter array initialization syntax [] instead of array() as of PHP >= 5.4
$input = [
'A man, a plan, a canal: Panama',
'Cigar? Toss it in a can. It is so tragic',
'Hey you guys!!!!!!'
];
// define a constant variable
define('UTF8', 'UTF-8');
<?php
namespace Palindromes;
interface iStringComparer
{
function compareArrayStringsInsensitive(); // by default no visibility keyword is set to public, don't do this!
public function parseCodepoints(array $codepoints);
}
FROM ubuntu:12.04
MAINTAINER Andre Dublin "81dublin@gmail.com"
ENV REFRESHED_AT 2014-05-01
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install build-essential
#RUN apt-get -y install linux-headers-$(uname -r)
RUN apt-get -y install linux-source
@andredublin
andredublin / index.htm
Created May 7, 2014 18:17
angular and html square brackets
<!-- note that levels is coming from $scope.levels = [0,1,2,3]; -->
<!-- note that foobar is coming from $scope.foobar = {}; -->
<!-- note that foobar is coming from $scope.foobar.buzzArray = [0,0,0]; -->
<div ng-repeat="(index, value) in foobar.buzzArray">
<label for="buzzArray[]">Buzz level {{ index + 1 }}</label>
<select ng-model="foobar.buzzArray" name="buzzArray[]" ng-options="level for level in levels">
<option value="">-- Select Level --</option>
</select>
</div>
@andredublin
andredublin / index.cshtml
Created May 8, 2014 16:08
ngapp example
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" ng-app="myapp"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" ng-app="myapp"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" ng-app="myapp"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" ng-app="myapp"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">