Skip to content

Instantly share code, notes, and snippets.

View bencentra's full-sized avatar

Ben Centra bencentra

View GitHub Profile
@bencentra
bencentra / canvas.html
Created February 3, 2014 15:19
Messing around with the HTML5 canvas
<!DOCTYPE HTML>
<html>
<head>
<title>Canvas! Yeah!</title>
<style type="text/css">
* {
font-family: Calibri, Arial, sans-serif;
}
.center {
@bencentra
bencentra / template.html
Last active August 29, 2015 14:00
Template webpage with Boostrap, jQuery, and AngularJS what for the quickly starting of webapps.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<title>Page Title</title>
@bencentra
bencentra / dbInfo.inc
Last active August 29, 2015 14:03
Sample file for storing database credentials and initializing a global PDO object for database operations
<?php
$dbName = ""; // Name of the database to use
$dbUser = ""; // Username of the database user
$dbPass = ""; // Password of the database user
$dbHost = ""; // Host of the database
try {
// Create a global PDO object
$pdo = new PDO(
@bencentra
bencentra / getRequestParam.js
Last active August 29, 2015 14:14
Memoized function for getting request parameters from the URL
var getRequestParam = (function(window) {
var params = [], keys = [], values = [];
return function(param) {
var index = -1, pair;
if (params.length === 0) {
params = window.location.href.split("?");
if (params.length === 1) return false;
params = params[1].split("&");
params.forEach(function(p) {
pair = p.split("=");
@bencentra
bencentra / Gruntfile.js
Last active August 29, 2015 14:15
A starter Gruntfile with common tasks
module.exports = function(grunt) {
// Project config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Variables
scssPath: 'style/',
scssFile: '<%= scssPath %><%= pkg.name %>.scss',
scssIncludes: '<%= scssPath %>**/*.scss',
jsPath: 'js/',
@bencentra
bencentra / batman.js
Created February 28, 2015 16:40
NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNBATMAN!
function batman(n) {
var i = 0, s = "";
while (i < n) {
s += parseInt("batman");
i++;
}
console.log(s+"BATMAN!");
}
batman(16);
@bencentra
bencentra / underscore_basics.js
Created February 28, 2015 19:22
Some basic Underscore.js methods
/*
* Some basic Underscore.js methods
*/
var numbers = [1, 2, 2, 3, 5, 5, 8];
var moreNumbers = [3, 6, 7, 8, 9];
var people = [
{name: "Ben", age: 22},
{name: "Jim", age: 34},
{name: "Sally", age: 16}
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@bencentra
bencentra / loose_cannon.py
Last active December 17, 2015 17:39
A short python script for XChat that will automatically reply for you when a user is kicked from the channel.
# Import xchat module
import xchat
# Required module information
__module_name__ = "loose cannon"
__module_version__ = "1.0"
__module_description__ = "Annoy the ops, namely agargiulo"
# Define the callback method for our hook
def loose_cannon_cb(word, word_eol, userdata):
@bencentra
bencentra / xss_whitelist.php
Created August 17, 2013 01:47
A basic whitelist to prevent XSS.
<?php
function xss_whitelist($input, $limit = null, $offset = 0)
{
// Force input to be a string0
$x = (string) $input;
// Allow alphanumeric characters, whitespace, and specific characters
$x = preg_replace("/[^a-zA-Z0-9 -:,.!?\/|]/", "",$x);
// Limit characters