Skip to content

Instantly share code, notes, and snippets.

// From:
// http://www.stone.com/The_Cocoa_Files/Thanks_A_Bundle_.html
// here's how we determine the size of the actual image in the ImageView:
// I reused this code from PhotoToWeb, since it worked already!
- (float)photoReduction {
NSSize size = [[self image] size];
NSRect iFrame = [self bounds];
if (NSWidth(iFrame) > size.width && NSHeight(iFrame) > size.height) return 1.0; // it fits
@jadeatucker
jadeatucker / HOWTODMG.md
Last active July 10, 2024 23:35
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

##Creating the DMG file #Disk Utility

@BrandonSmith
BrandonSmith / AndroidManifest.xml
Last active July 19, 2023 19:11
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
import Foundation
import UIKit
public enum UIButtonBorderSide {
case Top, Bottom, Left, Right
}
extension UIButton {
public func addBorder(side: UIButtonBorderSide, color: UIColor, width: CGFloat) {
@ssherar
ssherar / UIColorFromRGB.swift
Last active April 18, 2017 21:05
UIColorFromRGB - adapted from http://stackoverflow.com/a/12397366 for Swift
/**
Returns a UIColor object from a Hexadecimal string with a solid colour
i.e.
UIColorFromRGB("#FF0000") == UIColor.redColor()
UIColorFromRGB("#0000FF") == UIColor.blueColor()
UIColorFromRGB("#GGGGGG") == UIColor.blackColor()
UIColorFromRGB("#Hello") == UIColor.blackColor()
@ishida
ishida / gist:d76dce6e30eaf0a77dbb
Last active September 28, 2021 17:09
Update line height of UILabel in storyboard
@implementation UILabel (Extensions)
...
- (void)setLineHeight:(float)lineHeight
{
NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
paragrahStyle.minimumLineHeight = lineHeight;
paragrahStyle.maximumLineHeight = lineHeight;
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]
@rodrigohenriques
rodrigohenriques / ClickToSelectEditText.java
Last active July 28, 2024 11:13
Used to make your EditText a better option than Spinners
public class ClickToSelectEditText<T extends Listable> extends AppCompactEditText {
List<T> mItems;
String[] mListableItems;
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
public ClickToSelectEditText(Context context) {
super(context);
@MrJackdaw
MrJackdaw / UIView+Border.swift
Last active May 12, 2023 19:02
Swift 3 Extension for adding border to one side of UIView
// This syntax reflects changes made to the Swift language as of Aug. '16
extension UIView {
// Example use: myView.addBorder(toSide: .Left, withColor: UIColor.redColor().CGColor, andThickness: 1.0)
enum ViewSide {
case Left, Right, Top, Bottom
}
@subinkrishna
subinkrishna / MainActivity.java
Created October 1, 2016 21:46
Sample - Height animation using ObjectAnimator
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Property;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
public class MainActivity extends AppCompatActivity {
@bishalg
bishalg / CoreDataHelper.swift
Last active September 30, 2020 18:05
CoreData Helper to Delete All Entities
//
// CoreDataHelper.swift
// Xcode 8.0
// Swift 3.0
// Subclass of CoreDataStack -
// https://gist.github.com/bishalg/6e3a4fc4020b558f40b02c1d835aad8b
//
import Foundation
import CoreData