Skip to content

Instantly share code, notes, and snippets.

carlosefonseca / TDCards.js
Last active Nov 8, 2021
iOS Home Screen Widget for Scriptable ( displaying the amount on a Prize Card and a Dá Card.
View TDCards.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: cyan; icon-glyph: wallet;
// Card Number
const prizeCardAmount = (await prizeCard("1234567890123456")).amount
// Username, Password, Date
const daCardAmount = (await daCard("username", "password", "31081980"))
carlosefonseca / animation.js
Created Nov 22, 2020
Paste this into the dev console in map view and see an animation of your activities.
View animation.js
var setDate = new Date("2019-01-01");
var today = new Date();
var dateDiv = document.getElementById("date")
if (dateDiv === null) {
dateDiv = document.createElement("div") = "date" = "float: left; margin-left: 30px; margin-top: 15px;"
View TravisWidget.js
// Follow this to install the travis cli:
// Then generate the API token by running the following commands and place the token in the var
// travis login --pro
// travis token --pro
let travis_token = "insert token"
// set to your GitHub username to appear in bold
let github_user = ""
carlosefonseca / GatewayAndManager.swift
Last active Sep 17, 2020
Swift Spy with methods described as enums
View GatewayAndManager.swift
import Foundation
public struct Something: Equatable {
var id: String?
var data: String
public init(id: String? = nil, data: String) { = id = data
carlosefonseca /
Last active Sep 7, 2020
Takes booted iOS simulators and changes their current keyboard to PT_PT.
sim_set_pt_booted() {
for d in $(xcrun simctl list devices booted | grep Booted | perl -pe "s/.*\(([^ ]+)\) \(Booted\)/\1/")
echo -n $d
/usr/libexec/PlistBuddy -c "Set :AppleKeyboards:2 pt_PT@sw=QWERTY;hw=Automatic" -c "Set :AppleLanguages:1 pt-PT" -c "Set :AppleKeyboards:3 pt_PT@sw=QWERTY;hw=Automatic" ~/Library/Developer/CoreSimulator/Devices/$d/data/Library/Preferences/.GlobalPreferences.plist
# This is reset on restart (last checked on iOS 13.7)
/usr/libexec/PlistBuddy -c "Set :AutomaticMinimizationEnabled false" ~/Library/Developer/CoreSimulator/Devices/$d/data/Library/Preferences/
echo " Files patched. Restarting device… "
xcrun simctl shutdown $d
carlosefonseca / gist:a258668c75ae3485def1376e7049592d
Created Feb 24, 2020
Quick and dirty Postman Visualizer for a tabled data
View gist:a258668c75ae3485def1376e7049592d
const res = pm.response.json();
// The list to show
const list = res["_embedded"].contacts
// Keys to ignore
const ignore = ["account_id", "deleted_at"]
// Implementation

Keybase proof

I hereby claim:

  • I am carlosefonseca on github.
  • I am carlosefonseca ( on keybase.
  • I have a public key ASDHkAU3TdmjHLMVB__Gh8YJ_T6Jb-j1bwobXg8exgIukAo

To claim this, I am signing this object:

carlosefonseca / HSVColor.kt
Created Jul 17, 2018
Easy way to manipulate an Android ColorInt as HSV and return the result as a ColorInt
View HSVColor.kt
* Convert the ARGB color to its HSV components.
class HSVColor(@ColorInt color: Int) {
val hsv = FloatArray(3).apply { Color.colorToHSV(color, this) }
View JKInterpolationMath.swift
// JKInterpolationMath.h
// Created by Carlos Fonseca on 08/11/15.
// Copyright © 2015 Carlos Fonseca. All rights reserved.
import Foundation
func JKLinearInterpolation(t:Float, start:Float, end:Float) -> Float
carlosefonseca / ArraysInsideDictionaries.swift
Created Jun 13, 2014
Demonstration of a difference in Swift's Arrays when compared to NS[Mutable]Arrays
View ArraysInsideDictionaries.swift
// Playground - noun: a place where people can play
import UIKit
var d1 = Dictionary<String, NSMutableArray>()
var d2 = Dictionary<String, String[]>()
d1["A"] = NSMutableArray(object: "A1")
d1 // ["A": ["A1"]]