Skip to content

Instantly share code, notes, and snippets.

View luisburgos's full-sized avatar
🎯
Focusing

Luis Burgos luisburgos

🎯
Focusing
View GitHub Profile
@ltOgt
ltOgt / conditional_parent_widget.dart
Created June 29, 2020 14:50
Flutter Widget to conditionally wrap a subtree with a parent without breaking the code tree
import 'package:flutter/widgets.dart';
/// Conditionally wrap a subtree with a parent widget without breaking the code tree.
///
/// [condition]: the condition depending on which the subtree [child] is wrapped with the parent.
/// [child]: The subtree that should always be build.
/// [conditionalBuilder]: builds the parent with the subtree [child].
///
/// ___________
/// Usage:
@apgapg
apgapg / my_stream_builder.dart
Created April 20, 2020 14:16
Wrapper of StreamBuilder for managing error and loading on its own. Fully customisable
import 'package:flutter/material.dart';
import 'package:workozy_app/widgets/helper/stream_error_widget.dart';
import 'package:workozy_app/widgets/helper/stream_loading_widget.dart';
typedef OnData<T> = Widget Function(T data);
typedef OnError = Widget Function(dynamic e);
typedef OnLoading = Widget Function();
class MyStreamBuilder<T> extends StatelessWidget {
MyStreamBuilder({
@shaps80
shaps80 / 1. StateMachine.swift
Last active May 17, 2023 12:27
A lightweight generic state machine implementation in Swift.
import Foundation
import os.log
public protocol StateMachineDelegate: class {
associatedtype StateType: Hashable
/// Invoked before a transition is about to occur, allowing you to reject even a valid transition. Defaults to true
///
/// - Parameters:
/**
* Crop a image taking a recerence a view parent like a frame, and a view child like final
* reference
*
* @param bitmap image to crop
* @param frame where the image is set it
* @param reference frame to take reference for crop the image
* @return image already cropped
*/
public static byte[] cropImage(Bitmap bitmap, View frame, View reference){
@Kraiden
Kraiden / BetterBounceInterpolator.java
Last active December 30, 2020 03:31
A more configurable bounce interpolator for Android animations
import android.view.animation.Interpolator;
import static java.lang.Math.*;
public class BetterBounceInterpolator implements Interpolator {
private int mBounces;
private double mEnergy;
/** Have more control over how to bounce your values.
*
@eofster
eofster / DependencyInjectionExample.swift
Created November 17, 2015 13:40
Dependency injection example with tests
import Foundation
import XCTest
//////////////////////////////////////////////////////////////////////
// Preferences
protocol UserDefaults {
func stringForKey(key: String) -> String
}
@jpalala
jpalala / how-to-setup-mac-elasticsearch.md
Created September 11, 2015 08:28
setting up elasticsearch on your mac with brew

Install va homebrew

If you don't have homebrew installed - get homebrew here

Then run: brew install elasticsearch

Configuration

Update the elasticsearch configuration file in /usr/local/etc/elasticsearch/elasticsearch.yml.

@vitalbone
vitalbone / keystone2heroku.md
Last active January 1, 2023 23:35
Deploying KeystoneJS to Heroku

Deploying a Keystone App to Heroku

Keystone comes completely set up to install on Heroku in a couple of steps.

1. Sign up for a Heroku account and install the Heroku Toolbelt.

Log in with it and you're ready to begin. Heroku uses git to deploy a new site, so with that in mind:

2. Create a new repository on Github and then clone it.

@staltz
staltz / introrx.md
Last active November 19, 2024 18:00
The introduction to Reactive Programming you've been missing
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active November 18, 2024 11:51
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k