Skip to content

Instantly share code, notes, and snippets.

@rowej83
rowej83 / responsive-helpers
Created July 23, 2014 13:01
Hidden/Visible responsive helper classes for PureCSS Framework - using pixels or EMs
/* pure-hidden-xs */
@media screen and (max-width:567px) {
.pure-visible-sm{display:none}
.pure-visible-md{display:none}
.pure-visible-lg{display:none}
.pure-visible-xl{display:none}
.pure-hidden-xs{display:none}
}
/* pure-hidden-sm */
@media screen and (min-width:568px) and (max-width:767px) {
@bgreenlee
bgreenlee / UIImage+Resize.swift
Created November 23, 2015 05:24
Swift port of UIImage+Resize, UIImage+Alpha, and UIImage+RoundedCorner, from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
// UIImage+Resize.swift
// Port of UIImage+Resize.m
// from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
import Foundation
import UIKit
extension UIImage {
@yiwenl
yiwenl / hsv2rgb
Last active October 24, 2024 01:30
GLSL Color Coversions
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
@eonist
eonist / NSView overlapping interaction
Created December 15, 2015 07:24
The following code demonstrates how you can handle overlapping tracking areas
import Cocoa
/*
let a = TempNSView(frame:NSRect(0,0,100,100))
a.name = "a"
addSubview(a)
let b = TempNSView(frame:NSRect(50,50,100,100))
b.name = "b"
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage {
@nyg
nyg / Uptime.swift
Last active April 1, 2024 21:35
Get boot time and uptime for macOS & iOS.
// https://stackoverflow.com/a/45068046/5536516
import Foundation
func kernelBootTime() -> timeval {
var mib = [ CTL_KERN, KERN_BOOTTIME ]
var bootTime = timeval()
var bootTimeSize = MemoryLayout<timeval>.size