Skip to content

Instantly share code, notes, and snippets.

View sebas7dk's full-sized avatar

Sebastian de Kok sebas7dk

View GitHub Profile
@john-doherty
john-doherty / cordova-file-storage.js
Last active August 2, 2023 10:32
An easy way to read/write files in Cordova
var fileStorage = {
/**
* Saves a file on the device
* @param {string} name - filename (can include sub folders)
* @param {string} data - file contents
* @param {boolean} useSandbox - uses protected sandbox if true, otherwise external (default false)
* @returns {Promise} executes .then with saved file path as first param
*/
write: function (name, data, useSandbox) {
@lukicdarkoo
lukicdarkoo / configure.sh
Last active June 6, 2024 16:05
Raspberry Pi: AP + client mode
#!/bin/sh
# The script configures simultaneous AP and Managed Mode Wifi on Raspberry Pi Zero W (should also work on Raspberry Pi 3)
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/6b92d182d37d0a10400060d8344f86e4/raw | sh -s WifiSSID WifiPass APSSID APPass
# Licence: GPLv3
# Author: Darko Lukic <lukicdarkoo@gmail.com>
# Special thanks to: https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
MAC_ADDRESS="$(cat /sys/class/net/wlan0/address)"
CLIENT_SSID="${1}"
CLIENT_PASSPHRASE="${2}"
@agtorre
agtorre / config.go
Last active December 26, 2019 12:13
Store OAuth2 Token Using Redis
type Config struct {
*oauth2.Config
Redis MyRedisInterface
}
func (c *Config) StoreToken(token *oauth2.Token) error {
//store the token in redis here using c.Redis
}
func (c *Config) Exchange(ctx context.Context, code string) (*oauth2.Token, error) {
@afgomez
afgomez / validate_spanish_id.js
Last active May 5, 2024 12:31
Spanish DNI, CIF, NIE validator
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );