Skip to content

Instantly share code, notes, and snippets.

@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active March 27, 2024 11:56
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

@seanharmer
seanharmer / gist:f0fb73170853c5628613ef90ed3b540c
Created December 10, 2020 08:36
Rails font awesome xlink
# app/helpers/application_helper.rb
module ApplicationHelper
def declare_fa_icon(options, anchor_name)
fa_icon(options, data: { 'fa-symbol': anchor_name })
end
def use_fa_icon(anchor_name, text)
%Q(<svg class="icon-fa-xs"><use xlink:href="##{anchor_name}"></use></svg>#{text}).html_safe
end
@CJBridges
CJBridges / circleci_command_for_cache_optimization.yml
Last active January 22, 2024 18:56
CircleCI does not support checks for existence of a cache key without restoring the full cache. Save a tiny key in parallel with the cache to allow bailing out faster if the cache already exists. More documentation on the approach and the code I started from (thanks TzookB!) is here: https://tzookb.com/circleci-project-deepdive
commands:
halt_if_cache_exists:
description: Halt a build if a cache already exists, without downloading the entire cache. Match only exact key. Pair with mark_cache_existence.
parameters:
category:
description: friendly name of the sort of cache (e.g. bundle, src)
type: string
key:
description: hash key where underlying data would be stored
# frozen_string_literal: true
return unless defined?(DeprecationToolkit)
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [
%r{^((?!/gems/).)* warning: Using the last argument as keyword parameters is deprecated},
%r{^((?!/gems/).)* warning: Passing the keyword argument as the last hash parameter is deprecated},
%r{^((?!/gems/).)* warning: Splitting the last argument into positional and keyword parameters is deprecated},
]
# frozen_string_literal: true
Warning.singleton_class.prepend(
Module.new do
DISABLED_WARNINGS = Regexp.union(
/_pry_ is deprecated, use pry_instance instead/,
/warning: The called method( `.+')? is defined here/,
)
def warn(warning)
on:
pull_request:
types: [closed]
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
@davidwhitney
davidwhitney / LICENSE.txt
Last active October 7, 2019 21:14
A Tiny Typescript mocking... um... library? class? That doesn't annoy me, and doesn't cause Typescript linters to get confused or fill your code up with :anys. The license is MIT.
Copyright (c) 2019 David Whitney
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
import 'package:flutter/material.dart';
import 'package:bloc_lite/bloc_lite.dart';
import 'package:bloc_lite_flutter/bloc_lite_flutter.dart';
class ReactiveWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() => ReactiveWidgetState();
}
class ReactiveWidgetState extends State<ReactiveWidget> {
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ReactiveWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() => ReactiveWidgetState();
}
class ReactiveWidgetState extends State<ReactiveWidget> {
@override
@yann-yinn
yann-yinn / ApolloQuery.vue
Last active March 21, 2024 09:28
Use "apollo-client" package with Vue.js, without "vue-apollo"
<!--
If you really like to use apolloClient declaratively, here is a naive implementation
of a custom 'ApolloQuery' component
-->
<template>
<div>
<slot name="result" :result="this.result" />
</div>
</template>