Skip to content

Instantly share code, notes, and snippets.

View jancassio's full-sized avatar
:octocat:
Loading...

Jan Cassio jancassio

:octocat:
Loading...
View GitHub Profile
@jancassio
jancassio / averageColor.pde
Last active September 25, 2019 23:02
Get average color of an image
color averageColor(PImage image) {
float r = 0;
float g = 0;
float b = 0;
int count = image.pixels.length;
int[] pixels = image.pixels;
for(int i = 0; i < count; i++) {
r += red(pixels[i]);

Keybase proof

I hereby claim:

  • I am jancassio on github.
  • I am jancassio (https://keybase.io/jancassio) on keybase.
  • I have a public key ASB7EAgy7OiQS7SN1XNbtBqf8Q7vNMGpRkCEjFBsDszyHQo

To claim this, I am signing this object:

@jancassio
jancassio / making-animated-gifs-from-openframeworks-and-ffmpeg.md
Last active October 8, 2023 00:59
Making animated gifs from openframeworks using FFMPEG

Making animated gifs from Openframeworks using FFMPEG

Making gif loops from Openframeworks is really cool but, isn't simple as suppose to be.

Here are the steps I do to make that. Look almost the whole process are mostly mechanical and could be automated.

These steps are:

  1. Setup resolution
  2. Setup framerate
@jancassio
jancassio / i18n.js
Created February 10, 2019 14:58
Dead simple JavaScript i18n implementation
// dead stupid simple i18n implementation
/**
* i18n function allows to pick a string from a json (could be yml as well) and render it based on language.
*
* Examples:
* ```
* const enUS = i18n('en-us'); // load a function that provides all en-us strings.
* const ptBR = i18n('pt-br'); // load a function that provides all pt-br strings.
*
@jancassio
jancassio / README.md
Last active March 6, 2020 11:26
React Hooks

React Hooks

useImage

Provides an image from a respective URL

Usage

const Component = ({ src, alt, width = 320, height = 240, fallback }) => {
/**
Removes accents from strings.
Example:
stripAccents("Jânio Cássio") // outputs Janio Cassio
@param string The string to strip accents with
@return A new string with without accents.
*/
function stripAccents(string) {
@jancassio
jancassio / SmoothScroller.svelte
Last active February 27, 2024 09:43
Svelte Smooth Scroller Component
<!--
Smooth scroller
Just add any scrollable container inside this component.
Dependencies:
This example depends on GSAP to perform scroll y position across many browsers. It could
be replaced by any function that resolves scroll position for all browsers to cover with.

Smooth Scroller for React

It's a port of Sooth Scroller for Svelte for React.

Actually, it requires GSAP, TypeScript & Tailwindcss are optional.

To remove TypeScript, just remove the type marks. To remove Tailwindcss, remove tailwindclasses but don't forget to reproduce the same styles in the elements with pure CSS.

Dependencies:

@jancassio
jancassio / String+Localized.swift
Created April 15, 2021 23:53
Localizable String Extensions
//
// String+Localized.swift
//
// Created by Jan Cássio on 2021/03/27.
// Copyright © 2021 Jan Cassio. All rights reserved.
//
import Foundation
extension String {
@jancassio
jancassio / README.md
Last active November 2, 2021 21:00
StatefulPreview

StatefulPreview.swift

What's it?

StatefulPreview is a simple struct wrapped in a PreviewProvider extension that enables stateful previews for SwiftUI views.

Why?

Fields wrapped in @Binding annotation, are not easy to preview as stateful value. It's possible to wrap a value using .constant utilty but it will not allow to modify the value.