Skip to content

Instantly share code, notes, and snippets.

View nashfive's full-sized avatar

Julien Vignali nashfive

  • Lausanne, Switzerland
View GitHub Profile
@nashfive
nashfive / main.dart
Last active March 30, 2020 10:38
Provider error with ChangeNotifierProvider and Navigator.popUntil
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(MyApp());
class Store extends ChangeNotifier {
final createdAt = DateTime.now();
dispose() {
print("store.dispose()");
@nashfive
nashfive / hexStringToUint16.dart
Created December 10, 2019 14:14
Convert a hexadecimal string to a Uint16
import 'dart:typed_data';
/// Converts [input] to a Uint16.
///
/// For example, _decodeToUint16("734c") slices [input] into 2 substrings
/// of 2 hexa characters ('73' and '4c') and create a Uint8 list from their
/// respective decimal representation (i.e. [115, 76]).
///
/// Finally, it returns an unsigned 16-bits integer representation (little endian)
/// by using a [ByteData] view (i.e. '19571').
@nashfive
nashfive / UICollectionViewFlowLayout+DelegateAccess.swift
Created May 6, 2018 08:25 — forked from danielctull/UICollectionViewFlowLayout+DelegateAccess.swift
Wraps the six UICollectionViewFlowLayout delegate methods and their equivalent properties using functional programming techniques, so that values are easier to retrieve. Full details at: http://danieltull.co.uk/blog/2018/04/13/simplifying-uicollectionviewflowlayout-delegate-method-usage-with-functional-programming/
extension UICollectionViewFlowLayout {
typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value)
private var delegate: UICollectionViewDelegateFlowLayout? {
return collectionView?.delegate as? UICollectionViewDelegateFlowLayout
}
func retrieve<Key, Value>(
@nashfive
nashfive / UIButtonExtensions.swift
Last active March 29, 2018 19:23
Add a tap closure on UIButton
import UIKit
extension UIButton {
private struct Handlers {
static var touchUpInside = "touchUpInside"
}
public func tap(_ closure: @escaping (UIButton) -> Void) {
objc_setAssociatedObject(self, &Handlers.touchUpInside, closure, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
addTarget(self, action: #selector(_touchUpInside), for: .touchUpInside)
@nashfive
nashfive / .bash_profile
Created October 17, 2016 19:14 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@nashfive
nashfive / generate-header.rb
Last active August 29, 2015 14:01
Generates an Objective-C header file based on the selection.json file generated along by an iconmoon.io font package
#!/usr/local/bin/ruby
require 'rubygems'
require 'json'
fail("Input file not specified") unless ARGV.length == 1
input = ARGV.first
fail("Input file #{input} not found") unless File.exists?(input)
result = JSON.parse (File.read input), :symbolize_names => true
icons = result[:icons]
#!/bin/sh
# Download the latest httpd archive from your favorite mirror
# Configure Apache
./configure \
--enable-layout=Darwin \
--enable-mods-shared=all \
--with-mpm=prefork \
--disable-unique-id \
--enable-dav \