Skip to content

Instantly share code, notes, and snippets.

View Tantas's full-sized avatar

Joseph Preiss Tantas

  • Toronto Area, Ontario, Canada
View GitHub Profile
@fabnoe
fabnoe / ReversedUIButton.swift
Last active August 29, 2015 14:05
Draws a button with the image on the right hand side of the label
import UIKit
class ReversedUIButton: UIButton {
var buffer:NSNumber = 5
override func layoutSubviews() {
super.layoutSubviews()
let imageSize:CGSize = self.imageView.frame.size
@vszakats
vszakats / s3-upload-aws4.sh
Last active April 29, 2025 07:26
AWS S3 upload using signature v4
#!/bin/sh
# To the extent possible under law, Viktor Szakats
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# SPDX-License-Identifier: CC0-1.0
# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@jeffjohnson9046
jeffjohnson9046 / UuidHelper.java
Last active July 14, 2024 12:38
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
@saoudrizwan
saoudrizwan / Storage.swift
Last active October 27, 2021 01:51
Helper class to easily store and retrieve Codable structs from/to disk. https://medium.com/@sdrzn/swift-4-codable-lets-make-things-even-easier-c793b6cf29e1
import Foundation
public class Storage {
fileprivate init() { }
enum Directory {
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
case documents
@AlttiRi
AlttiRi / bytesToSizeWinLike.md
Last active October 19, 2023 04:42
How to format file size bytes into the human readable form like it Windows Explorer does.

How to format file size bytes into the human readable form like it Windows Explorer does

...like it Windows Explorer does.

JavaScript code:

/**
 * Formats bytes mostly like Windows does,
 * but in some rare cases the result is different.