Skip to content

Instantly share code, notes, and snippets.

//
// CacheAsyncImage.swift
//
// Created by Costantino Pistagna on 08/02/23.
//
import SwiftUI
struct CacheAsyncImage<Content, Content2>: View where Content: View, Content2: View {
private let url: URL?
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active July 13, 2024 23:25
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) because d

@perezpaya
perezpaya / challenge.md
Last active October 5, 2020 11:46
Allfunds Coding Challenge

Allfunds Coding Challenge

Our financial department is currently overloaded, they have lots of monthly expense reports waiting to be paid.

This reports consists of three different kind of expenses.

  • TRANSPORTATION (km):
    • Every kilometer is paid at 0.12 $/km
    • When an employee exceeds 100km per month, the next kms are paid at 0.08 $/km
@izqui
izqui / forwarder.sol
Last active October 21, 2021 04:24
Very cheap to deploy (66k gas) forwarder contracts that can clone any contract and still have their own storage
// Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/
// Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/
// Credits to Jordi Baylina for this way of deploying contracts https://gist.github.com/jbaylina/e8ac19b8e7478fd10cf0363ad1a5a4b3
// Forwarder is slightly modified to only return 256 bytes (8 normal returns)
// Deployed Factory in Kovan: https://kovan.etherscan.io/address/0xaebc118657099e2110c90494f48b3d21329b23eb
// Example of a Forwarder deploy using the Factory: https://kovan.etherscan.io/tx/0xe995dd023c8336685cb819313d933ae8938009f9c8c0e1af6c57b8be06986957
// Just 66349 gas per contract
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@hadees
hadees / arel_helpers.rb
Created March 5, 2016 05:41
Arel Helpers
module ArelHelpers
extend self
def self.included(base)
base.extend self
end
def asterisk(arel_table_or_model)
arel_table, columns = case arel_table_or_model
when Arel::Table

How to iOS

Dear iOS Developer,

These are the things you might take into account when developing rock-solid iOS apps.

Writing better code makes you happy and will make your employer, teammates, and even customers happier in the mid-long term.

Please remember

@jasiek
jasiek / isin_validator.rb
Created June 23, 2015 15:15
ISIN validation in Ruby
class IsinValidator < ActiveModel::Validator
CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def validate(record)
value = record[:isin_cusip]
return if value.blank?
digits = value.upcase.chars.collect { |c| CHARS.index c }
digits = digits.join.chars.collect { |c| c.to_i }
actual_check_digit = digits.pop
@pricees
pricees / value_investing.rb
Last active June 4, 2017 13:08
Value Investing (CROIC)
# Margins of Safety
# 30% > $ 10B
# 50% - 30% for $1-10B Market Cap
# > 50% for < $1B
# Owner's Earnings
# Read more: http://www.oldschoolvalue.com/blog/valuation-methods/working-capital-free-cash-flow-fcf/#ixzz3O1Egljwo
# Owner earnings = Net income + depreciation & amortization +/- one-time items +/- changes in working capital - capital expenditures
def owner_earnings # Better than free cash flow
// Playground - noun: a place where people can play
import Foundation
extension NSTimeInterval {
var seconds: NSTimeInterval {
return self
}
var minutes: NSTimeInterval {