Skip to content

Instantly share code, notes, and snippets.

gudbergur

Block or report user

Report or block gudbergur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gudbergur
gudbergur / README.md
Created May 4, 2012
watchjs - Watch Javascript/CoffeeScript files for changes, concatenate and uglify
View README.md

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 Apr 30, 2012
Add CSS class to mobile browsers
View README
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 Apr 12, 2012
Crude Django request object to text
View gist:2366485
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"
@gudbergur
gudbergur / README.markdown
Created Feb 19, 2012
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things
View README.markdown

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 Dec 3, 2011
Very bare Embed.ly plugin for TinyMCE
View gist:1426081
// 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;
View gist:1310207
#!/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
#
You can’t perform that action at this time.