Skip to content

Instantly share code, notes, and snippets.

@nathanfjohnson
nathanfjohnson / String+HTML.swift
Last active November 23, 2021 15:09 — forked from mwaterfall/StringExtensionHTML.swift
Decoding HTML Entities in Swift 4
// Swift 4
// Check out the history for contributions and acknowledgements.
extension String {
/// Returns a new string made by replacing all HTML character entity references with the corresponding character.
///
/// - Returns: decoded string
func decodingHTMLEntities() -> String {
var result = String()
var position = startIndex
@lucifr
lucifr / init.lua
Last active June 4, 2022 19:21
My Hammerspoon config file
-- -------------------------------
-- Watcher for changes of init.lua
-- -------------------------------
function reloadConfig(files)
doReload = false
for _,file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
@kevin-smets
kevin-smets / macos-virtualbox-ubuntu-server-docker.md
Last active February 3, 2023 02:22
macOS VirtualBox headless Ubuntu Server and Docker setup

Get started

Install virtualbox and the extension pack:

brew install --cask docker virtualbox virtualbox-extension-pack

Download the ubuntu server image and create a VBox for it, the rest of the readme assumes it is named "Ubuntu Server".

Enable SSH

@PasanBhanu
PasanBhanu / CheckNetwork.java
Last active July 25, 2023 13:28
Check Internet Connection in Android (API Level 29) Using Network Callback
/*
You need to call the below method once. It register the callback and fire it when there is a change in network state.
Here I used a Global Static Variable, So I can use it to access the network state in anyware of the application.
*/
// You need to pass the context when creating the class
public CheckNetwork(Context context) {
this.context = context;
}
@V8tr
V8tr / AutoLayoutDSL.swift
Last active October 31, 2023 17:42
Auto Layout DSL
import UIKit
/// Represents a single `NSLayoutConstraint`
enum LayoutAnchor {
case constant(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
constant: CGFloat)
case relative(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
@joshdholtz
joshdholtz / .env
Last active December 26, 2023 13:31
Using Dotenv and environment variables with fastlane
STUFF = this is some stuff
@Farbklex
Farbklex / ConnectivityChecker.kt
Created February 18, 2020 13:27
Android: Check if the device has internet access on devices with API level >= 23.
package me.a_hoffmann.gists
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
/**
* Checks if the device has an internet connection.
* NOTE: Works only on android API level 23 and above!
*/
@surajsau
surajsau / ParallaxScreen.kt
Last active April 16, 2024 13:53
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()
@przbadu
przbadu / react_on_docker2.md
Created October 29, 2020 04:31
Docker configuration to run react app

Setup docker to run React app

After setting up docker to generate React app without installing node js in https://gist.github.com/przbadu/4a62a5fc5f117cda1ed5dc5409bd4ac1 It was confusing to some of the devs, how to run react app, so I am creating this as second step to the configuration.

Generate required files in your react project

cd my-react-app
touch Dockerfile Dockerfile.dev docker-compose.yml .dockerignore
@gdurastanti
gdurastanti / parallels-reset.sh
Created August 9, 2017 14:00
Reset Parallels' trial
#!/bin/sh
# Reset Parallels Desktop's trial and generate a casual email address to register a new user
rm /private/var/root/Library/Preferences/com.parallels.desktop.plist /Library/Preferences/Parallels/licenses.xml
jot -w pdu%d@gmail.com -r 1