Skip to content

Instantly share code, notes, and snippets.

@yogeshmanghnani
yogeshmanghnani / CircularProgressBar.swift
Last active June 23, 2021 11:04
This is a Circular Progress Bar View. Demo application at :- http://github.com/yogeshmanghnani/circularProgressBar
//
// CircularProgressBar.swift
// attendance-manager
//
// Created by Yogesh Manghnani on 02/05/18.
// Copyright © 2018 Yogesh Manghnani. All rights reserved.
//
import UIKit
@lengocgiang
lengocgiang / animation.swift
Created December 3, 2017 09:52
addSubview and removeFromSuperview animation in Swift 4.0
# addSubview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
self.view.addSubview(view)
}, completion: nil)
# removeFromSuperview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
subview.removeFromSuperview()
}, completion: nil)
@martincalvert
martincalvert / Xcode_Playground_URLSession.swift
Last active November 7, 2021 15:13
How to run URLSession requests in the playground in XCode 8.3
//: Playground - noun: a place where people can play
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
var request = URLRequest(url: URL(string: "https://api.github.com/")!)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
@yuv4ik
yuv4ik / ExtendedEntry.cs
Created May 5, 2017 13:59
Xamarin.Forms iOS Numeric Keyboard With 'Done' Button
using Xamarin.Forms;
namespace YourNamespace.Controls
{
public class ExtendedEntry : Entry { }
}
func imageByAddingBorder(width: CGFloat, color: UIColor) -> UIImage? {
UIGraphicsBeginImageContext(self.size)
let imageRect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)
self.draw(in: imageRect)
let context = UIGraphicsGetCurrentContext()
let borderRect = imageRect.insetBy(dx: width / 2, dy: width / 2)
context?.setStrokeColor(color.cgColor)
@norsez
norsez / UIImage+Rotation.swift
Last active February 19, 2023 04:54
Rotate UIImage by radians in Swift 3
extension UIImage {
func image(withRotation radians: CGFloat) -> UIImage {
let cgImage = self.cgImage!
let LARGEST_SIZE = CGFloat(max(self.size.width, self.size.height))
let context = CGContext.init(data: nil, width:Int(LARGEST_SIZE), height:Int(LARGEST_SIZE), bitsPerComponent: cgImage.bitsPerComponent, bytesPerRow: 0, space: cgImage.colorSpace!, bitmapInfo: cgImage.bitmapInfo.rawValue)!
var drawRect = CGRect.zero
drawRect.size = self.size
let drawOrigin = CGPoint(x: (LARGEST_SIZE - self.size.width) * 0.5,y: (LARGEST_SIZE - self.size.height) * 0.5)
@onjin
onjin / docker-compose.yml
Created September 5, 2016 09:17
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
@jandrewmc
jandrewmc / gist:de26c518169a6d8c833c8fda1755efad
Created May 23, 2016 12:44
Installing cocoapods and RVM and Ruby
\curl -sSL https://get.rvm.io | bash -s stable
rvm install ruby
gem install cocoapods
@subfuzion
subfuzion / curl.md
Last active May 6, 2024 02:31
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@cybersamx
cybersamx / script_to_run_in_rails.rb
Last active July 26, 2023 18:40
Load and execute a Ruby script in Rails console
# Say you need to run this script which is not part of your Rails app...
# Do the following:
#
# 1. Assume we put this script file in <Rails app root>/tmp
# 2. $ cd <Rails app root>
# 3. $ rails console
# 4. ruby > load "#{Rails.root}/tmp/script_to_run_in_rails.rb"
# 5. ruby > MyClass.echo
# Hello
# => nil