Skip to content

Instantly share code, notes, and snippets.

import math
class Reward:
def __init__(self, verbose=False):
self.first_racingpoint_index = 0 # None
self.verbose = verbose
def reward_function(self, params):
# Import package (needed for heading)
@marcadams
marcadams / sense_leds.py
Created October 29, 2023 17:47
Sense Hat script to flicker like a candle (for pumpkin)
from sense_hat import SenseHat
import time
import random
sense = SenseHat()
colors = [
[255, 0, 0], # Red
[255, 194, 0], # Amber
[255, 165, 0], # Orange
[0, 0, 0] # Off
@marcadams
marcadams / dexfix.java
Created November 30, 2015 15:56
Dealing with the dexmaker.dexcache issue in Android unit tests
// Because I keep forgetting
System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());
@marcadams
marcadams / powerline.zsh-theme
Created June 10, 2015 17:38
Powerline theme for oh-my-zsh
# FreeAgent puts the powerline style in zsh !
if [ "$POWERLINE_DATE_FORMAT" = "" ]; then
POWERLINE_DATE_FORMAT=%D{%Y-%m-%d}
fi
if [ "$POWERLINE_RIGHT_B" = "" ]; then
POWERLINE_RIGHT_B=%D{%H:%M:%S}
elif [ "$POWERLINE_RIGHT_B" = "none" ]; then
POWERLINE_RIGHT_B=""
@marcadams
marcadams / simulator-size.sh
Created March 20, 2015 15:47
Add this to your path and you can use it without having to remember it. I have a folder in my user root named "scripts" that I add to my path, then any script in there will be available from terminal
#!/usr/bin/env bash
function main() {
local simulator_size=$1
if [[ -z "$1" ]]; then
simulator_size="1.0"
fi
defaults write ~/Library/Preferences/com.apple.iphonesimulator SimulatorWindowLastScale ${simulator_size}
@marcadams
marcadams / update_storyboard_strings.sh
Last active December 24, 2015 15:59 — forked from problame/update_storyboard_strings.sh
It seems in Xcode 5 that there was an issue with passing in the file path with a ./, changing the find command to use ${PWD} results in the absolute path being used. Apparently, ibtool prefers absolute paths. This also ignores any locale folders under a "Views" directory, which is where I put my XIB files. Otherwise, the XIB localization folders…
#!/bin/sh
#
# update_storyboard_strings.sh - automatically extract translatable strings from storyboards and update strings files
# Source: https://gist.github.com/marcadams/6825053
# Based on http://forums.macrumors.com/showpost.php?p=16060008&postcount=4 by mikezang
storyboardExt=".storyboard"
stringsExt=".strings"
newStringsExt=".strings.new"
oldStringsExt=".strings.old"
@marcadams
marcadams / gist:1670980
Created January 24, 2012 16:30 — forked from graemerocher/gist:1393603
Using GORM from MongoDB from a Groovy Script
@GrabResolver(name='grails-core', root='http://repo.grails.org/grails/core')
@Grab(group='org.grails', module='grails-datastore-gorm-mongo', version='1.0.0.BUILD-SNAPSHOT')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.1')
import grails.persistence.*
import org.grails.datastore.gorm.mongo.config.*
MongoDatastoreConfigurer.configure("myDatabase", Book)
Book.withSession {
@marcadams
marcadams / gist:1401101
Created November 28, 2011 17:01 — forked from graemerocher/gist:1393603
Using GORM from MongoDB from a Groovy Script
@GrabResolver(name='grails-core', root='http://repo.grails.org/grails/core')
@Grab(group='org.grails', module='grails-datastore-gorm-mongo', version='1.0.0.BUILD-SNAPSHOT')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.1')
import grails.persistence.*
import org.grails.datastore.gorm.mongo.config.*
MongoDatastoreConfigurer.configure("myDatabase", Book)
Book.withSession {
development {
hibernate {
cache.use_second_level_cache=false
cache.use_query_cache=false
cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'
}
dataSource {
pooled = true
dbCreate = "validate"
@marcadams
marcadams / gist:180329
Created September 3, 2009 14:27 — forked from heavysixer/gist:180328
will_paginate fix for facebooker from Heavysixer
class FacebookPaginator < WillPaginate::LinkRenderer
include WillPaginate::ViewHelpers
def stringified_merge(target, other)
other.each do |key, value|
key = key.to_s # this line is what it's all about!
next if "fb_sig_friends" == key
existing = target[key]
if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)