Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define QUESTIONS_FILE "hello.txt"
#define BUFFER_SIZE 255
#define OPTSEPARATOR ';'
#define QUESTIONSEPARATOR '\n'
struct option_t
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
private function init() : void
{
core.addEventListener(ResultEvent.RESULT,
function(e:ResultEvent):void{ trace("Result: "+e.result); });
00000000 00 03 00 00 00 01 00 0b 2f 31 2f 6f 6e 52 65 73 /1/onRes
00000010 75 6c 74 00 04 6e 75 6c 6c 00 00 00 00 11 0a 07 ult null
00000020 3b 66 6c 65 78 2e 6d 65 73 73 61 67 69 6e 67 2e ;flex.messaging.
00000030 69 6f 2e 4f 62 6a 65 63 74 50 72 6f 78 79 0a 81 io.ObjectProxy
00000040 03 55 66 6c 65 78 2e 6d 65 73 73 61 67 69 6e 67 Uflex.messaging
00000050 2e 6d 65 73 73 61 67 65 73 2e 41 63 6b 6e 6f 77 .messages.Acknow
00000060 6c 65 64 67 65 4d 65 73 73 61 67 65 09 62 6f 64 ledgeMessage bod
00000070 79 11 63 6c 69 65 6e 74 49 64 1b 63 6f 72 72 65 y clientId corre
00000080 6c 61 74 69 6f 6e 49 64 17 64 65 73 74 69 6e 61 lationId destina
00000090 74 69 6f 6e 0f 68 65 61 64 65 72 73 13 6d 65 73 tion headers mes
elif isinstance(field, models.ForeignKey) and\
field.rel.limit_choices_to:
key = field.rel.get_related_field().name
choices = field.rel.limit_choices_to
info.choices = list()
for choice in field.rel.to._default_manager.filter(**choices).values():
info.choices.append( (choice[key], unicode(choice.values()[0]),) )
info.shortName = '%s_id' % info.shortName
info.fullName = '%s_id' % info.fullName
@mharju
mharju / choice_game.py
Created December 19, 2010 19:04
Tässä vähän tämmöstä pikaista testiä! :)
from itertools import chain
import random
def shift(cards, shift):
return [ cards[(i - shift) % len(cards)] for i in range(0, len(cards) ) ]
def shuffle(cards, m):
return [ [ card for pos, card in enumerate(chain(*cards)) if pos % m == p ] for p in range(0, m) ]
def shift_amt(position, m, n):
var application = Sammy.Bundle('#element',
{
'base': my_app.base, // A Sammy.Application in its own right
'add-event': my_app.add_event // So is this
},
function() {
// Rules how to change states. Can be triggered by binding or routing?
this.get('#/add', function() {
this.setApplication('add-event');
@mharju
mharju / salaclip.sh
Created April 3, 2011 08:28
A function to include in your .zshrc to copy passwords to OS X clipboard from Sala
SALADIR=~/.sala
function _sala_all {
(cd $SALADIR && find . | cut -d'/' -f 2,3 | grep '/' | grep -v '.git' | xargs)
}
function _salacomp {
reply=(`_sala_all`)
}
compctl -K _salacomp sc
function sc {
@mharju
mharju / gist:1182864
Created August 31, 2011 05:12
Etsii ne lähtöjoukon n/2-kombinaatiot, joiden unioni muodostaa koko lähtöjoukon
def set_bipartitioning_combinations(iterable):
return ( (i, j) for i in itertools.permutations(iterable, len(iterable) / 2)
for j in itertools.permutations(iterable, len(iterable) / 2)
if set(i).union(j) == set(iterable) )
@mharju
mharju / gist:1286545
Created October 14, 2011 08:16
Asynchronous loading of a resource with resource names coming from external resource
protected void LoadFeedByName(string name, OpenReadCompletedEventHandler handler)
{
WebClient client = new WebClient();
client.OpenReadCompleted += handler;
if (App.UriProvider.IsFeedsAvailable)
{
client.OpenReadAsync(App.UriProvider.UriForName(name));
}
else
@mharju
mharju / gist:1292407
Created October 17, 2011 11:11
Quick & Dirty screensaver for PyCon.
import processing.opengl.*;
void setup()
{
size(1440, 960, OPENGL);
background(0);
}
void star(int size)