Skip to content

Instantly share code, notes, and snippets.


Nico Prananta nicnocquee

View GitHub Profile
View advanced-swiftui-animations.swift
// The SwiftUI Lab: Advanced SwiftUI Animations
// (Animating Paths)
// (GeometryEffect)
// (AnimatableModifier)
import SwiftUI
struct ContentView: View {
nicnocquee / node-tcp.js
Created April 12, 2022 03:09
simple tcp server with node.js
View node-tcp.js
const Net = require("net");
// The port on which the server is listening.
const port = 8080;
// Use net.createServer() in your code. This is just for illustration purpose.
// Create a new TCP server.
const server = new Net.Server();
// The server listens to a socket for a client to make a connection request.
// Think of a socket as an end point.
server.listen(port, function () {
View swiftid-usersme.swift
struct MeResponseData: Decodable {
let id: Int
let username: String
let email: String
func me(authToken: String? = nil) async throws -> MeResponseData {
let meData: MeResponseData = try await URLSession.shared.get(pathname: "/users/me", authToken: authToken)
return meData
View swiftid-login.swift
struct LoginRequestData: Encodable {
let identifier: String
let password: String
struct LoginResponseData: Decodable {
let jwt: String
func login(_ loginRequest: LoginRequestData) async throws -> String {
// is an extension which you can find here
let loginData: LoginResponseData = try await "/auth/local", data: loginRequest)
View swiftid-register.swift
struct RegisterRequestData: Encodable {
let username: String
let email: String
let password: String
struct LoginResponseData: Decodable {
let jwt: String
nicnocquee / EnumListView.swift
Created March 17, 2021 13:10
Swift Enumerations to SwiftUI list view
View EnumListView.swift
struct EnumListView<Enum: RawRepresentable &
CaseIterable &
CustomStringConvertible> : View where
Enum.RawValue: Hashable,
Enum.AllCases: RandomAccessCollection {
var title: String = ""
@Binding var selectedItem: Enum?
var body: some View {
nicnocquee / pokemon-fetch-combine.swift
Created February 5, 2021 17:41
sample of fetching list of pokemon using swift combine
View pokemon-fetch-combine.swift
import UIKit
import Combine
struct PokemonResponse: Codable{
let results: [Pokemon]
struct Pokemon: Codable{
let name: String
nicnocquee / next.config.js
Created May 5, 2020 15:41
Small function to expose environment variables to nextjs app
View next.config.js
const getEnvWithPrefixes = (prefixes = ['REACT_APP_', 'FIREBASE_']) => {
return Object.keys(process.env).reduce((prev, curr) => {
if (prefixes.some(p => curr.startsWith(p))) {
return {
[curr]: process.env[curr],
nicnocquee / uicollectionview-playground.playyground
Created October 19, 2018 06:37
Testing UICollectionView in Swift Playground iPad
View uicollectionview-playground.playyground
import UIKit
import PlaygroundSupport
let cellSize = CGSize(width: 100, height: 100)
class Cell: UICollectionViewCell {
var imageView: UIImageView?
var identifier: String?
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
nicnocquee /
Last active April 24, 2017 06:51
my shell alias
# Color LS
alias ls="command ls ${colorflag}"
alias l="ls -lF ${colorflag}" # all files, in long format
alias la="ls -laF ${colorflag}" # all files inc dotfiles, in long format
alias lsd='ls -lF ${colorflag} | grep "^d"' # only directories
alias lsa="command ls -la | lolcat"
# Quicker navigation
alias ..="cd .."