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 / aruba-ftp-upload.sh
Created September 7, 2016 11:49
ARUBA FTP FILE UPLOAD USING CURL
#
#ARUBA FTP FILE UPLOAD USING CURL
#
pasky$ curl -v -T uploadme.dat ftp://ftp.site.com/www.site.com/_backup/ --user username:p4ssw0rd
@elpsk
elpsk / Unity2DRotateZ.cs
Created January 5, 2017 11:33
Rotate object on Z axis in 2D environment, with mouse.
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour
{
public GameObject objectToRotate;
public GameObject rotationOverlay; // optional
void OnMouseDrag ()
{
@elpsk
elpsk / timeElapsed.cs
Created March 6, 2017 09:54
c# unity - time elapsed difference
void LoadHeavyData()
{
// start timer
float startTime = Time.realtimeSinceStartup;
// sample heavy code...
[...]
// stop timer
float endTime = Time.realtimeSinceStartup;
@elpsk
elpsk / xcodeRun.scpt
Created March 20, 2017 12:44
Open and Run project on XCode
tell application id "com.apple.dt.Xcode"
activate
end tell
tell application "System Events"
tell process "Xcode"
click menu item "Run" of menu "Product" of menu bar item "Product" of menu bar 1
end tell
@elpsk
elpsk / arduino-speedometer.ino
Last active May 22, 2017 18:26
arduino snippet to make a gps/ble speedometer controlled by ios app
/*
MTB Speedometer 1.0
- GPS module
- BLE 4 module
- 7 Segment display
- DHT sensor for temperature and humidity
(c) 2017 Alberto Pasca
*/
#include <string.h>
@elpsk
elpsk / SpeechManager.swift
Last active March 6, 2020 15:18
Recognize spoken text using Siri
import UIKit
import Speech
protocol SpeechManagerProtocol {
func didTextRecognized(text: String)
}
class SpeechManager: NSObject {
private var speechRecognizer : SFSpeechRecognizer?
@elpsk
elpsk / BatteryStatus.swift
Created September 28, 2018 10:17
Swift - Battery status
import UIKit
class BatteryVC: UIViewController {
var timer: Timer?
override func viewDidLoad() {
super.viewDidLoad()
UIDevice.current.isBatteryMonitoringEnabled = true
@elpsk
elpsk / Headphones
Created September 28, 2018 10:19
Swift - detect plugged headphones
import AVFoundation
import MediaPlayer
// [...]
private func headphones() {
let currentRoute = AVAudioSession.sharedInstance().currentRoute
if currentRoute.outputs.count != 0 {
for description in currentRoute.outputs {
@elpsk
elpsk / screenshot
Created September 28, 2018 10:19
Swift - detect a screenshot
func screenshotDetector() {
NotificationCenter.default.addObserver(forName: .UIApplicationUserDidTakeScreenshot, object: nil, queue: OperationQueue.main) { notification in
print("Screenshot taken!")
}
}
@elpsk
elpsk / Brightness
Created September 28, 2018 10:20
Swift - Brightness
import UIKit
class BrightnessVC: UIViewController {
var timer: Timer?
override func viewDidLoad() {
super.viewDidLoad()
timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { (t) in