Skip to content

Instantly share code, notes, and snippets.

@frankandrobot
frankandrobot / flashLoan.sol
Created October 6, 2022 02:58
Nonworking flash loan contract
// SPDX-License-Identifier: mit
pragma solidity >=0.6.12;
import "@sushiswap/bentobox/contracts/interfaces/IBentoBoxV1.sol";
import "@sushiswap/bentobox/contracts/interfaces/IFlashBorrower.sol";
import "@boringcrypto/boring-solidity/contracts/libraries/BoringERC20.sol";
import "hardhat/console.sol";
import "../shared/Withdrawable.old.sol";
/**
@frankandrobot
frankandrobot / Boid.ts
Created January 17, 2022 06:02
Flocking - An implementation of Daniel Shiffman's Boids program to simulate the flocking behavior of birds. Each boid steers itself based on rules of avoidance, alignment, and coherence. https://processing.org/examples/flocking.html
import "@pixi/math-extras";
import { Point } from "pixi.js";
/**
*
* Limit the magnitude of the point to the given max.
*/
function limit(p: Point, max: number): Point {
const x = p.x;
const y = p.y;
#' Calculate the real return on an index fund.
#'
#' @param yield - percent as a decimal
#' @param expense_ratio - percent as a decimal
#' @param balance
#' @param n - number of years
#'
#' @return
#' @examples
real_return_n <- function(yield, expense_ratio, starting_balance, n) {
#' Calculate the real return on an index fund over a single year.
#'
#' @param yield - percent as a decimal
#' @param expense_ratio - percent as a decimal
#' @param balance
#'
#' @return
#' @examples
real_return <- function(yield, expense_ratio, balance) {
# if there was no expense ratio, this would be your new balance
@frankandrobot
frankandrobot / is_visible.py
Created July 25, 2018 02:22
simple brain teaser
def is_visible(object_value, current_visibility, desired_visibility):
specified = object_value['visibility']
if current_visibility == 'hide':
if desired_visibility == 'show':
return specified == desired_visibility
else:
return True
# current_visibility is "show"...
@frankandrobot
frankandrobot / .gitignore
Last active July 20, 2016 03:43
Recursive Flatten vs Tail-Recursive Flatten
.gradle/
.idea/
build/
*.iml
gradle/
static private class TaskUnionRepeatQuery implements TaskQuery
{
@Override
public Cursor query(SQLiteOpenHelper openHelper,
Uri url,
String[] projectionIn,
String selection,
String[] selectionArgs,
String sort)
{
@frankandrobot
frankandrobot / Datastructure.java
Created August 10, 2013 18:50
Gist for Android Studio bug
package com.frankandrobot.reminderer.datastructures;
import java.util.HashMap;
import java.util.Map;
import java.util.Calendar;
/**
* A datastructure with auto-generated getters and setters.
*
* It is possible to write functions that take variable __names__ as arguments
@frankandrobot
frankandrobot / Task.java
Created August 10, 2013 18:50
Gist for Android Studio bug
package com.frankandrobot.reminderer.datastructures;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
import com.frankandrobot.reminderer.database.TaskTable.TaskCol;
import com.frankandrobot.reminderer.parser.GrammarRule.RepeatsToken;
import com.frankandrobot.reminderer.datastructures.DataStructure.*;
@frankandrobot
frankandrobot / CursorProxyDelete.java
Created August 9, 2013 22:53
Proxy for the Android Cursor class that ignores the row passed in the constructor. Use this to "delete" rows in the listview before deleting them for real in the database.
package com.frankandrobot.reminderer.database.databasefacade;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.database.AbstractCursor;
import android.database.CharArrayBuffer;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.net.Uri;