Skip to content

Instantly share code, notes, and snippets.

View mchirico's full-sized avatar
💭
Kubernetes... API Server Development

Mike Chirico mchirico

💭
Kubernetes... API Server Development
View GitHub Profile
@mchirico
mchirico / bashFor.go
Last active October 29, 2023 04:14
Go (golang) program to execute a bash for loop.
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
)
@mchirico
mchirico / eatblob.c
Last active October 11, 2023 04:34
Eat Blob: Example program that both reads binary data into a SQLite database, and demonstrates writing that data out.
/*
The MIT License (MIT)
Copyright (c) 2013 Mike Chirico mchirico@gmail.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
@mchirico
mchirico / cal.swift
Created September 6, 2014 12:36
Example of creating and removing calendar entries in Swift. Also, shows how to list reminders
/*
You need to import EventKit
import EventKit
*/
@IBAction func buttonCalendar(sender: AnyObject) {
var eventStore : EKEventStore = EKEventStore()
// 'EKEntityTypeReminder' or 'EKEntityTypeEvent'
@mchirico
mchirico / tree.go
Last active June 6, 2023 05:50
Example of putting a slice into a tree in golang
/*
Example of tree
mchirico@gmail.com
http://play.golang.org/p/yGYwb9ACeG
*/
package main
@mchirico
mchirico / twotableviewsInOneView.swift
Last active June 5, 2023 08:47
Creating multiple tableViews in one ViewController...this just starts out as a view controller
//
// ViewController.swift
// Delete
//
// Created by Mike Chirico on 10/21/15.
// Copyright © 2015 Mike Chirico. All rights reserved.
//
import UIKit
@mchirico
mchirico / bridge.go
Created April 7, 2023 15:30
Go Bridge Pattern
package main
import "fmt"
// CollectorInterface defines the interface for the collector abstraction
type CollectorInterface interface {
Collect()
SetResolver(ResolverInterface)
}
@mchirico
mchirico / gzipWriter.go
Created August 3, 2013 19:34
Example of writing a gzip file in go (golang). This appends data to the same file every time it is run. It is important to Flush() the data before closing the file.
/*
This is an example of a golang gzip writer program,
which appends data to a file.
*/
package main
@mchirico
mchirico / mmap.c
Last active February 28, 2023 05:29
An example of mmap where data is modified in the file. This version currently compiles on Mac OSX.
/*
An example of mmap where data is modified in the file. This
version currently compiles on Mac OSX.
References:
Advanced Programming in the UNIXî Environment, Third Edition
By: W. Richard Stevens; Stephen A. Rago
Publisher: Addison-Wesley Professional
@mchirico
mchirico / channelPipe.go
Created February 6, 2016 19:07
Go (Golang) Fan-out example
// Ref: https://blog.golang.org/pipelines
package main
import (
"fmt"
"sync"
)
func gen(done <-chan struct{}, nums ...int) <-chan int {
@mchirico
mchirico / SQLite.java
Created February 10, 2013 21:29
Example using the sqlite-jdbc
package dev.sysadmin;
/*
* https://bitbucket.org/xerial/sqlite-jdbc/overview
*
*
*/
import java.sql.Connection;
import java.sql.DriverManager;