Skip to content

Instantly share code, notes, and snippets.

@carlosefonseca
carlosefonseca / TDCards.js
Last active Nov 8, 2021
iOS Home Screen Widget for Scriptable (https://scriptable.app) 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
carlosefonseca / StatsHunters.com animation.js
Created Nov 22, 2020
Paste this into the dev console in statshunters.com map view and see an animation of your activities.
View StatsHunters.com 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")
dateDiv.id = "date"
dateDiv.style = "float: left; margin-left: 30px; margin-top: 15px;"
$("#total").parent().append(dateDiv)
}
View TravisWidget.js
// 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 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) {
self.id = id
self.data = data
}
@carlosefonseca
carlosefonseca / sim_set_pt_booted.sh
Last active Sep 7, 2020
Takes booted iOS simulators and changes their current keyboard to PT_PT.
View sim_set_pt_booted.sh
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 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
View keybase.md

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 Jul 17, 2018
Easy way to manipulate an Android ColorInt as HSV and return the result as a ColorInt
View HSVColor.kt
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) }
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
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"]]