Skip to content

Instantly share code, notes, and snippets.

View mpj's full-sized avatar

Mattias Petter Johansson mpj

View GitHub Profile
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '389030183265', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
@mpj
mpj / jquery 3d in webkit
Created June 28, 2010 12:00
jquery 3d in webkit
// Some simple webkit 3d extensions to jQuery
// Use safari 5 to view.
// (you need to set the -webkit-perspective CSS property to something on the element containing #myNiceDiv for this to work)
// Example use:
// Rotate a div on Y an Z axis:
// $("#myNiceDiv").rotate(0, 30, 10);
// Move the div closer to the camera
// $("#myNiceDiv").translate(0, 0, 100);
<div id="fb-root"></div>
<script>
$(document).ready(function() {
// Facebook
window.fbAsyncInit = function() {
FB.init({appId: '132860020070788', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('edge.create', function(href, widget) {
// Tell Google Analytics that we had a like!
_gaq.push(['_trackEvent', 'FacebookLikes', 'Root', 'Like of Root Page']);
/*
JUMPYFIELD is a simple little thing that makes the focus jump between fields when they reach maxlength.
Usage:
$(".myInputFields").jumpy();
jumpy also accepts an optional array of default values that count the fields as "empty". Example:
$(".myInputFields").jumpy(["YY","MM","DD"]);
class JayCutCommandFactory
attr_accessor :site_name, :key, :secret, :api_host_base
def initialize(site_name, key, secret)
@site_name = site_name
@key = key
@secret = secret
@api_host_base = "api.jaycut.com"
end
# This script accepts one or more directories and find all .as and .mxml files in them, and extracts
# gettext marked strings from them. It also finds string that are NOT marked with gettext, and puts
# them in a separate file, for easy finding of strings that we have missed to internationalize.
# create a list of all .as and .mxml files and put the list into files4i18n
find $* | egrep -i '\.as$|\.mxml$' > files4i18n
echo "Extracting marked strings and putting them into template.pot"
xgettext -f files4i18n --keyword=LC:1c,2 --from-code=UTF-8 -o template.pot --add-comments='TRANSLATOR' --language=python
# We parse as python, since there is no offical support for ActionsScript. This works, with the minor exception that it won't
# handy little script i wrote to compress the enourmous image folder my girlfriend had,
sudo port install ImageMagick
find . -type f -name '*.jp*' -exec mogrify -resize '1280>' -compress jpeg -quality 85 {} \;
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
import sys, os, traceback, optparse
import polib
from xml.dom.minidom import Document
import time
import re
#from pexpect import run, spawn
def main ():
doc = Document()
@mpj
mpj / XHR upload.js
Created November 7, 2010 21:37
Dirt simple example
function on_file_input_element_changed() {
var my_file_input_element = my_method_to_find_file_input_element();
var file = my_file_input_element.files[0];
var xhr = new XMLHttpRequest();
var is_async = true;
xhr.open("POST", "/upload", is_async);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", encodeURIComponent(file.fileName));
xhr.setRequestHeader("Content-Type", "application/octet-stream");