Skip to content

Instantly share code, notes, and snippets.

View aplekhanov's full-sized avatar
🇨🇾
Working from home

Alex Plekhanov aplekhanov

🇨🇾
Working from home
View GitHub Profile
@kinlane
kinlane / Convert Word and Powerpoint File to PDF with Google Docs API
Created April 16, 2011 03:48
This will convert Microsoft Word and Powerpoint files to PDF using the Google Docs Listing API.
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@powdahound
powdahound / hipchat_bot.js
Created April 25, 2011 18:35
Basic XMPP bot example for HipChat using node.js
// Basic XMPP bot example for HipChat using node.js
// To use:
// 1. Set config variables
// 2. Run `node hipchat_bot.js`
// 3. Send a message like "!weather 94085" in the room with the bot
var request = require('request'); // github.com/mikeal/request
var sys = require('sys');
var util = require('util');
@lukaskubanek
lukaskubanek / NSBezierPath+CGPath.swift
Created June 14, 2015 08:19
NSBezierPath+CGPath.swift
import AppKit
public extension NSBezierPath {
public convenience init(path: CGPath) {
self.init()
let pathPtr = UnsafeMutablePointer<NSBezierPath>.alloc(1)
pathPtr.initialize(self)
@zacwest
zacwest / ios-font-sizes.swift
Last active June 17, 2024 01:38
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@isoiphone
isoiphone / UIImage+color.swift
Created March 28, 2016 16:45
Create UIImage of solid color
extension UIImage {
class func imageWithColor(color: UIColor, size: CGSize=CGSize(width: 1, height: 1)) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(CGRect(origin: CGPoint.zero, size: size))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
}
@SteveRohrlack
SteveRohrlack / swift.gitignore
Last active January 17, 2023 05:51
swift .gitignore template
# see https://gist.github.com/muhasturk/df28ec9d2cc18bf1cfc8
# see https://github.com/github/gitignore/blob/master/Swift.gitignore
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata
#
# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
extension String {
var localized: String {
return NSLocalizedString(self, comment: "")
}
}
// Which allows for:
"Hello world".localized
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

@nor0x
nor0x / UICollectionView + NSFetchedResultsController.swift
Last active March 21, 2021 12:52 — forked from nazywamsiepawel/UICollectionView + NSFetchedResultsController.swift
UICollectionView + NSFetchedResultsController Swift 3 / iOS 10
var _fetchedResultsController: NSFetchedResultsController<Entity>? = nil
var blockOperations: [BlockOperation] = []
var fetchedResultController: NSFetchedResultsController<Entity> {
if _fetchedResultsController != nil {
return _fetchedResultsController!
}
let fetchRequest: NSFetchRequest<Entity> = Entity.fetchRequest()
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).managedObjectContext!
enum DateStride {
case year(Int)
case month(Int)
case day(Int)
var component: Calendar.Component {
switch self {
case .year(_):
return .year