Skip to content

Instantly share code, notes, and snippets.

Privacy Policy for Signal Peak This policy applies to the Signal Peak mobile application. Data Collection: We do not collect any personal identity information. However, the app uses third-party advertising services (like AdMob) which may collect "Identifiers" (such as IDFA) to provide personalized ads. Data Usage: Any data accessed is used solely for advertising performance and app functionality. Contact: Support at ramazan0onur@gmail.com

@rmznonur
rmznonur / stringToAnchor.js
Last active October 9, 2018 07:38
Javscript string to anchor html code
function stringToAnchor(_txt){
if(!_txt) return '';
if(
_txt.substring(0,3) == 'www' ||
_txt.substring(0,4) == 'http'
){//if url
return '<a href="'+_txt+'">'+_txt+'</a>';
}
else if(
_txt.indexOf('@') > 0
@rmznonur
rmznonur / UIButton + Border Extensions.swift
Created August 27, 2018 10:25
Add/Remove Border Extensions
//import Foundation
import UIKit
public enum UIButtonBorderSide {
case Top, Bottom, Left, Right
}
extension UIButton {
public func addBorder(side: UIButtonBorderSide, color: UIColor, width: CGFloat) {
let border = CALayer()
func shake(viewShake : UIView){
let animation = CABasicAnimation(keyPath: "position")
animation.duration = 0.07
animation.repeatCount = 4
animation.autoreverses = true
animation.fromValue = NSValue(cgPoint: CGPoint(x: viewShake.center.x - 10, y: viewShake.center.y))
animation.toValue = NSValue(cgPoint: CGPoint(x: viewShake.center.x + 10, y: viewShake.center.y))
viewShake.layer.add(animation, forKey: "position")
}
func fadeOut(_ view:UIView, duration: TimeInterval = 0.5, delay: TimeInterval = 0, completion: @escaping (Bool) -> Void = {(finished: Bool) -> Void in}) {
UIView.animate(withDuration: duration, delay: delay, options: UIViewAnimationOptions.curveEaseIn, animations: {
view.alpha = 0
}, completion: completion)
}
func fadeIn(_ view:UIView, duration: TimeInterval = 0.5, delay: TimeInterval = 0.2, completion: @escaping (Bool) -> Void = {(finished: Bool) -> Void in}) {
UIView.animate(withDuration: duration, delay: delay, options: UIViewAnimationOptions.curveEaseIn, animations: {
view.alpha = 1
}, completion: completion)
}
function formatCurrency(num)
{
num = num.toString().replace(/\$|\,/g, '');
if (isNaN(num))
num = "0";
sign = (num == ( num = Math.abs(num)));
num = Math.floor(num * 100 + 0.50000000001);
cents = num % 100;
num = Math.floor(num / 100).toString();
if (cents < 10)
String.prototype.turkishToUpper = function(){
var string = this;
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
string = string.replace(/(([iışğüçö]))+/g, function(letter){ return letters[letter]; })
return string.toUpperCase();
}
String.prototype.turkishToLower = function(){// "türkçe".turkishToLower(); // => TÜRKÇE
var string = this;
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "Ü": "ü", "Ö": "ö", "Ç": "ç" };