Skip to content

Instantly share code, notes, and snippets.

View with-heart's full-sized avatar
❤️‍🔥
growing love

with-heart with-heart

❤️‍🔥
growing love
View GitHub Profile
def DrawFuelBars(surface):
# Draw player 1's fuel bar
x1 = 100 # FIXME: update to starting x location
y1 = 100 # FIXME: update to starting y location
x2 = x + player1_fuel
y2 = y + 10
color = (255, 255, 255) # TODO: add code to change the fuel bar's color based on fuel amount
pygame.draw.rect(surface, color, (x1, y1, x2, y2))
@with-heart
with-heart / gist:ec3b5a9278ae493e31f3
Created June 6, 2014 03:33
Ruby Abstract of My Birth
class BryanKaelin < Man
attr_accessor :time_paradox
def initialize(name, body, time_paradox)
@time_paradox = time_paradox
super
end
def create_offspring(name)
Man.new(name, @body + @time_paradox)
@with-heart
with-heart / ProjectContainer.js
Created December 21, 2016 10:31
Fetching Nested Model by ID
import React, { Component } from 'react'
import { withRouter } from 'react-router'
import { connect } from 'react-redux'
import { projectSelector } from 'selectors/projects'
import { userSelector } from 'selectors/users'
import { fetchProjectsRequest } from 'actions/projects'
import { fetchUsersRequest } from 'actions/users'
import { Project } from 'components/projects'
class ProjectContainer extends Component {
@with-heart
with-heart / instance_as_lambda.kt
Created June 27, 2017 18:07
Kotlin: Use Instance Method as Lambda
val elements = mutableListOf<Int>()
Flux.just(1, 2, 3, 4)
.log()
.subscribe(elements::add)
val elements = mutableListOf<Int>()
Flux.just(1, 2, 3, 4)
.log()
.subscribe({ elements.add(it) })
val elements = mutableListOf<Int>()
Flux.just(1, 2, 3, 4)
.log()
.subscribe({ elements.add(it) })
@Component
class UriDecryptionFilter : ZuulFilter() {
override fun run() = null
override fun shouldFilter() = false
override fun filterOrder() = 1
override fun filterType() = "pre"
}
class UriDecryptionFilterTest {
private val filter = UriDecryptionFilter()
private val request = MockHttpServletRequest()
@Before
fun init() {
val ctx = RequestContext.getCurrentContext()
ctx.clear()
ctx.request = request
}
@Test
fun `basic properties`() {
assertEquals(false, filter.shouldFilter())
assertEquals(1, filter.filterOrder())
assertEquals("pre", filter.filterType())
}
@Test
fun `should filter if encrypted string found in uri`() {
val encrypted = "ABCDEFG123456"
request.requestURI = "/endpoint/$encrypted"
assertEquals(true, filter.shouldFilter())
}