This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//an easing function that eases in and out by constant acceleration in either direction (parabolic), that allows the user to specify a starting velocty. This allows a user to interrupt the animation partway through and send it in a different direction without any sudden jerks. | |
fn sq(a:f32)-> f32 { a*a } | |
//I'm including these because the way the constant acceleration functions handle cases where initial_velocity > 2 doesn't look very good, it overshoots the target, then comes back to it. You will probably prefer to use these linear acceleration-deceleration functions for those cases instead. You might like to use them instead of constant acceleration methods altogether, but I find they look a bit too jerky. | |
fn linear_acceleration_ease_in_out_with_initial_velocity(t:f32, initial_velocity:f32)-> f32 { | |
t*(t*((initial_velocity - 2f32)*t + (3f32 - 2f32*initial_velocity)) + initial_velocity) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::Iterator; | |
//for hex schemes like this: | |
//. . x-> | |
// . . . | |
// y . . | |
// \ | |
// v | |
#[derive(Debug)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let's break down the highlevel relsat code: | |
addAndTriple := fn a b -> | |
3*(a + b) | |
//First we'll break down the syntactical sugars until we can see how it translates to a tree | |
//note that each of these stages are valid rel code, it's all equivalent. | |
(:= addAndTriple fun( vars(a b) block( | |
3*(a + b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ImportByProxySuccess.hx | |
using A; | |
class Main{ | |
var b:B; | |
static public function main(){ | |
trace("runs fine"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#usage: schedule_scheduled_task(time:Time, task_name:String, task_parameter:String) | |
# runs the function task_name refers to(big trouble if it doesn't refer to a function) with task_parameter. | |
# Will record the task to DB if the bot is shut down. Will restore to the schedule when bot is restarted. | |
#TODO: | |
# implement schedule_task(time, callback) [where time is the time at which it should run, rather than how long till it should run] | |
# do we have simple memory access shims for mem_load_all(key), and mem_save(key, value)? If not, we should, please write them. | |
# mem_delete_k_v(key, value) , this is new functionality, but greatly needed | |
# run reinstate_scheduled_tasks on initialization (note, may execute tasks during the call, make sure initialization is at a stage where it's ready for that) | |
# should work at that point. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SizedArray[V, length:Int] | |
def zipmap[T, otherLength:Int](f:(V, V)=>T, other:SizedArray[otherLength,T]):SizedArray[math.min(length, otherLength),T] = | |
const val minLength = math.min(length, otherLength) | |
retval = new SizedArray[V,minLength] | |
for i in range(0, minLength) | |
retval(i) = f(this(i), other(i)) | |
return retval | |
class Array[V] | |
def zipmap[T](f:(V, V)=>T, other:Array[T]):Array[T] = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def | |
name a | |
type Int32 | |
assign | |
i 1 | |
def | |
name b | |
type Int32 | |
assign |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//no annotations, executing: | |
performing macro expansion julienrf.variants.Variants.format[controllers.Application.SA] at source-/home/mako/programming/calf/app/controllers/Application.scala,line-23,offset=545 | |
play.api.libs.json.Format[SA](play.api.libs.json.Reads[SA](((json) => json.$bslash(Impl.this.defaultDiscriminator).validate[String].flatMap(<empty> match { | |
}))), play.api.libs.json.Writes[SA](<empty> match { | |
})) | |
Apply(TypeApply(Select(Select(Select(Select(Ident(newTermName("play")), newTermName("api")), newTermName("libs")), newTermName("json")), newTermName("Format")), List(Ident(controllers.Application.SA))), List(Apply(TypeApply(Select(Select(Select(Select(Ident(newTermName("play")), newTermName("api")), newTermName("libs")), newTermName("json")), newTermName("Reads")), List(Ident(controllers.Application.SA))), List(Function(List(ValDef(Modifiers(PARAM), newTermName("json"), TypeTree(), EmptyTree)), Apply(Select(TypeApply(Select(Apply(Select(Ident(newTermName("json")), newTermName("$bslash")), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UIMode | |
constructor = (uiControls, subModes = [], inf = ()->, out = ()->)-> | |
@uiControls = uiControls | |
#hides all uiControls managed by the system until their mode comes up | |
for con in uiControls | |
con.style.opacity = 0 | |
con.style.display = 'none' | |
@subModes = subModes | |
for subs in subModes | |
subs.parent = @ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Thing{ a: u8, b: u8 } | |
fn main(){ | |
let mut boxed_thing = box Thing{a:2, b:2}; | |
let btr = &mut boxed_thing; | |
let mut unboxed_thing = Thing{a:3, b:3}; | |
let utr = &mut unboxed_thing; | |
fn pass(a:&mut u8, b:&mut u8){} | |
pass(&mut utr.a, &mut utr.b); //< this is allowed | |
pass(&mut btr.a, &mut btr.b); //< while this is not. | |
//error: cannot borrow `btr.b` as mutable more than once at a time |