Skip to content

Instantly share code, notes, and snippets.

View eliakorkmaz's full-sized avatar
🎯
Focusing

Emrah Korkmaz eliakorkmaz

🎯
Focusing
View GitHub Profile
@Digitalchemy
Digitalchemy / CropImage.cs
Created February 6, 2011 06:21
iOS: Crop a UIImage to the specified Rect
// Crop a UIImage to the specified cropRect
public UIImage CropImage(UIImage image, RectangleF cropRect)
{
UIGraphics.BeginImageContextWithOptions(cropRect.Size, false, 0);
var context = UIGraphics.GetCurrentContext();
context.TranslateCTM(0.0f, image.Size.Height);
context.ScaleCTM(1.0f, -1.0f);
context.DrawImage(new RectangleF(0, 0, image.Size.Width, image.Size.Height), image.CGImage);
context.ClipToRect(cropRect);
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active June 22, 2024 05:19
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@manjeshpv
manjeshpv / Apple Push Notification APNS PHP Snippet.php
Last active May 24, 2023 22:56
Apple Push Notification APNS PHP Snippet - Server Side Implementation
<?php
$deviceToken = '6e1326c0e4758b54332fab3b3cb2f9ed92e2cd332e9ba8182f49027054b64d29'; // iPad 5s Gold prod
$passphrase = '';
$message = 'Hello Push Notification';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'pushcert.pem'); // Pem file to generated // openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts // .p12 private key generated from Apple Developer Account
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); // production
// $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); // developement
@gonzalezreal
gonzalezreal / ios-cell-registration-swift.md
Last active March 13, 2024 15:18
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@ccabanero
ccabanero / how-to-create-a-cocoa-pod
Last active April 1, 2023 04:43
How to Create a Cocoa Pod
Notes for Creating a Cocoa Pod
Pod Version: 0.39.0
OS: OS X El Capitain (10.11.3)
- - - - - - - - - - - - - - - - - - - - - - -
1. Install CocoaPods (https://guides.cocoapods.org/using/getting-started.html)
2. Create Xcode project to author the Pod
@subfuzion
subfuzion / curl.md
Last active June 22, 2024 13:47
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@samwarnick
samwarnick / UIRoundedButtonWithGradientAndShadow.swift
Last active December 26, 2021 16:45
A rounded button with a gradient and shadow written in swift
class UIRoundedButtonWithGradientAndShadow: UIButton {
let gradientColors : [UIColor]
let startPoint : CGPoint
let endPoint : CGPoint
required init(gradientColors: [UIColor],
startPoint: CGPoint = CGPoint(x: 0, y: 0.5),
endPoint: CGPoint = CGPoint(x: 1, y: 0.5)) {
self.gradientColors = gradientColors
@candostdagdeviren
candostdagdeviren / .swiftlint.yml
Last active April 27, 2024 08:48
Sample SwiftLint file to apply best practices
disabled_rules: # rule identifiers to exclude from running
- variable_name
- nesting
- function_parameter_count
opt_in_rules: # some rules are only opt-in
- control_statement
- empty_count
- trailing_newline
- colon
- comma
@TheCodedSelf
TheCodedSelf / RxSwiftBindToButton.swift
Created May 13, 2017 17:16
RxSwift: Bind to button taps
import UIKit
import RxSwift
import RxCocoa
let button = UIButton()
button.rx.tap.bind {
print("button tapped")
}
@zkat
zkat / index.js
Last active March 10, 2024 14:32
npx is cool
#!/usr/bin/env node
console.log('yay gist')