Skip to content

Instantly share code, notes, and snippets.

alias cd..='cd ..'
alias gs='git status'
@bleft
bleft / ViewUp.swift
Created June 26, 2015 10:41
move hidden text fields up if keyboard appears
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyBoardWillShow:", name: UIKeyboardDidShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyBoardWillHide:", name: UIKeyboardDidHideNotification, object: nil)
}
public override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
NSNotificationCenter.defaultCenter().removeObserver(self)
}
@bleft
bleft / gist:e88cfe0d7504ab725f76
Created June 23, 2015 13:46
remove special characters from string for save text input
function strippedString(OriginalString){
var newString = OriginalString.replace(/\?/g,'?');
newString = newString.replace(/(<([^>]+)>)/ig,"");
return newString;
}
@bleft
bleft / UIImage+Extension.swift
Last active March 6, 2018 14:18
resize UIImage
extension UIImage {
/**
returns an UIImage with the given height
**/
func resizedImage(newHeight: CGFloat) -> UIImage {
let scale = newHeight / self.size.height
let newWidth = self.size.width * scale
UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
self.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
@bleft
bleft / php.ini
Created May 13, 2015 15:14
php ini with XDebug
[Xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=On
xdebug.remote_port=9000
xdebug.profiler_enable_trigger=1
xdebug.max_nesting_level=250
@bleft
bleft / terminal defaults
Last active August 29, 2015 14:15
terminal copy without text attributes
kopieren als reiner Text:
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.no-attributes
und wieder aktivieren:
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.attributes
@bleft
bleft / swift_singleton.swift
Last active July 17, 2017 12:54
swift singleton
class SingletonClass {
static let shared = SingletonClass()
// mark init as private to prevent from calling it directly
private init(){
// set your default properties
}
class var shared: SingletonClass {
@bleft
bleft / roundView.swift
Created October 17, 2014 10:46
Make round UIView
let layer = view.layer
layer.cornerRadius = CGRectGetWidth(mapView.bounds) / 2
layer.borderWidth = 1
layer.masksToBounds = true
@bleft
bleft / gist:c9ae29f3cd51ea439c63
Created September 24, 2014 14:34
colors in terminal: .bash_profile
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
@bleft
bleft / maxNumbersOfLines.m
Created July 22, 2014 14:40
set maximum number of lines on UITextView
// the following snippet sets the number of lines to 1
myTextView.attributedText = [[NSAttributedStringalloc] initWithString:@"my too long text"];
myTextView.textContainer.maximumNumberOfLines = 1;
myTextView.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;