Skip to content

Instantly share code, notes, and snippets.

View juliengdt's full-sized avatar
🎯
Focusing

juliengdt juliengdt

🎯
Focusing
View GitHub Profile
@juliengdt
juliengdt / HowTo_Markdown.md
Created August 27, 2014 07:47
Markdown usage in a project

Markdown

Markdown Usage in Your Project

What it means ?

It means to use Markdown formatting and Markdown files to enhance your projects, more precisely the management around it.

Markdown synthax is essentially used for formatting raw text into a bit more sexy one (This file is MD formatted !).

@juliengdt
juliengdt / hook-system-git.md
Created August 27, 2014 07:48
Hook system in Git

commit-msg - The Hook

Hooks are plugins which can be launch by git, on a special event. The commit-msg hook, if defined, is launched when user want commit

It's a git-enforced policy, used in entreprise to force dev to correctly format their commit messages

A custom one

Here is a custom commit-msg hook which looks for a format like these both:

  • [ADD] - It's a message where i add something
@juliengdt
juliengdt / commit-msg
Created August 27, 2014 07:50
commit-msg
#!/bin/sh
# author: julien gdt
# regex='^[\[](ADD|IMP|FIX)[\]]'
# regexjira='^[\[]JIRA[\]][[:space:]][\#][0-9]'
# regexversion='^Version[[:space:]][0-9]\.[0-9]\.[0-9][[space:]][a-zA-Z]{3,}'
var=`head -n 1 "$1"`
function info
@juliengdt
juliengdt / versionAndBuild.swift
Created April 21, 2015 08:46
[SWIFT] App Version & Build Number
extension UIApplication {
class func appVersion() -> String {
return NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as! String
}
class func appBuild() -> String {
return NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey as String) as! String
}
@juliengdt
juliengdt / jackyScript.sh
Created July 20, 2015 16:06
Jacky Script for Xcode Build Phases
#CODE COMPLEXITY
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 wc -l | awk '$1 > 400 && $2 != "total" {for(i=2;i<NF;i++){printf "%s%s", $i, " "} print $NF ":1: warning: File more than 400 lines (" $1 "), consider refactoring." }'
#TODO & FIXME CHECKER
KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
#TOTAL LINES - USELESS BUT FUN
echo "Total lines of code:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 cat | wc -l
@juliengdt
juliengdt / UIViewExtension.swift
Last active August 29, 2015 14:25
ClosureMiniKit
//
// UIViewExtension.swift
// SwiftTester
//
// Created by JulienGdt on 07/07/15.
// Copyright (c) 2015 JulienGdt @jlngdt. All rights reserved.
// @see https://gist.github.com/juliengdt/a80deda0ed2240b4d347
//
import UIKit
@juliengdt
juliengdt / gist:e1c143a7e6652458bb0b
Last active August 29, 2015 14:25 — forked from bwhiteley/gist:049e4bede49e71a6d2e2
Initialize Swift subclass of UIView, designed in .xib
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet weak private var contentView:UIView!
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
self.commonInit()
@juliengdt
juliengdt / SpringExtension.swift
Last active August 29, 2015 14:27
Because Spring framework in Swift 2.0 is awesome, lazy functions are moaar awesome !!!
extension SpringView {
func fadeIn(duration: CGFloat, completion: (() -> ())? = nil) {
self.animation = "fadeIn"
self.duration = duration
self.animateNext() {
completion?()
}
}
@juliengdt
juliengdt / AutoScroll.swift
Last active August 29, 2015 14:27
Auto-Scroll in Swift, wherever you want, everywhere - not perfect but works like a charm
extension UIView {
//MARK: - AutoScroll Stuff -
private func autoScroll(view: UIView, kbFrame: CGRect, animated: Bool) {
let offset = kbFrame.height + 20
let deltaOffset = CGRectGetMinY(view.convertRect(view.bounds, toView: self.view)) - offset
autoScrollOffset = deltaOffset < 0 ? 0 : deltaOffset
totalAutoScrollOffset = autoScrollOffset
@juliengdt
juliengdt / ats-workaround.plist
Created October 14, 2015 14:35
Apple ATS Workarounds
<!--Allow unsecured connections in a whitelist-->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>