Skip to content

Instantly share code, notes, and snippets.

View mkelley33's full-sized avatar
🎯
Focusing

Michaux Kelley mkelley33

🎯
Focusing
View GitHub Profile
@mkelley33
mkelley33 / simple-pagination.js
Created February 9, 2024 23:39 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@mkelley33
mkelley33 / webpack.config.js
Created November 20, 2016 00:42
webpack-dashboard config
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// add
const Dashboard = require('webpack-dashboard');
const DashboardPlugin = require('webpack-dashboard/plugin');
const dashboard = new Dashboard();
// add
@mkelley33
mkelley33 / osx_install.sh
Last active August 29, 2015 14:25 — forked from t-io/osx_install.sh
Homebrew: brew cask and brew installs of apps common to my dev machine
#!/bin/sh
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew tap homebrew/dupes
brew install wget
brew install postgresql
brew install mongodb
brew install mongoose
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Mongoid.connect_to 'mongoid-3144'
class Post
include Mongoid::Document
field :name
embeds_many :comments
accepts_nested_attributes_for :comments
# This line somehow triggers the bug; commenting it out fixes the bug, wierd.
@mkelley33
mkelley33 / gist:4158093
Created November 28, 2012 00:12 — forked from dodecaphonic/gist:946254
Function set sequences to max in Postgres (instead of writing the same piece of code in ruby again and again)
Taken from http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync.
--drop function IF EXISTS reset_sequence (text,text) RESTRICT;
CREATE OR REPLACE FUNCTION "reset_sequence" (tablename text,columnname text) RETURNS bigint --"pg_catalog"."void"
AS
$body$
DECLARE seqname character varying;
c integer;
BEGIN
select tablename || '_' || columnname || '_seq' into seqname;
@mkelley33
mkelley33 / strip_tags.py
Created April 1, 2012 15:00 — forked from braveulysses/strip_tags.py
Strip HTML tags using BeautifulSoup
def strip(untrusted_html):
"""Strips out all tags from untrusted_html, leaving only text.
Converts XML entities to Unicode characters. This is desirable because it
reduces the likelihood that a filter further down the text processing chain
will double-encode the XML entities."""
soup = BeautifulStoneSoup(untrusted_html, convertEntities=BeautifulStoneSoup.ALL_ENTITIES)
safe_html = ''.join(soup.findAll(text=True))
return safe_html
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib import files
USAGE = """
================================================================
NOTE:
using this fabfile expects that you have the python utility
@mkelley33
mkelley33 / settings.py
Created August 20, 2011 19:22 — forked from dfeeney/settings.py
Working django-cms settings with django 1.3 staticfiles
# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG