Skip to content

Instantly share code, notes, and snippets.

View edwardIshaq's full-sized avatar

Edward Ishaq edwardIshaq

View GitHub Profile
type itemsList struct {
items []int
mapItems map[int][]int
}
func newItemsList() *itemsList {
return &itemsList{
mapItems: make(map[int][]int),
}
@edwardIshaq
edwardIshaq / kubectl.md
Last active August 22, 2023 16:08
Kubectl gotcha

Issue switching context:

Problem:

you want to set a context but you get the error: error: open /etc/kube/config.lock: permission denied

Solution

kubernetes/kubernetes#67676 (comment)

$ kubectl config get-contexts
$ kubectl config use-context "yourContext"
//Opentracing setup
var jaegerCloser io.Closer
var zErr error
var closeJaegerIfNeeded = func() {
if jaegerCloser != nil {
if err := jaegerCloser.Close(); err != nil {
logging.Error("Failed to close tracing with error: %s", err.Error())
}
jaegerCloser = nil
}
@edwardIshaq
edwardIshaq / repeat.go
Last active April 21, 2019 11:53
trying to figure out how to use channels properly
package main
import (
"fmt"
"time"
)
func repeat(done <-chan interface{}, value interface{}) <-chan interface{} {
output := make(chan interface{})
go func() {
@edwardIshaq
edwardIshaq / SnappyError.go
Last active April 8, 2019 17:58
Wrapping around Snappy error
// SnappyJSON type implements json.Marshaler and represents a snappy compressed []byte
type SnappyJSON []byte
// SnappyError wrapper around the error returned from snappy
type SnappyError struct {
json SnappyJSON
err error
}
func (s *SnappyError) Error() string {
//
// Rac4VC.swift
// Pop
//
// Created by Edward Ishaq on 3/25/16.
// Copyright © 2016 Zuno. All rights reserved.
//
import UIKit
import Result
@edwardIshaq
edwardIshaq / DataSource.swift
Last active December 15, 2015 22:27
Generic protocols to map out the properties of DataSource
public protocol Generative {
typealias GeneratedType
var elements: [GeneratedType] { get }
}
public extension Generative {
func count() -> Int {
return elements.count
}
@edwardIshaq
edwardIshaq / SwiftArrayMapFilterSelf.swift
Last active December 2, 2015 20:02
Swift Array Extension to Map & Filter on Element instance functions
extension Array {
func mapSelf<T>(f: Element -> () -> T) -> [T] {
return self.map{ f($0)() }
}
func filterSelf(includedElem: Element -> () -> Bool) -> [Element] {
return self.filter{ includedElem($0)() }
}
}
extension Realm {
public class func saveClosure(dbClosure: (Realm)->()) {
do {
let rlm = try Realm()
rlm.write { () -> Void in
dbClosure(rlm)
}
}
@edwardIshaq
edwardIshaq / gist:a667a51ba8a95962dd30
Created May 1, 2015 19:47
Random Title generator
// Playground - noun: a place where people can play
import UIKit
var str = "Generate random events titles"
let hosts = ["Eddie", "Paul", "Elyse", "MD", "Jon"]
let events = ["Wedding", "Engagement","Birthday"]
let magnitudes = ["Party", "Bash", "Jam"]