Skip to content

Instantly share code, notes, and snippets.

💭
coding 👩🏻‍💻

Phyllis Wong PhyllisWong

💭
coding 👩🏻‍💻
View GitHub Profile
View Async to Synchronous
public func get<T>(key: String, defaultValue: T) -> Any {
let group = DispatchGroup()
var allocations = [JSON]()
var value = [JSON]()
if (futureAllocations == nil) { return defaultValue }
// This needs to be a blocking operation
let _ = self.futureAllocations?.done { (jsonArray) in
allocations = jsonArray
View LRUCache Swift
import Foundation
public class LRUCache<KeyType: Hashable> {
private let maxSize: Int
private var cache: [KeyType: Any] = [:]
private var priority: LinkedList<KeyType> = LinkedList<KeyType>()
private var key2node: [KeyType: LinkedList<KeyType>.LinkedListNode<KeyType>] = [:]
public init(_ maxSize: Int) {
self.maxSize = maxSize
View Intercom-settings-stg
<script>
// app ID
var intercomSettings = {
app_id: "r0j5pbsv"
};
// Verifies and cleans all GTM variables
function pushGTMVariablesToIntercom(gtmKey, gtmValue) {
if(gtmValue != null && gtmValue != "" && gtmValue != "undefined") {
if(typeof gtmValue == "string") {
View shopsTableView.swift
extension ShopsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedShop = fetchedResultsController.object(at: indexPath)
let st = UIStoryboardname: "Main", bundle: Bundle.main)
let vc = st.instantiateViewController(withIdentifier: "EmployeeViewController") as! EmployeeViewController
vc.shop = selectedShop
self.navigationController?.pushViewController(vc, animated: true)
}
@PhyllisWong
PhyllisWong / ProgressBar.js
Created Dec 13, 2018
Simple progress bar component with inline style
View ProgressBar.js
import React from 'react'
// ES6 JS object
const containerStyle = {
'position': 'relative',
'height': '20px',
'width': '350px',
'border-radius': '350px',
'border': '1px solid #333'
};
@PhyllisWong
PhyllisWong / Square.js
Last active Dec 12, 2018
Square with CSS stylesheet
View Square.js
import React, { Component } from 'react';
import './Square2.css';
class Square extends Component {
render () {
return (
<div className='sq2-container'>
<h1 className='sq2-title'>Even better title</h1>
<p className='sq-content'>Much improved content</p>
</div>
@PhyllisWong
PhyllisWong / Square.js
Last active Dec 11, 2018
simple square component for tutorial example
View Square.js
import React from 'react';
const Square = () => {
const sqStyle = {
"border": "1px solid black",
"color": "#a9a9a9"
}
return (
<div className='sq-container' style={sqStyle}>
You can’t perform that action at this time.