Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Stamatiou stammy

View GitHub Profile
@mecid
mecid / PagerView.swift
Last active Jan 19, 2021
PagerView in SwiftUI
View PagerView.swift
//
// PagerView.swift
//
// Created by Majid Jabrayilov on 12/5/19.
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
struct PagerView<Content: View>: View {
let pageCount: Int
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020
Custom Segmented Picker / Segmented Control in SwiftUI
View iOSCustomSegmentedControlSwiftUI.swift
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@LeeKahSeng
LeeKahSeng / Decode-Dynamic-Keys-JSON-Final.swift
Last active Dec 27, 2020
Decode and Flatten JSON with Dynamic Keys Using Swift Decodable (https://swiftsenpai.com/swift/decode-dynamic-keys-json/)
View Decode-Dynamic-Keys-JSON-Final.swift
let jsonString = """
{
"S001": {
"firstName": "Tony",
"lastName": "Stark"
},
"S002": {
"firstName": "Peter",
"lastName": "Parker"
},
@stinger
stinger / CombineFetcherAndDecoder.swift
Last active Dec 15, 2020
Combine - fetching and decoding JSON data
View CombineFetcherAndDecoder.swift
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String), parserError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created Feb 3, 2011
Ruby 1.9 features, tips & tricks you may not know about...
View ruby-1.9-tips.rb
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@addyosmani
addyosmani / pubsub.md
Created Oct 28, 2011
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)
View pubsub.md

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

View Wallet.swift
import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
Color(UIColor.systemRed),
View redis-server-for-init.d-startup
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@uqmessias
uqmessias / devices-model-resolution.md
Last active Aug 11, 2020
Some Android devices dimensions
View devices-model-resolution.md
@harperreed
harperreed / create_custom_origin.py
Created Jan 14, 2011
creates a custom origin for cloudfront. EASY CDN!
View create_custom_origin.py
import boto
# requires cf_customorigin branch
# https://github.com/boto/boto/tree/cf_customorigin
origin_domain = 'www.example.org'
cdn_cname = ['media.example.org']
caller_reference = 'exmaple Distribution'
c = boto.connect_cloudfront()
d = c.create_custom_distribution(
You can’t perform that action at this time.