Skip to content

Instantly share code, notes, and snippets.

View niftycode's full-sized avatar
🏠
Working from home

Bodo Schönfeld niftycode

🏠
Working from home
View GitHub Profile
@niftycode
niftycode / ChangeNavigationBarStyle
Last active August 29, 2015 14:19
HowTo change barStyle and tintColor of the NavigationBar in Swift
override func viewDidAppear(animated: Bool) {
var navBar = self.navigationController?.navigationBar
navBar?.barStyle = UIBarStyle.Black
navBar?.tintColor = UIColor.yellowColor
}

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@niftycode
niftycode / MyButton.swift
Last active November 18, 2015 17:16
UIButton customization in Swift
import UIKit
class MyButton: UIButton {
override var highlighted: Bool {
didSet {
if (highlighted) {
self.backgroundColor = UIColor.redColor()
} else {
self.backgroundColor = UIColor.clearColor()
@niftycode
niftycode / CALayerPlaygroundExample.swift
Last active January 18, 2023 00:03
How to create a basic CALayer object in a playground (Swift 4)
//: # Introduction to CALayer
//: (Xcode 9 and Swift 4)
import UIKit
import PlaygroundSupport
//: From Apples's Support Documentation:
//:
//: > The CALayer class manages image-based content and allows you to perform animations on that content. Layers are often used to provide the backing store for views but can also be used without a view to display content.
//:
@niftycode
niftycode / CALayerImageExample.swift
Last active January 27, 2018 16:19
This playground project shows how to modify an image with CALayer (Swift 4)
//: # CALayer Example 2
import UIKit
import PlaygroundSupport
// view with white background color
var backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
backgroundView.backgroundColor = UIColor.white
PlaygroundPage.current.liveView = backgroundView
@niftycode
niftycode / Substrings.swift
Created March 19, 2016 10:49
Useful String extensions
extension String {
// string length
var len: Int {
return self.characters.count
}
// retrieve a single character
subscript(n: Int) -> Character {
if n < 0 || n > self.len {
@niftycode
niftycode / EpochConverter.cpp
Created August 24, 2016 14:41
Convert the UNIX time to a human readable string
/* EpochConverter */
#include <iostream>
#include <time.h>
using namespace std;
int main(int argc, const char * argv[]) {
int inputTime;
struct tm *timeinfo;
@niftycode
niftycode / elections_bw_1980-2016.py
Last active June 10, 2018 08:37
line graph example using Python3 and Matplotlib
import matplotlib.pyplot as plt
import numpy as np
# results for the greens and the cdu
gruene = np.array([5.3, 8.0, 7.9, 9.5, 12.1, 7.7, 11.7, 24.2, 30.3])
cdu = np.array([53.4, 51.9, 49.0, 39.6, 41.3, 44.8, 44.2, 39.0, 27.0])
fig, ax = plt.subplots()
xlabels = [1980, 1984, 1988, 1992, 1996, 2001, 2006, 2011, 2016]
@niftycode
niftycode / familyStatus.py
Last active December 10, 2016 14:53
Line graph that shows the family status of the citizens of Kiel, Germany
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Line graph of the familiy status of the citizens of Kiel, Germany.
The data is provided by the City of Kiel.
http://kiel.de/rathaus/statistik/open_data/index.php
familyStatus.py
version: 1.3
@niftycode
niftycode / big-o-notation.py
Last active October 12, 2024 07:41
big-o-notation graph with Python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
MIT License
Copyright (c) 2016-2024 Bodo Schönfeld
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,