Skip to content

Instantly share code, notes, and snippets.

View hectorddmx's full-sized avatar

Hector De Diego hectorddmx

View GitHub Profile
/// |                    World                 |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
  1. World is a module
  2. World is aware of all modules.
  3. Modules aren't aware of World.
@RuiAAPeres
RuiAAPeres / opaqueEquivalent.swift
Last active February 18, 2020 07:50
Extension to provide an equivalent opaque UIColor to a UIColor with alpha channel. So: f(r,g,b,a) == (r,g,b,1)
import UIKit
public extension UIColor {
var components: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
@mattt
mattt / UIViewControllerPreview.swift
Last active December 3, 2024 07:42
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@liitfr
liitfr / README.md
Last active December 16, 2024 17:58
[how to revert 100644 → 100755 commits ?] #git #chmod

how to revert 100644 → 100755 commits

  • on your repo's root, run : find . -type f | xargs chmod -x
  • commit this change on files : commit -n -m 'fix: files permission from 100755 to 100644'
  • then with vim .git/config, set filemode option to false
[core]
        filemode = false
@mattgallagher
mattgallagher / AppDelegate.swift
Last active May 18, 2022 17:42
Animated circle views in SwiftUI and AppKit/CoreAnimation
//
// AppDelegate.swift
// SwiftUITestApp
//
// Created by Matt Gallagher on 4/6/24.
// Copyright © 2019 Matt Gallagher. All rights reserved.
//
import Cocoa
import SwiftUI
javascript: (function () {
const demoClasses = document.querySelectorAll('.taskboard-row-summary');
demoClasses.forEach(element => {
element.classList.toggle('hidden');
});
}());
@jmarkstar
jmarkstar / AlamofireCodable.swift
Last active June 6, 2023 16:45
Decode Alamofire response to a Generic codable type but if we get http code 400, I decode different json which is a error message.
@discardableResult
private func performRequest<T:Decodable>(route: APIRouter, decoder: JSONDecoder = JSONDecoder(), completion:@escaping (Int, Result<T>)->Void) -> DataRequest {
return Alamofire.request(route).responseData() { responseData in
guard let response = responseData.response else {
completion(APIClient.responseErrorCode, .failure(ApiError.internalServerError(NSLocalizedString("service_error", comment: AppConstant.EMPTY))))
return
}
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 30, 2025 02:57
set -e, -u, -o, -x pipefail explanation
@magnatronus
magnatronus / main.dart
Created September 13, 2018 14:08
Demo of Oscilloscope using Stream Data
/// Demo of using the oscilloscope package
/// This uses the output from the Acceleromter on a device
import 'package:flutter/material.dart';
import 'package:oscilloscope/oscilloscope.dart';
import 'package:sensors/sensors.dart';
void main() => runApp(new MyApp());
@somoso
somoso / install-android-sdk-tools.sh
Created August 4, 2018 19:14
Install command line Android SDK tools and set up bash/zsh profile to allow tools to make use of new SDK tools
#!/usr/bin/env bash
SDK_LINUX=https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
SDK_MAC=https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip
if [ -z ${JAVA_HOME+x} ]; then
echo "\$JAVA_HOME environmental variable is not set."
echo "Find the location of your Java directory, and then put it in your"
echo "~/.bash_profile (or any other shell equivalent)"
exit 0