Skip to content

Instantly share code, notes, and snippets.

View Widcket's full-sized avatar

Rita Zerrizuela Widcket

View GitHub Profile
@Widcket
Widcket / AtomicInteger.swift
Created October 6, 2022 12:12 — forked from nestserau/AtomicInteger.swift
Atomic way to operate on integers in Swift. Inspired by Java's AtomicInteger
/// This is free and unencumbered software released into the public domain.
///
/// Anyone is free to copy, modify, publish, use, compile, sell, or
/// distribute this software, either in source code form or as a compiled
/// binary, for any purpose, commercial or non-commercial, and by any
/// means.
///
/// In jurisdictions that recognize copyright laws, the author or authors
/// of this software dedicate any and all copyright interest in the
/// software to the public domain. We make this dedication for the benefit
@Widcket
Widcket / subscribe-to-remote-config-topic.swift
Created January 16, 2019 19:59
Subscribe to Remote Config Topic
Messaging.messaging().subscribe(toTopic: "REMOTE_CONFIG") { error in
if let error = error {
debugPrint("Could not subscribe to Remote Config topic", error)
}
}
@Widcket
Widcket / invalidate-remote-config-cache.swift
Created January 16, 2019 19:57
Invalidate Remote Config Cache
var expirationDuration: TimeInterval = 43200 // 12hs of cache by default
if UserDefaults.standard.bool(forKey: "CONFIG_STATE") {
UserDefaults.standard.set(false, forKey: "CONFIG_STATE")
UserDefaults.standard.synchronize()
expirationDuration = 0
}
RemoteConfig.fetch(withExpirationDuration: expirationDuration) { [weak self] status, error in
@Widcket
Widcket / handle-remote-config-push-notifications.swift
Created January 16, 2019 19:55
Handle Remote Config push notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (_: UIBackgroundFetchResult) -> Void) {
if userInfo["CONFIG_STATE"] != nil {
UserDefaults.standard.set(true, forKey: "CONFIG_STATE")
UserDefaults.standard.synchronize()
}
completionHandler(UIBackgroundFetchResult.newData)
}
@Widcket
Widcket / remote-config-cloud-function.js
Created January 16, 2019 19:48
Remote Config Cloud Function
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.pushConfig = functions.remoteConfig.onUpdate(metadata => {
const payload = {
data: {
CONFIG_STATE: 'STALE'
}
@Widcket
Widcket / pgessays.py
Last active August 29, 2015 14:22 — forked from goc9000/pgessays.py
# -*- coding: utf-8 -*-
"""
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html
Original script: Ola Sitarska <[email protected]>
Improved version: Cristian Dinu <[email protected]>
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/
The checking facility requires epubcheck: http://code.google.com/p/epubcheck/
Embedding the 'Roots of Lisp' paper requires the programs ps2pdf and pdftoppm