Skip to content

Instantly share code, notes, and snippets.

@gudbergur
gudbergur / README.markdown
Created February 19, 2012 23:49
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@gudbergur
gudbergur / gist:1426081
Created December 3, 2011 04:50
Very bare Embed.ly plugin for TinyMCE
// Requirements: jQuery
// Installation: Add this to your tinyMCE.init, put in your button image and your Embed.ly key and you're good to go
// This is just a very simple embed.ly button cause Google turned up squat.
setup : function(ed) {
ed.addButton('myembedly', {
title : 'Embed.ly',
image : 'BUTTON IMAGE',
onclick : function() {
var url = prompt("Enter URL to embed");
if (url == null) return;
@gudbergur
gudbergur / README.md
Created May 4, 2012 22:07
watchjs - Watch Javascript/CoffeeScript files for changes, concatenate and uglify

watchjs - Watch Javascript/CoffeeScript files for changes, concatenate and uglify

Just a very simple Python script (that depends on Node executables :p) to concatenate JS/Coffeescript files and compress them. I run a Procfile with Foreman that runs this python script on the js/ directory in small projects + stylus on the .styl files. It's similar to some functionality of Brunch.io but where Brunch is not suited I needed a small wrapper to do this for me.

Usage:

chmod +x watchjs.py

./watchjs.py <directory> <output filename>

@gudbergur
gudbergur / README
Created April 30, 2012 19:31
Add CSS class to mobile browsers
Simple javascript that adds "mobile" class to body tag when visited by mobile browsers but "desktop" otherwise.
Instructions: Add <script src="<path to>mobilecss.js"></script> before </body>
@gudbergur
gudbergur / gist:2366485
Created April 12, 2012 10:52
Crude Django request object to text
def dump_request(request):
text = "*** GET ***<br/>\n"
for k in self.request.GET:
text += k+": "+self.request.GET.getlist(k))+"<br/>\n"
text += "*** POST ***<br/>\n"
for k in self.request.POST:
text += k+": "+self.request.POST.getlist(k))+"<br/>\n"
text += "*** COOKIES ***<br/>\n"
for k in self.request.COOKIES:
text += k+": "+self.request.GET.get(k))+"<br/>\n"
#!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#