Skip to content

Instantly share code, notes, and snippets.

View elpsk's full-sized avatar
:octocat:
I may be slow to respond.

alberto elpsk

:octocat:
I may be slow to respond.
View GitHub Profile
@elpsk
elpsk / CryptoManager
Created June 26, 2023 08:26
CryptoManager - encrypt / decrypt files for macOS using AES
import Cocoa
import CommonCrypto
class CryptoManager {
static var defaultCryptoKey: String? {
set {
if let key = newValue {
StorageManager.save(cryptoKey: key)
@elpsk
elpsk / PlayerSession.swift
Created May 7, 2023 15:14 — forked from AFathi/PlayerSession.swift
A Swift class designed to simplify the process of connecting to other players in an AR game or app using WiFi and Bluetooth signals.
//
// PlayerSession.swift
//
// Created by Ahmed Bekhit on 8/17/18.
// Copyright © 2018 Ahmed Fathi Bekhit. All rights reserved.
//
import MultipeerConnectivity
/// An enum that denotes the player's session status
@elpsk
elpsk / HOWTODMG.md
Created July 31, 2022 14:53 — forked from jadeatucker/HOWTODMG.md
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

##Creating the DMG file #Disk Utility

struct AllowedUTI {
static var utis: [UTType] {
[
.item,
.content,
.compositeContent,
.diskImage,
.data,
.directory,
.resolvable,
@elpsk
elpsk / ArduinoBluetoothHelper.swift
Created April 14, 2021 09:32
Swift bluetooth communication helper for the SH-HC-08 board
//
// BluetoothHelper.swift
//
// Created by Alberto Pasca on 03/05/17.
// Copyright © 2017 albertopasca.it. All rights reserved.
//
import UIKit
import CoreBluetooth
@elpsk
elpsk / git-update-all.sh
Created March 31, 2021 08:15
Update all local git projects and clean unused remotes
#!/bin/bash
# Update all git directories below current directory or specified directory
# Skips directories that contain a file called .ignore
RED="\033[1;31m"
HIGHLIGHT="\033[1;32m"
NORMAL='\033[0m'
function update {
@elpsk
elpsk / xcode_code_lines_counter_script.sh
Created September 4, 2020 14:45
Count the number of code in Xcode iOS (objectivec/swift) project excluding the Cocoa Pods
#!/bin/sh
### ---------------
### Get the sum of the total line of code for that project folder
### ---------------
find . -path ./Pods -prune -o \( -name "*.h" -o -name "*.m" -o -name "*.swift" \) -print0 ! -name "/Pods" | \
xargs -0 wc -l |\
sort -t '\0' -n -r |\
grep " total" |\
awk '{print $1}'
//
// BluetoothManager.swift
//
import CoreBluetooth
protocol BluetoothManagerDelegate: AnyObject {
func didErrorReceived(manager: NSObject)
func didSensorReceived(data: Data, rssi: Int)
}
//
// Twitter SentimentAnalysis
//
import UIKit
import SwifteriOS
import CoreML
class ViewController: UIViewController {
@elpsk
elpsk / CoreML Twitter sentiment analysis
Last active March 5, 2020 10:26
A sample playground to create a trained model for twitter sentiment analysis
import Cocoa
import CreateML
// tha path of your csv file
let baseFolder = "<#path#>"
let data = try! MLDataTable(contentsOf: URL(fileURLWithPath: "\(baseFolder)/twitter-sanders-apple3.csv"))
let (trainingData, testingData) = data.randomSplit(by: 0.8, seed: 5)
// classifier