Skip to content

Instantly share code, notes, and snippets.

View romyilano's full-sized avatar
😎
improving

Romy romyilano

😎
improving
View GitHub Profile
/// Request to form the search URLRequests for the Open library app (Version 1)
/// - For subject searches the search terms must be lowercased or it will return XML + a 200 response
enum SearchRequest: NetworkRequestProtocol {
var timeout: TimeInterval? {
TimeInterval(BookAPIConstants.standardTimeout)
}
case subjectSearch(String)
// case subjectSearchParameters(SubjectSearchInfo)
fn main() {
println!("Hello, world!");
// fixed sized array
let arr1 : [i32; 4] = [3, 23, 4, 2];
println!("first element of array {}", arr1[0]);
println!("the array is {} long", arr1.len());
let xs: [i64; 2] = [1, 3];
// Arrays are stack allocated.
println!("Array occupies {} bytes", std::mem::size_of_val(&xs));
@romyilano
romyilano / rust.rs
Created July 1, 2024 22:40
handling a vector and array. Note that the &a is a reference to the elements of array a which are on the stack. Vectors live on the heap.
fn main() {
let tuple = array_and_vec();
println!("{:?} array and {:?} vector", tuple.0, tuple.1);
}
fn array_and_vec() -> ([u32; 4], Vec<u32>) {
let a = [1, 25, 200, 203];
let mut v = Vec::new();
// reference symbol in a (a pointer to the stack)
for element in &a {
@romyilano
romyilano / epub.py
Last active June 23, 2024 23:54
general epub script for book printing
import os
import re
import subprocess
import argparse
# Set up argument parsing
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--format", action='append', choices=['tex', 'pdf', 'epub'], type=str.lower, required=True)
parser.add_argument("--skip-image-generation", help="skip image generation", action="store_true")
args = parser.parse_args()
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
@romyilano
romyilano / combineSample.swift
Created January 23, 2024 22:41
ways of doing core location in the different async frameworks
// super rusty on combine
// https://brightdigit.com/tutorials/combine-corelocation-publishers-delegates/
class CLLocationManagerPublicist: NSObject, CLLocationManagerCombineDelegate {
...
let locationSubject = PassthroughSubject<[CLLocation], Never>()
func locationPublisher() -> AnyPublisher<[CLLocation], Never> {
return locationSubject.eraseToAnyPublisher()
}
func locationManager(_: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
@romyilano
romyilano / appleWatchStateTransition.md
Last active January 17, 2024 02:03
Apple watchOS state transition

Handling Common State Transitions

The watch is a little different from the phone but has the same states

  1. not running
  2. inactive
  3. active
  4. background
  5. suspended
@romyilano
romyilano / mermaid.md
Last active January 16, 2024 23:44
Drawing mermaid state machine diagrams

Add a space in a state name

stateDiagram
    classDef yourState font-style:italic,font-weight:bold,fill:white

    yswsii: Your state with spaces in it
 [*] --&gt; yswsii:::yourState
@romyilano
romyilano / documentation.md
Last active September 28, 2023 23:16
swift memory review
  • arrays and variable-size collections use copy-on-write optimization
  • multiple copies of an array share the same storage