Skip to content

Instantly share code, notes, and snippets.

😎
improving

Romy romyilano

😎
improving
Block or report user

Report or block romyilano

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@romyilano
romyilano / helloworld.js
Created Nov 29, 2019
son you must learn javascript again. at least this doesn't have all those semicolons =D
View helloworld.js
// nice quick and dirty webserver
const http = require('http')
const port = process.env.PORT || 3000
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain '})
res.end('Hello world! this is a noob server')
})
@romyilano
romyilano / atcoder.md
Last active May 19, 2019
tips for accepting input into atcoder
View atcoder.md

swift

cielavenir

let inputInt = Int(readline()!)!

let arrayInt = readlin()!.characters.split { $0== " " }.map { Int(String($0))! }
View networkingPlayground.swift
import Foundation
// async swift playground
import PlaygroundSupport
// https://min-api.cryptocompare.com/data/all/coinlist
let allCoinsPath = "/data/all/coinlist"
class CryptoApi {
View URLComponents.swift
// brushing up on url components
//
class CryptoApi {
static let host = "min-api.cryptocompare.com"
static let allCoinsPath = "/data/all/coinlist"
var allCoinsUrl: URL? = {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = CryptoApi.host
View URLComponents.swift
// brushing up on url components
//
class CryptoApi {
static let host = "min-api.cryptocompare.com"
static let allCoinsPath = "/data/all/coinlist"
var allCoinsUrl: URL? = {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = CryptoApi.host
View blockCrash.m
// https://stackoverflow.com/questions/23806751/strong-reference-to-a-weak-references-inside-blocks
__weak typeof(self) weakSelf = self;
void (^someBlock)(id) = ^(id data){
if (weakSelf != nil) {
// last remaining strong reference released by another thread.
// weakSelf is now set to nil.
[myArray addObject:weakSelf];
}
});
@romyilano
romyilano / Retain.m
Last active Apr 7, 2019
retain cycle sin blocks in objective-c thru apple. //
View Retain.m
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW16
@interface XYZBlockKeeper : NSObject
@property (copy) void (^block)(void);
@end
@implementation XYZBlockKeeper
- (void)configureBlock {
self.block = ^{
[self doSomething]; // capturing a strong reference to self
@romyilano
romyilano / DoubleProtocol.swift
Created Mar 25, 2019
From the PanModal GitHub... interesting!
View DoubleProtocol.swift
protocol RowPresentable {
var string: String { get }
// it conforms to both protocol + class
var rowVC: UIViewController & PanModalPresentable { get }
}
@romyilano
romyilano / ParentViewController.swift
Created Mar 23, 2019
Handling container views in code
View ParentViewController.swift
// thanks dude
// https://medium.com/@dushyant_db/setting-up-a-container-view-using-interface-builder-and-via-code-7ac1a7f0a0d6
override func viewDidLoad() {
super.viewDidLoad()
guard let childVC = self.storyboard?.instantiateViewController(withIdentifier: "ChildViewController") as? ChildViewController else {
return
}
addChildViewController(childVC)
@romyilano
romyilano / ParentViewController.swift
Created Mar 23, 2019
Handling container views in code
View ParentViewController.swift
// thanks dude
// https://medium.com/@dushyant_db/setting-up-a-container-view-using-interface-builder-and-via-code-7ac1a7f0a0d6
override func viewDidLoad() {
super.viewDidLoad()
guard let childVC = self.storyboard?.instantiateViewController(withIdentifier: "ChildViewController") as? ChildViewController else {
return
}
addChildViewController(childVC)
You can’t perform that action at this time.