Skip to content

Instantly share code, notes, and snippets.

@neuman
neuman / get_embedded
Created April 25, 2012 15:57
search nested lists of python objects (great for mongoengine)
def get_embedded(self, hierarchy, key, value, indexes=False):
"""get a list containing the ordered indexes of embedded documents.
A recursive depth first search replacing the nested for loops normally required
to iterate through nested objects contained within lists to find a single object
that has a specific value for a specific key.
Keyword Arguments:
hierarchy -- a list of keys needed to access the list containingthe next level of objects to search
key -- the string name of the member to match value too
@neuman
neuman / showertime.js
Created February 26, 2014 06:09
Shower Time Tasker JS
showScene('Tester');
mediaVol(15);
say("Good morning Eric, welcome to "+global('DAYW')+". Let me check the weather.");
//getLocation( 'net' );
//var coords = global('LOCN').split(",");
var http = new XMLHttpRequest();
//flashLong('http://api.openweathermap.org/data/2.5/find?lat='+coords[0]+'&lon='+coords[1]+'&units=imperial&mode=json');
//http.open("GET",'http://api.openweathermap.org/data/2.5/find?lat='+coords[0]+'&lon='+coords[1]+'&units=imperial&mode=json&type=like',false);
http.open("GET",'http://api.openweathermap.org/data/2.5/find?q=brooklyn&units=imperial&mode=json&type=like',false);
http.send();
class PostListView(SiteRootView, TemplateView):
template_name = 'posts.html'
def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs)
context['posts'] = cm.Post.objects.all().order_by('-updated_at')
return context
{
"name": "Indiepen",
"version": "0.0.3",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt",
"**/.*",
"node_modules",
"bower_components",
@neuman
neuman / EmbeddedMixin.py
Created March 5, 2014 22:03
EmbeddedMixin
class EmbeddedMixin(object):
def get_embedded(self, hierarchy, key, value, depth=0, indexes=False):
"""get a list containing the ordered indexes of embedded documents.
A recursive depth first search replacing the nested for loops normally required
to iterate through nested objects contained within lists to find a single object
that has a specific value for a specific key.
Keyword Arguments:
hierarchy -- a list of keys needed to access the list containingthe next level of objects to search
@neuman
neuman / texture_inside.shader
Last active August 29, 2015 14:05
texture_inside.shader
Shader "Custom/texture_inside" {
Properties {
_Color("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans(A)", 2D)="white"{}
}
SubShader {
Tags { "RenderType" = "Opaque" }
@neuman
neuman / tours.json
Last active August 29, 2015 14:07
tours
{
"initial_id":"alpha",
"spheres":[
{
"id":"alpha",
"title":"dining",
"projection_image_url":"https://s3.amazonaws.com/projectastraltours/highgarden/dining_4096.jpg",
"width":4096,
"height":2048,
"doors":[
class KensView(MessageView):
def get_context_data(self, **kwargs):
kens_var = request.POST.get("kens_thing", "")
messages.info(request, 'kens message here')
# Call the base implementation first to get a context
context = super(MessageView, self).get_context_data(**kwargs)
# Add in a QuerySet of all the books
context['message'] = self.message
return context
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections;
using System.Collections.Generic;
using System;
public class WebImageDisplay : MonoBehaviour
{
SqueakyModel.TwitterAccount: (models.E004) 'id' can only be used as a field name if the field also sets 'primary_key=True'.