Tuesday, October 29, 2013

Tastypie valid lookups


exact
iexact
contains
icontains
in
gt
gte
lt
lte
startswith
istartswith
endswith
iendswith
range
year
month
day
week_day
isnull
search
regex
iregex

Ex:

class ThemeResource(ModelResource):
class Meta:
allowed_methods = ['get', 'put']
queryset = Theme.objects.all()
resource_name = 'theme'
filtering = {
'name': ['exact', 'icontains'],
'id':('exact'),
}

http://local.test:8000/api/v1/theme/?format=json&name__icontains=agenda

Monday, October 28, 2013

django Incorrect string value for object_repr

http://stackoverflow.com/questions/11497744/django-mysql-unicode-errors

ALTER TABLE django_admin_log MODIFY object_repr VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

Wednesday, October 16, 2013

Showing collation and setting collation MySQL



mysql> show full columns from [table];


ALTER TABLE [table] CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Thursday, September 26, 2013

Load iOS 6.1 SDK into XCode5



  1. Find the SDK file, like iPhoneOS6.1.sdk, in your or your friend's older Xcode directory.
  2. Sym link the old SDK to the new XCode5 app directory:
  3. ln -s /Applications/Xcode4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk

Thursday, August 15, 2013

RabbitMQ Installing rabbitmqadmin


rabbitmq-plugins enable rabbitmq_management

Restart rabbitmq server:
rabbitmqctl stop
./rabbitmqctl-server

Download rabbitmq_management from:
http://[server]/cli/

Friday, August 2, 2013

Django filter on multiple object IDs

https://docs.djangoproject.com/en/1.5/topics/db/queries/

# Get blogs entries with id 1, 4 and 7
>>> Blog.objects.filter(pk__in=[1,4,7])

# Get all blog entries with id > 14
>>> Blog.objects.filter(pk__gt=14)

Monday, July 22, 2013

Print attributes of python object

from pprint import pprint
pprint (vars(your_object))

Monday, July 8, 2013

Re-install xcodebuild

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Wednesday, June 26, 2013

misc notes Django Python South migration

#sudo python manage.py migrate [application name]
#sudo python manage.py migrate guidebook
#sudo python manage.py migrate appsub


#sudo python ./manage.py schemamigration appsub --auto

#sudo python manage.py migrate --list
#sudo python manage.py migrate appsubmit
#sudo python manage.py migrate --list

Monday, June 24, 2013

ant build problems

Buildfile: /Users/deanliu/Desktop/gb_build/src/android/build.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

BUILD FAILED
Desktop/gb_build/src/android/build.xml:88: The following error occurred while executing this line:
Desktop/gb_build/src/android/build.xml:51: Problem: failed to create task or type for
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.


Solution:

http://www.coderanch.com/t/506388/tools/failed-create-task-type-undefined

Install ant-contrib:

#sudo port install ant-contrib

Tuesday, April 9, 2013

emuclient --config PS3_Battlefield3_McKack.xml --port /dev/ttyUSB0 --type joystick --refresh 4

Sunday, April 7, 2013

Simulate Mouse Clicks on Python



The evdev package provides bindings to parts of the input handling subsystem in Linux. It also happens to include a pythonic interface to uinput.
Example of sending a relative motion event and a left mouse click with evdev:
from evdev import UInput, ecodes as e

capabilities = {
    e.EV_REL : (e.REL_X, e.REL_Y), 
    e.EV_KEY : (e.BTN_LEFT, e.BTN_RIGHT),
}

with UInput(capabilities) as ui:
    ui.write(e.EV_REL, e.REL_X, 10)
    ui.write(e.EV_REL, e.REL_Y, 10)
    ui.write(e.EV_KEY, e.BTN_LEFT, 1)
    ui.syn()

Raspberry Pi linux-headers 3.1.9+


Note by Dean:  I have made some changes from the original post to match my 3.1.9+ environment
by shig » Sun Sep 23, 2012 6:31 am
So, as the standard debian kernel packaging system isn't used (the kernel and module are all in the raspberrypi-bootloader package), and the headers aren't distributed, you will need to download the source tree from the github at https://github.com/raspberrypi/linux/. You won't have to recompile it however.

Here a quick guide. I'm assuming that you already have build-essential/compiler/everything else you need in place anyhow, and just need the kernel specific headers and symbols.

Download the kernel source and unpack it with:
CODE: SELECT ALL
sudo bash
cd /usr/src
git clone --depth 1 git://github.com/raspberrypi/linux.git

Then we'll grab the config from the raspberry pi's running kernel, and get the source tree to prepare itself for module builds:
CODE: SELECT ALL
cd linux
zcat /proc/config.gz > .config
make oldconfig
make modules_prepare

What you will also need to build modules that will actually go into the new kernel is Modules.symvers. Luckily, someone has nicely put it in the raspberrypi/firmware github along with the pre-compiled kernel and firmware binaries, so we can just download the latest one from there:
CODE: SELECT ALL
wget https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers

Then just make symlinks available in /lib/modules/[kernelversion]/ for the stuff you're compiling. Might as well put a symlink in for /usr/src/linux etc as well
CODE: SELECT ALL
KSRC=`pwd`
pushd /lib/modules/`uname -r`
ln -s ${KSRC} source
ln -s ${KSRC} build
popd

pushd /usr/src
ln -s ${KSRC} linux-`uname -r`
ln -s ${KSRC} linux
popd

Apart from the time downloading, the rest should take about 10 minutes or so hopefully, depending on how fast the storage you've got available is. This will also take up about 630MB of space under /usr/src until you clean it up

Hope this helps

Friday, January 18, 2013

Logs of OSX downloads

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'


http://www.macgasm.net/2013/01/18/good-morning-your-mac-keeps-a-log-of-all-your-downloads/