Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Check if the correct number of arguments are passed
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <git-url> <path-to-directory> <target-directory>"
exit 1
fi
# Variables from arguments
GIT_URL=$1
@nicnocquee
nicnocquee / git-contributions.sh
Created December 19, 2023 14:11
Script to get git contribution stats
#!/bin/zsh
# Check if a repository path was provided
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 /path/to/git/repo"
exit 1
fi
# Assign the first argument to the variable 'repo_path'
repo_path="$1"
//------------------------------------------------------------------------
// The SwiftUI Lab: Advanced SwiftUI Animations
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths)
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect)
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier)
//------------------------------------------------------------------------
import SwiftUI
struct ContentView: View {
@nicnocquee
nicnocquee / node-tcp.js
Created April 12, 2022 03:09
simple tcp server with node.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 () {
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
}
struct LoginRequestData: Encodable {
let identifier: String
let password: String
}
struct LoginResponseData: Decodable {
let jwt: String
}
func login(_ loginRequest: LoginRequestData) async throws -> String {
// URLSession.shared.post is an extension which you can find here https://gist.github.com/nicnocquee/f0a0dbe345f0a18a378d9022c7d11e9c#gistcomment-3964831
let loginData: LoginResponseData = try await URLSession.shared.post(pathname: "/auth/local", data: loginRequest)
struct RegisterRequestData: Encodable {
let username: String
let email: String
let password: String
}
struct LoginResponseData: Decodable {
let jwt: String
}
@nicnocquee
nicnocquee / EnumListView.swift
Created March 17, 2021 13:10
Swift Enumerations to SwiftUI list view
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
nicnocquee / pokemon-fetch-combine.swift
Created February 5, 2021 17:41
sample of fetching list of pokemon using swift combine
import UIKit
import Combine
struct PokemonResponse: Codable{
let results: [Pokemon]
}
struct Pokemon: Codable{
let name: String