Skip to content

Instantly share code, notes, and snippets.

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@jwebcat
jwebcat / gist:5122366
Last active June 20, 2024 13:35 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@samirahmed
samirahmed / errorcodes.m
Created November 13, 2014 18:13
NSURLErrorDomain codes
kCFURLErrorUnknown = -998,
kCFURLErrorCancelled = -999,
kCFURLErrorBadURL = -1000,
kCFURLErrorTimedOut = -1001,
kCFURLErrorUnsupportedURL = -1002,
kCFURLErrorCannotFindHost = -1003,
kCFURLErrorCannotConnectToHost = -1004,
kCFURLErrorNetworkConnectionLost = -1005,
kCFURLErrorDNSLookupFailed = -1006,
kCFURLErrorHTTPTooManyRedirects = -1007,
@derhuerst
derhuerst / _.md
Last active June 9, 2024 10:05
List of HAFAS API Endpoints
@dogancelik
dogancelik / bookmarks.sql
Last active November 24, 2023 06:32
Export Firefox Mobile Bookmarks #Android
/* bookmarks are stored in “/data/data/org.mozilla.firefox/files/mozilla/…….default/browser.db” */
SELECT url, created
FROM bookmarks
WHERE COALESCE(url, '') <> ''
ORDER BY created ASC
@joshavant
joshavant / UITextView+HeightCalculation.swift
Created July 21, 2016 03:00
UITextView Height Calculation
extension UITextView {
// Note: This will trigger a text rendering!
func calculateViewHeightWithCurrentWidth() -> CGFloat {
let textWidth = self.frame.width -
self.textContainerInset.left -
self.textContainerInset.right -
self.textContainer.lineFragmentPadding * 2.0 -
self.contentInset.left -
self.contentInset.right
@ollieatkinson
ollieatkinson / HTTPStatusCode.swift
Last active April 15, 2024 18:34
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
@Bogidon
Bogidon / GrowingTextView.swift
Last active February 15, 2021 20:06
A UITextView subclass that grows with its text but allows scrolling according to AutoLayout constraints. Updates intrinsicContentSize. For an animatable version see https://gist.github.com/Bogidon/632e265b784ef978d5d8c0b86858c2ee
//
// GrowingTextView.swift
// https://gist.github.com/Bogidon/cc0c9ae6f041413c39fb0ff146ad1b18
//
// Created by Bogdan Vitoc on 02/22/2017.
// Distributed under the MIT License: https://gist.github.com/Bogidon/cc0c9ae6f041413c39fb0ff146ad1b18#file-license
//
import UIKit
@marcc-orange
marcc-orange / ScaledHeightImageView.swift
Last active April 5, 2023 09:22
An image view that can computes its intrinsic height from its width while preserving aspect ratio
import UIKit
/// An image view that computes its intrinsic height from its width while preserving aspect ratio
/// Source: https://stackoverflow.com/a/48476446
class ScaledHeightImageView: UIImageView {
// Track the width that the intrinsic size was computed for,
// to invalidate the intrinsic size when needed
private var layoutedWidth: CGFloat = 0