Skip to content

Instantly share code, notes, and snippets.

View pwwilson's full-sized avatar

Patrick Wilson pwwilson

View GitHub Profile
struct LazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}
@mshafer
mshafer / ContentView.swift
Last active October 11, 2024 13:00
Slide-over card (like in Maps or Stocks) using SwiftUI
import SwiftUI
struct ContentView : View {
var body: some View {
ZStack(alignment: Alignment.top) {
MapView()
SlideOverCard {
VStack {
CoverImage(imageName: "maitlandbay")
Text("Maitland Bay")
$(".new-goods-submit-button").on('click',function(){
console.log('submitting goood');
//get hash of the good
var file_unique_hash = $("#good_file_input").data('uniquehash');
var file_name = "canoe";
var file_description = "a wooden boat";
anonymous
anonymous / ballot.sol
Created August 13, 2017 18:52
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.15+commit.bbb8e64f.js&optimize=true&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
@blakeberg
blakeberg / ParkingPlaces.sol
Created April 28, 2016 20:29
Solidity Contracts
/// @title Contract for Parking Places and Parking Reservations.
/// @author Bjoern Lakeberg
contract ParkingPlaces {
address public controller;
uint public blockCosts;
Place[] public places;
mapping (address => Place) placeOf;
struct Place {
@pdesantis
pdesantis / Fastfile
Created February 11, 2016 22:58
An example Fastfile
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "1.41.0"
default_platform :ios
platform :ios do
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/MoneyWithWings"
@rrag
rrag / README.md
Last active March 19, 2024 16:11
Yet another tutorial and Cheat sheet to Functional programming

There are many tutorials and articles available online which explain functional programming. Examples show small functions, which are composed into others which again get composed. It is hard to imagine how it would all work, then come the analogies and then the math. While the math is necessary to understand it can be difficult to grasp initially. The analogies on the other hand, (at least for me) are not relatable. Some articles assume the reader knows the different terminologies of FP. Over all I felt it is not inviting to learn.

This introduction is for those who have had a tough time understanding those analogies, taken the plunge to functional programming but still have not been able to swim. This is yet another tutorial on functional programming

Terminology

Functions as first class citizens

Functions are first class means they are just like anyone else, or rather they are not special, they behave the same as say primitives or strings or objects.

@wosephjeber
wosephjeber / ngrok-installation.md
Last active May 4, 2025 11:47
Installing ngrok on Mac

Installing ngrok on OSX

For Homebrew v2.6.x and below:

brew cask install ngrok

For Homebrew v2.7.x and above:

def status_code_behavior(r):
"""
Holds a dictionary of all possible HTTP status codes and returns a string value.
:param code: HTTP Response status code
:return: {String}
"""
# Copied from multiple sources...
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Response_codes
# http://httpstatus.es/
@anaimi
anaimi / Serializable.swift
Created July 9, 2014 03:51
Serialize a Swift object to JSON or Dictionary, with selective properties.
/*
Purpose:
Convert (or Serialize) an object to a JSON String or Dictionary.
Usage:
Use 'Serialize.toJSON' on instances of classes that:
- Inherit from NSObject
- Implement 'Serializable' protocol
- Implement the property 'jsonProperties' and return an array of strings with names of all the properties to be serialized