Skip to content

Instantly share code, notes, and snippets.

@kdmukai
kdmukai / __base_template.html
Last active August 29, 2015 13:56
Simple jQuery approach to a site-wide popup warning or action dialog with a page overlay to dim the background. This should eventually be packaged up as a plugin that can be loaded on a per-page basis rather than living in the __base_template.html
<html>
<body>
<style>
.page_overlay {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
@kdmukai
kdmukai / gist:1101813
Created July 23, 2011 19:58
Google's example code to upload a file to Google Docs
DocumentListEntry uploadedEntry = uploadFile("/path/to/your/file.doc", "TitleToUse");
System.out.println("Document now online @ :" + uploadedEntry.getHtmlLink().getHref());
public DocumentListEntry uploadFile(String filepath, String title)
throws IOException, ServiceException {
File file = new File(filepath);
DocumentListEntry newDocument = new DocumentListEntry();
String mimeType = DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
newDocument.setFile(new File(filepath), mimeType);
newDocument.setTitle(new PlainTextConstruct(title));
@kdmukai
kdmukai / UploadFileToGoogleDocs.java
Created July 23, 2011 19:47
How to upload a File to Google Docs when you can't create a File in Google App Engine!
import com.google.gdata.client.docs.DocsService;
import com.google.gdata.data.MediaContent;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.docs.DocumentListEntry;
import com.google.gdata.data.docs.DocumentListEntry.MediaType;
import com.google.gdata.data.media.MediaByteArraySource;
import com.google.gdata.data.media.MediaSource;
import com.google.gdata.util.ContentType;
// ...skipping to the good part...
@kdmukai
kdmukai / BitmapButton.as
Created September 11, 2011 01:44
Customizable ActionScript BitmapButton
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.events.MouseEvent;
/**
* A reusable Button class that can be skinned by Bitmaps
*/
public class BitmapButton extends Sprite {
private var defaultBitmap:Bitmap = new Bitmap();
private var onHoverBitmap:Bitmap = new Bitmap();
@kdmukai
kdmukai / Example1.java
Created November 4, 2011 18:06
_GenericDaoHibernateImpl<T> excerpt with session-safe getHibernateTemplate.save()
Cat oldCat = catDao.get(oldCatId);
Cat newCat = new Cat();
newCat.setName("Whiskers");
newCat.setOwner(oldCat.getOwner());
catDao.save(newCat); // Causes Session conflict because Owner isn't initialized
@kdmukai
kdmukai / IndexServlet.java
Created June 9, 2012 20:08
Adding a page with Java, Tiles, and JSP
package com.essaytagger.web.user.administrator;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;
@kdmukai
kdmukai / about_us.html
Created June 9, 2012 20:42
Adding a page with Django
{% extends 'visitor/_visitor_base.html' %}
{% block page_title %}About Us{% endblock %}
{% block page_headline_text %}About Us{% endblock %}
{% block page_content %}
This is the About Us text
{% endblock %}
@kdmukai
kdmukai / register.html
Created July 26, 2012 01:16
Facebook registration with django_facebook
{% load url from future %}
<link href="{{ STATIC_URL }}css/facebook.css" type="text/css" rel="stylesheet" media="all" />
{% include 'django_facebook/_facebook_js.html' %}
Register!
<form action="{% url 'facebook_connect' %}?facebook_login=1" method="post">
<a href="javascript:void(0);" style="font-size: 20px;" onclick="F.connect(this.parentNode);">Login or register with facebook</a>
<input type="hidden" value="{% url 'my_post_registration_url' %}" name="register_next" />
@kdmukai
kdmukai / raspbian-python3.7.md
Last active July 19, 2018 15:36 — forked from dschep/raspbian-python3.6.rst
Installing Python 3.7 on Raspbian

Installing Python 3.7 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

  1. Install the required build-tools (some might already be installed on your system).
$ sudo apt-get update
$ sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev
@kdmukai
kdmukai / EssayManagerExtensions.java
Created July 24, 2011 08:45
Final versions of ObjectifyGenericDAO with interfaces
package com.essaytagger.server.impl;
import com.essaytagger.model.Comment;
import com.essaytagger.model.Essay;
import com.essaytagger.server.IEssayManagerExtensions;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.googlecode.objectify.Key;
/**
* Implementation class for any Essay-specific methods that aren't already handled by ObjectifyGenericDAO<T>.