Skip to content

Instantly share code, notes, and snippets.

@carlosefonseca
carlosefonseca / TDCards.js
Last active November 8, 2021 12:26
iOS Home Screen Widget for Scriptable (https://scriptable.app) displaying the amount on a Prize Card and a Dá Card.
// 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
carlosefonseca / StatsHunters.com animation.js
Created November 22, 2020 20:33
Paste this into the dev console in statshunters.com map view and see an animation of your activities.
var setDate = new Date("2019-01-01");
var today = new Date();
var dateDiv = document.getElementById("date")
if (dateDiv === null) {
dateDiv = document.createElement("div")
dateDiv.id = "date"
dateDiv.style = "float: left; margin-left: 30px; margin-top: 15px;"
$("#total").parent().append(dateDiv)
}
// Follow this to install the travis cli: https://github.com/travis-ci/travis.rb#installation
// 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
carlosefonseca / GatewayAndManager.swift
Last active September 17, 2020 22:02
Swift Spy with methods described as enums
import Foundation
public struct Something: Equatable {
var id: String?
var data: String
public init(id: String? = nil, data: String) {
self.id = id
self.data = data
}
@carlosefonseca
carlosefonseca / sim_set_pt_booted.sh
Last active September 7, 2020 12:03
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/")
do
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/com.apple.Preferences.plist
echo " Files patched. Restarting device… "
xcrun simctl shutdown $d
@carlosefonseca
carlosefonseca / gist:a258668c75ae3485def1376e7049592d
Created February 24, 2020 15:14
Quick and dirty Postman Visualizer for a tabled data
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 (https://keybase.io/carlosefonseca) on keybase.
  • I have a public key ASDHkAU3TdmjHLMVB__Gh8YJ_T6Jb-j1bwobXg8exgIukAo

To claim this, I am signing this object:

@carlosefonseca
carlosefonseca / HSVColor.kt
Created July 17, 2018 13:18
Easy way to manipulate an Android ColorInt as HSV and return the result as a ColorInt
import android.graphics.Color
import android.support.annotation.ColorInt
import android.support.v4.graphics.ColorUtils
/**
* Convert the ARGB color to its HSV components.
*/
class HSVColor(@ColorInt color: Int) {
val hsv = FloatArray(3).apply { Color.colorToHSV(color, this) }
//
// 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
carlosefonseca / ArraysInsideDictionaries.swift
Created June 13, 2014 16:37
Demonstration of a difference in Swift's Arrays when compared to NS[Mutable]Arrays
// 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"]]