This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
/** | |
Adds an observer with block for a notification. | |
- returns: A handle to remove observer. | |
- parameters: | |
- name: Notification name. | |
- object: Specify object you only want to listen to. | |
- block: Block to run when notification observed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBDesignable class GradientView: RoundedView { | |
@IBInspectable var topColor:UIColor = .clear { didSet { setNeedsLayout() } } | |
@IBInspectable var bottomColor:UIColor = .black { didSet { setNeedsLayout() } } | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
let gradient: CAGradientLayer = CAGradientLayer() | |
gradient.frame = bounds | |
gradient.colors = [topColor.cgColor, bottomColor.cgColor] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.annotation.Nullable; | |
@SuppressWarnings("unchecked") | |
final public class Global { | |
private static final Global shared = new Global(); | |
private Global() {} | |
private Object object; | |
// returns the object, if expected class matches | |
@Nullable static public <T> T get(Class<T> kind) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Bool { | |
var data:NSData { | |
var _self = self | |
return NSData(bytes: &_self, length: MemoryLayout.size(ofValue: self)) | |
} | |
init?(data:NSData) { | |
guard data.length == 1 else { return nil } | |
var value = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* */ | |
"error_auth_incorrectEmailLength" = "Email should be longer than 5 and shorter than 254 symbols"; | |
/* */ | |
"error_auth_incorrectPasswordLength" = "Password should be longer than 5 and shorter than 50 symbols"; | |
/* */ | |
"error_auth_invalidEmail" = "Incorrectly formatted email"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEBUG true // change to false for production env. | |
#if DEBUG | |
#define PRINT(x, y) { | |
eosio::print(x); | |
eosio::print(": "); | |
eosio::print(y); | |
eosio::print("\n"); | |
} | |
#define PRINT_(x) { | |
eosio::print(x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEBUG | |
TABLE cdp { | |
... | |
void print() const { | |
eosio::print("#"); eosio::print(id); | |
eosio::print(" c: "); eosio::print(collateral); | |
eosio::print(" d: "); eosio::print(debt); | |
eosio::print(" icr: "); eosio::print(icr); | |
eosio::print(" time: "); eosio::print(modified_round); | |
eosio::print("\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void buck::run_requests(uint8_t max) { | |
PRINT_("running requests processing"); | |
PRINT("limit", max); | |
auto cdp_itr = _cdp.begin(); | |
cdp_itr->print(); | |
} | |
// Action output: | |
// >> running requests processing | |
// >> limit: 70 |