Skip to content

Instantly share code, notes, and snippets.

View neilcamm's full-sized avatar

Neil Camm neilcamm

View GitHub Profile
@neilcamm
neilcamm / package.json
Last active July 30, 2018 15:44
Webpack config to compile Sass, ES6 and Vue Components. Implements PurgeCss to remove unused css classes
{
"name": "tbs4",
"version": "1.0.0",
"description": "A Twitter Bootstrap 4 starter theme",
"main": "index.js",
"scripts": {
"dev": "webpack",
"build": "webpack",
"watch": "webpack --watch",
"production": "cross-env NODE_ENV=production webpack"
@neilcamm
neilcamm / array_chunk.js
Last active February 12, 2018 18:45
PHP's array_chunk in JavaScript
var array_chunk = function(array, size) {
var output = [],
i = 0,
n = 0;
for(item in array) {
if(i >= size) {
i = 0;
public class ImageResize
{
public enum Dimensions
{
Width,
Height
}
public enum AnchorPosition
Create the interface
interface ICustomPrincipal : IPrincipal
{
int UserId { get; set; }
string FirstName { get; set; }
string LastName { get; set; }
}
CustomPrincipal
@neilcamm
neilcamm / gist:5112580
Created March 7, 2013 22:49
Delete all views, SPs, functions, PKs, FKs and tables.
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
// create an object named "app" which we can define methods on
var app = {
// returns an array of each url to prefetch
prefetchLinks: function(){
// returns an array of each a.prefetch link's href
var hrefs = $("a.prefetch").map(function(index, domElement){
return $(this).attr("href");
});
// returns the array of hrefs without duplicates
return $.unique(hrefs);
@neilcamm
neilcamm / Delete Duplicates Rows
Created December 15, 2012 18:17
Delete duplicate rows in SQL Server
SET NOCOUNT ON
SET ROWCOUNT 1
WHILE 1 = 1
BEGIN
DELETE FROM major
WHERE name IN (SELECT name
FROM Major
GROUP BY name
HAVING COUNT(*) > 1)
IF @@Rowcount = 0
@neilcamm
neilcamm / gist:4230211
Created December 7, 2012 02:18
Bootstrapify a Dropdownlist
jQuery(function($){
$('select').each(function(i, e){
if (!($(e).data('convert') == 'no')) {
$(e).hide().wrap('<div class="btn-group" id="select-group-' + i + '" />');
var select = $('#select-group-' + i);
var current = ($(e).val()) ? $(e).val(): '&nbsp;';
select.html('<input type="hidden" value="' + $(e).val() + '" name="' + $(e).attr('name') + '" id="' + $(e).attr('id') + '" class="' + $(e).attr('class') + '" /><a class="btn" href="javascript:;">' + current + '</a><a class="btn dropdown-toggle" data-toggle="dropdown" href="javascript:;"><span class="caret"></span></a><ul class="dropdown-menu"></ul>');
$(e).find('option').each(function(o,q) {
select.find('.dropdown-menu').append('<li><a href="javascript:;" data-value="' + $(q).attr('value') + '">' + $(q).text() + '</a></li>');
if ($(q).attr('selected')) select.find('.dropdown-menu li:eq(' + o + ')').click();
@neilcamm
neilcamm / JavaScript
Created July 26, 2012 15:19
Keyboard shortcuts
var isCtrl = false;$(document).keyup(function (e) {
if(e.which == 17) isCtrl=false;
}).keydown(function (e) {
if(e.which == 17) isCtrl=true;
if(e.which == 83 && isCtrl == true) {
alert('Keyboard shortcuts + JQuery are even more cool!');
return false;
}
});
@neilcamm
neilcamm / gist:1653414
Created January 21, 2012 17:50
CSS Drop Shadows
/* Shared styles */
.drop-shadow {
position:relative;
float:left;
width:40%;
padding:1em;
margin:2em 10px 4em;
background:#fff;
-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;