Skip to content

Instantly share code, notes, and snippets.

View ysoftware's full-sized avatar

Yaroslav Erohin ysoftware

View GitHub Profile
@ysoftware
ysoftware / file.cpp
Created June 5, 2019 12:07
Testing-1
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
@ysoftware
ysoftware / file.cpp
Created June 5, 2019 12:06
Testing-1
#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");
@ysoftware
ysoftware / file.cpp
Created June 5, 2019 12:05
Testing-1
#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);
@ysoftware
ysoftware / Localizable.strings
Created February 2, 2019 14:10
Example of localizable file on iOS
/* */
"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";
@ysoftware
ysoftware / Bool+Data.swift
Created December 26, 2018 10:02
Convert Bool to Data and back
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
@ysoftware
ysoftware / Global.java
Last active March 13, 2017 12:05
Global class that keeps an object in memory. Can be used to pass objects to a new Activity instead of using Intent. Will not work if Intent is in a different process. Overall this is a very fragile system and will fail at any given chance.
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) {
@ysoftware
ysoftware / RoundedView.swift
Last active January 16, 2017 14:34
Views with simple effects
@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]
@ysoftware
ysoftware / NotificationObserver.swift
Last active March 13, 2017 10:15
Notification center observers for multiple notifications with block
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.