Skip to content

Instantly share code, notes, and snippets.

@wuxiaowei
wuxiaowei / NSApplication+MXUtilities.h
Created May 16, 2018 09:46 — forked from joerick/NSApplication+MXUtilities.h
Launch at login category on NSApplication
//
// NSApplication+MXUtilities.h
// Mixim
//
// Created by Joe Rickerby on 15/09/2014.
// Copyright (c) 2014 Mixim Technology Ltd. Released under BSD Licence.
//
#import <Cocoa/Cocoa.h>
@michaelevensen
michaelevensen / PagingCollectionViewController.swift
Last active April 10, 2024 08:46
An example of perfectly paging horizontal UICollectionViewController with overflowing cells. Works great with Storyboard — no need to set any specific attributes, just add this Class to the Controller and set your desired size for the cells like you would normally.
import UIKit
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
/* Custom scrollView for paging */
let pagingScrollView = UIScrollView()
/* Return item size */
@plapier
plapier / LaunchStarter.swift
Created May 23, 2015 23:45
Add Login item using Launch Services (Shared List File) in Swift
//
// toggleLaunchAtStartup.swift
// Recents
//
// Created by Phil LaPier on 5/21/15.
// Copyright (c) 2015 Philip LaPier. All rights reserved.
//
// With help from: https://github.com/RamonGilabert/Prodam/blob/master/Prodam/Prodam/LaunchStarter.swift
import Foundation
@coreh
coreh / ScreenCapture.m
Last active April 20, 2023 16:37
Screen capture in Cocoa (Grabs the screen contents and puts it into a NSImage)
NSImage *CaptureScreen() {
// Get the Screen Rect
NSRect screenRect = [[NSScreen mainScreen] frame];
// Create a CGImage with the screen contents
CGImageRef cgImage = CGWindowListCreateImage(screenRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
// Convert the CGImage into a NSBitmapImageRep
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
@pigeon6
pigeon6 / Unlit-CastShadow.shader
Created December 7, 2012 23:11
Unlit texture shader which casts shadow on Forward/Defered
// Unlit texture shader which casts shadow on Forward/Defered
Shader "Unlit/Texture CastShadow" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Opaque" }
LOD 100
@ryanhanwu
ryanhanwu / myViewController.h
Created December 6, 2012 07:20
[iOS] Get current location and city name
@interface myViewController: UIViewController <CLLocationManagerDelegate>
CLLocationManager *locationManager;
CLLocation *currentLocation;
@end