Skip to content

Instantly share code, notes, and snippets.

View norsez's full-sized avatar
💭
busy coding

Norsez Orankijanan norsez

💭
busy coding
View GitHub Profile
@haldun
haldun / hash.swift
Created April 6, 2016 09:13
Generic hash value computation for swift objects
func hashValue<T: Hashable>(objects: T?...) -> Int {
var result = 31
for object in objects {
result = (result &* 17) &+ object.hashValue
}
return result
}
func hashValue<T: Hashable>(objects: T...) -> Int {
var result = 31
@joepie91
joepie91 / double-number.js
Created October 27, 2015 19:41
CommonJS module example
module.exports = function(number) {
return number * 2;
}
@schickling
schickling / UIImageFixedOrientationExtension.swift
Last active December 31, 2024 22:21
Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.Up {
return self
}
var transform: CGAffineTransform = CGAffineTransformIdentity
@marchinram
marchinram / UIImage+PixelColor.swift
Last active January 19, 2022 08:53
iOS Swift UIImage subscript extension to get pixel color
import UIKit
extension UIImage {
subscript (x: Int, y: Int) -> UIColor? {
guard x >= 0 && x < Int(size.width) && y >= 0 && y < Int(size.height),
let cgImage = cgImage,
let provider = cgImage.dataProvider,
let providerData = provider.data,
let data = CFDataGetBytePtr(providerData) else {
return nil
@drmarshall
drmarshall / event_export.py
Created June 8, 2015 17:04
Example Mixpanel raw event export script
#! /usr/bin/env python
#
# Mixpanel, Inc. -- http://mixpanel.com/
#
# Python API client library to consume mixpanel.com analytics data.
import hashlib
import urllib
import time
try:
@jokester
jokester / PixelExtractor.swift
Last active September 27, 2024 05:00
extract pixel from a CGImage
// extract pixel from a CGImage
/* use case:
let extractor = PixelExtractor(img: UIImage(named: "gauge_vertical")!.CGImage!)
let color = extractor.color_at(x: 10, y: 20)
*/
class PixelExtractor {
// taken from http://stackoverflow.com/questions/24049313/
// and adapted to swift 1.2
@acj
acj / ATTENTION.md
Last active May 5, 2023 12:23
Build a movie from jpeg images in Swift using AVFoundation

This code has moved

Please refer to the TimeLapseBuilder-Swift repository on GitHub from now on.

I will leave the original code here as a reference, but new comments may be removed. Please open an issue on GitHub if you have questions or would like to contribute.

Thanks!

@vasarhelyia
vasarhelyia / brewmvc.swift
Last active August 8, 2018 19:00
Brew MVC
class Brew {
var temp = 0.0
}
class BrewViewController: UIViewController {
@IBOutlet weak var tempLabel: UILabel!
var brew = Brew()
override func viewDidLoad() {
super.viewDidLoad()
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active April 20, 2025 21:15
The best FRP iOS resources.

Videos

@imkevinxu
imkevinxu / Device.swift
Last active March 4, 2023 16:09
iOS device checks for OS version and screen size in Swift
//
// Device.swift
// imHome
//
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15.
// Copyright (c) 2015 Alpha Labs, Inc. All rights reserved.
//
import Foundation