If you can’t load FTS3 on a Mac, this post on StackOverflow tells you how to solve the problem.
The final bit of magic is in:
from pysqlite2 import dbapi2 as sqlite3
If you can’t load FTS3 on a Mac, this post on StackOverflow tells you how to solve the problem.
The final bit of magic is in:
from pysqlite2 import dbapi2 as sqlite3
Yahoo sold Delicious to another company and for the most part it hasn’t worked for me since the transition. I don’t use the “social” part of the bookmarking: I just try to bookmark every interesting page I read in case I need to find it again in the future. If Yahoo had been clever, they could have built cleverer search infrastructure around bookmarking information but of course “Yahoo” and “clever” rarely appear in the same sentence with being chaperoned by “not”.
I know startups are hard and I feel a little bit bad about kicking them when they’re down but features likely multi-word tagging are not so nearly interesting to me as “working” so it’s off to Evernote which has a lot more powerful clipping capabilities, is well funded, charges money – free doesn’t stay in business.
Here’s how I did the migration:
curl https://USERNAME:PASSWORD@api.del.icio.us/v1/posts/all > backup.xmltoimport.enexFile > ImportI recently was tasked by a client with replacing a number of images — PNGs with alpha levels, such that parts of the image were transparent — with new pictures. The issue was how to get the exact same alpha level holes in the new images.
Here’s how I did it. I renamed one of the original images “template.png” and assumed that all the source images will the exactly the same size as the template. I then wrote this Python script using the Python Imaging Library.
import sys
import os
import re
import Image
#
# Get the template
#
itemplate = Image.open("template.png")
itemplate.getpixel(( 0, 0 ))
r, g, b, alpha = itemplate.split()
#
# Get the JPGs - they must be exactly the same size
#
for in_file in os.listdir("."):
if not in_file.endswith(".jpg"):
continue
isrc = Image.open(in_file)
if isrc.size != itemplate.size:
continue
idst = isrc.convert("RGBA")
idst.putalpha(alpha)
idst.save(in_file[:-4] + ".png")
Just add in your Python comments:
# MARK: comment # TODO: comment # FIXME: comment # !!!: comment # ???: comment
From here.
Here’s a lengthy Javascript code segment that can be dropped into any of your existing forms that provide for a date selection range. It has the following functionality:
ESC while a Calendar is displaying dismisses itDEL while a Calendar is displaying clears the input fieldYYYY-MM-DD formatThis code sample demonstrates:
configMinDate)This assumes:
id="id_event_start"id="id_event_end"class="yui-skin-sam"Add the following Script inclusions to your HTML (note: not all of these are probably needed, and there’s more efficient ways to include YUI JS, especially for production deployments):
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/json/json-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/event/event-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/connection/connection-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/dom/dom-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/element/element-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/button/button-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/dragdrop/dragdrop-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/container/container-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yuiloader/yuiloader-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/container/container_core-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/calendar/calendar-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/animation/animation-min.js"></script>
Add the following CSS inclusions to your HTML:
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/button/assets/skins/sam/button.css" /> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/container/assets/skins/sam/container.css" /> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/calendar/assets/skins/sam/calendar.css" />
Add the following CSS to your HTML:
<style type="text/css">
#id_calendar {
position: absolute;
z-index: 15;
}
.yui-skin-sam .yui-panel .bd, .yui-skin-sam .yui-panel .ft {
background-color:#FFFFFF;
}
</style>
Add the following HTML fragment:
<div id="id_calendar_wrapper"> <div id="id_calendar"></div> </div>
And finally, here’s the JS that makes it all work
<script type="text/javascript">
calendar_js = {
c : null,
start_e : null,
end_e : null,
current_e : 0,
supress : 0,
create : function() {
calendar_js.start_e = YAHOO.util.Dom.get("id_event_start");
calendar_js.end_e = YAHOO.util.Dom.get("id_event_end");
YAHOO.util.Event.addListener(calendar_js.start_e, "click", calendar_js.onclick, this);
YAHOO.util.Event.addListener(calendar_js.end_e, "click", calendar_js.onclick, this);
YAHOO.util.Dom.get(calendar_js.start_e).readOnly = true;
YAHOO.util.Dom.get(calendar_js.end_e).readOnly = true;
(new YAHOO.util.KeyListener(document, { keys:27 }, { fn:calendar_js.onesc })).enable();
(new YAHOO.util.KeyListener(document, { keys:8 }, { fn:calendar_js.ondel })).enable();
},
onesc : function() {
calendar_js.current_e = null;
if (calendar_js.c) {
calendar_js.c.hide();
}
},
ondel : function() {
if (calendar_js.current_e) {
calendar_js.current_e.value = "";
calendar_js.current_e = null;
}
if (calendar_js.c) {
calendar_js.c.hide();
}
},
toydate : function(d) {
if (!d) {
return null;
}
if (d.value) {
d = d.value;
}
if (d && d.length) {
d = d.replace(/(\d\d\d\d)-(\d\d)-(\d\d)/, "$2/$3/$1");
if (d.indexOf('/') == 2) {
return d;
}
}
return null;
},
onclick : function(evt, obj) {
var e_e = YAHOO.util.Event.getTarget(evt);
if (calendar_js.c == null) {
calendar_js.c = new YAHOO.widget.Calendar(null, "id_calendar");
calendar_js.c.render();
calendar_js.c.selectEvent.subscribe(calendar_js.ondate, calendar_js.c, true);
}
var c_e = YAHOO.util.Dom.get("id_calendar");
if (calendar_js.current_e == e_e) {
calendar_js.current_e = null;
calendar_js.c.hide();
} else {
YAHOO.util.Dom.setAttribute(c_e, "display", "block");
calendar_js.current_e = e_e;
var region = YAHOO.util.Region.getRegion(e_e);
calendar_js.c.show();
if (e_e.value.length) {
var d = calendar_js.toydate(e_e);
if (d) {
calendar_js.supress = 1;
calendar_js.c.select(d);
}
}
if (e_e == calendar_js.start_e) {
var d = calendar_js.toydate(calendar_js.end_e);
if (d) {
calendar_js.c.configMaxDate(null, [ d ], null);
calendar_js.c.configMinDate(null, [ "01/01/1970" ], null);
}
} else {
var d = calendar_js.toydate(calendar_js.start_e);
if (d) {
calendar_js.c.configMinDate(null, [ d ], null);
calendar_js.c.configMaxDate(null, [ "01/01/2200" ], null);
}
}
calendar_js.c.render();
YAHOO.util.Dom.setXY(c_e, [ region.right + 2, region.top ]);
}
},
ondate : function(type, args, obj) {
if (calendar_js.supress) {
calendar_js.supress = 0;
return;
}
var date = this.toDate(args[0][0]);
var year = "" + date.getFullYear();
var month = "" + ( 1 + date.getMonth() );
while (month.length < 2) {
month = "0" + month;
}
var day = "" + date.getDate();
while (day.length < 2) {
day = "0" + day;
}
var animate = new YAHOO.util.ColorAnim(calendar_js.current_e,
{backgroundColor: { from: '#ffff99', to: '#FFFFFF' } }
);
animate.duration = 0.75;
animate.method = YAHOO.util.Easing.easeOut;
animate.animate();
calendar_js.current_e.value = year + "-" + month + "-" + day;
calendar_js.c.hide();
calendar_js.current_e = null;
},
end : 0
};
YAHOO.util.Event.onDOMReady(calendar_js.oninit);
</script>
Notes:
If you want to the use the Python Imaging Library on Mac OS/X Snow Leopard, these instructions appear to be the best way to to get libjpeg installed:
1. Download the source from http://libjpeg.sourceforge.net/
2. Extract, configure, make:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --enable-shared --enable-static
make
3. You may need to create the following directories:
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/lib
sudo mkdir -p /usr/local/man/man1
4. Now you can install it as usual.
sudo make install
I used to use Fink on Leopard, but it didn’t seem to work to well this time. If you’ve previously made an attempt at installing PIL, make sure to rm -rf build.
Having recently upgraded to Django 1.1, I suddenly started getting the error messages that look like:
File "/Library/Python/2.6/site-packages/django/db/models/fields/related.py", line 257, in __get__
rel_obj = QuerySet(self.field.rel.to).get(**params)
File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 300, in get
num = len(clone)
File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 81, in __len__
self._result_cache = list(self.iterator())
File "/Library/Python/2.6/site-packages/django/db/models/query.py", line 251, in iterator
obj = self.model(*row[index_start:aggregate_start])
File "/Library/Python/2.6/site-packages/django/db/models/base.py", line 324, in __init__
signals.post_init.send(sender=self.__class__, instance=self)
File "/Library/Python/2.6/site-packages/django/dispatch/dispatcher.py", line 166, in send
response = receiver(signal=self, sender=sender, **named)
File "/Library/Python/2.6/site-packages/django/db/models/fields/files.py", line 368, in update_dimension_fields
(self.width_field and not getattr(instance, self.width_field))
AttributeError: 'Icon' object has no attribute 'width'
The issue turns out to be that you can’t just define the ImageField in your model, you also have to explicitly define the fields that will store the width and height fields for the image field. The sql generation tools for Django don’t do it for you.
For various reasons, I can’t do that this at this moment so I made the following I hack which I strongly recommend you don’t use (for efficiency reasons, as with this the height & width have to be computed every time you access the image). This is added to site-packages/django/db/models/fields around line 367.
if self.width_field and not hasattr(instance, self.width_field):
dimension_fields_filled = False
else:
dimension_fields_filled = not(
(self.width_field and not getattr(instance, self.width_field))
or (self.height_field and not getattr(instance, self.height_field))
)
The proper solutions probably involve:
Yesterday, my experiments came with Android programming came to a crashing halt when I tried to use the Google Maps libraries. No matter what I tried – adding every possible Google Maps SDK, manually adding the jar to the project’s libs directory, a few more things too foolish to talk about – I would get one of these errors:
[javac] .../LocationMapActivity.java:21: package com.google.android.maps does not exist
[javac] import com.google.android.maps.*;
[javac] ^
[javac] .../LocationMapActivity.java:24: cannot find symbol
[javac] symbol: class MapActivity
[javac] extends MapActivity
or
W/dalvikvm( 247): Unable to resolve superclass of Lcom/.../LocationMapActivity; (89) W/dalvikvm( 247): Link of class 'Lcom/.../LocationMapActivity;' failed D/AndroidRuntime( 247): Shutting down VM W/dalvikvm( 247): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
or
Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]
Well. Here’s what you need to know:
ant won’t look for jar files and just give you the linking errorsIn particular, this is what you want to do to fix your problem – it’s all about “targets”:
android list targets to find a suitable Google Maps-enabled targetandroid &. Don’t be fooled by seeing just “Platform” and “API Level” listed there – the target determines what these areemulator -avd david_6 &android update project --path HelloAndroid --target 7If you’re an Eclipse user, I’m sure there’s some easy way to do this, but the command line works just fine for me. I’m not the first person to see this problem, but I’ve never really seen this spelled out so explicitly how to solve it so hopefully you fine this of use.
This is an example of how to combine a UIPageControl and a UIScrollView together to create a “snap to page”-like effect that is seen on the iPhone’s home screen. This sample is partially based on Apple’s UIPageControl example.
Here is a brief outline of how one would “naively” transform Almost Universal API‘s (AUAPI) JSON into XML. We say “naive” because in general one wants to make a transformation into a specific XML application: Atom, RSS, OPML, KML, etc.. In those cases, one has to rename and rework certain elements first for standards compliance, then complete the naive transformation for remaining elements.
Walking JSON objects is done depth first. Most of the complexity involved is in handling dictionaries, which can be valued as being comprised of ( key, value ) pairs. For each dictionary, we are creating an XML node whose properties are defined as follows:
@@ are ignored@ means “the text” of the node (the examples will make this more clear)@ are attributes of the nodeThere are number of complexities that have to be addressed; for this I suggest looking at the examples or source code.
You can see the code for this in the AUAPI source base in api.py in XMLAPIWriter.TranscribeNode.
{
"numbers" : [ 1, -0.23, ],
"strings" : [ "bob", "caf\xe9", ],
"booleanish" : [ True, False, None, ],
}
<root>
<numbers>1</numbers>
<numbers>-0.23</numbers>
<booleanish>True</booleanish>
<booleanish>False</booleanish>
<booleanish />
<strings>bob</strings>
<strings>caf\xc3\xa9</strings>
</root>
{
"a1" : {
"b1" : 1,
"b2" : 2,
},
"a2" : {
"b3" : "hi",
"b4" : "there",
},
}
<root>
<a1>
<b1>1</b1>
<b2>2</b2>
</a1>
<a2>
<b4>there</b4>
<b3>hi</b3>
</a2>
</root>
{
"@attribute" : "hello",
"@bttribute" : "there",
"a" : "some string",
},
<root attribute="hello" bttribute="there">
<a>some string</a>
</root>
Powered by WordPress