Skip to content

Instantly share code, notes, and snippets.

View artemisia-absynthium's full-sized avatar

Cristina De Rito artemisia-absynthium

View GitHub Profile
// The SwiftUI Lab
// Website: https://swiftui-lab.com
// Article: https://swiftui-lab.com/alignment-guides
import SwiftUI
class Model: ObservableObject {
@Published var minimumContainer = true
@Published var extendedTouchBar = false
@Published var twoPhases = true
@Ravi61
Ravi61 / CustomDateCoding.swift
Created July 13, 2017 15:16
Custom Date Encoding/Decoding
// Custom Date Decoding
jsonDecoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
let data = try decoder.singleValueContainer().decode(String.self)
//perform your operation on obtained string
let disturbance = "01-07-1977"
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy"
if data == "First disturbance in force" {
return formatter.date(from: disturbance) ?? Date()
} else {
@stilist
stilist / LICENSE
Created February 3, 2017 01:06
Uninstall all non-default Ruby gems
Copyright (c) 2017 Jordan Cole
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@wojteklu
wojteklu / gitenv.md
Last active July 7, 2024 14:20
Perfect git environment on OS X

Perfect git environment on OS X

Global alias

Add the following to your ~/.bashrc:

alias g='git'

Branch auto-completion

@thatseeyou
thatseeyou / ViewController.swift
Last active August 10, 2023 13:45
How to capture video frames from the camera as images using AV Foundation on iOS
//
// ViewController.swift
//
// Technical Q&A QA1702
// How to capture video frames from the camera as images using AV Foundation on iOS
//
import UIKit
import AVFoundation
import CoreMedia
@lopspower
lopspower / README.md
Last active November 18, 2024 19:11
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@db0company
db0company / topMostViewController.swift
Created January 19, 2015 14:28
Get the top most viewController anywhere in the app (typically from the appDelegate). Get the current visible viewController.
extension UIViewController {
func topMostViewController() -> UIViewController {
if self.presentedViewController == nil {
return self
}
if let navigation = self.presentedViewController as? UINavigationController {
return navigation.visibleViewController.topMostViewController()
}
if let tab = self.presentedViewController as? UITabBarController {
if let selectedTab = tab.selectedViewController {
@pyrtsa
pyrtsa / StringSplit.swift
Created October 4, 2014 13:45
Splitting strings by a separator string in Swift
import Foundation
extension String {
public func split(separator: String) -> [String] {
if separator.isEmpty {
return map(self) { String($0) }
}
if var pre = self.rangeOfString(separator) {
var parts = [self.substringToIndex(pre.startIndex)]
while let rng = self.rangeOfString(separator, range: pre.endIndex..<endIndex) {
@comoc
comoc / ClearCanvas.java
Created October 9, 2013 02:30
Clear the Canvas of a SurfaceView for Android.
// Obtain a SurfaceView.
// SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
Canvas canvas = surfaceView.getHolder().lockCanvas();
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// Draw someting
surfaceView.getHolder().unlockCanvasAndPost(canvas);
@Jerdak
Jerdak / EchoSpheres.cs
Last active December 19, 2015 20:49
Unity multiple echo shader. Uses floating point -> pixel packing to support transmitting data from Unity component to the shader through a texture rather than as properties.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
[Serializable]
public class EchoSphere2 {
public enum ShaderPackingMode { Texture, Property };
public ShaderPackingMode CurrentPackingMode = ShaderPackingMode.Texture;