Skip to content

Instantly share code, notes, and snippets.

View sarbogast's full-sized avatar

Sebastien Arbogast sarbogast

View GitHub Profile
@sarbogast
sarbogast / InformationSecurityForNomads.md
Last active July 28, 2023 13:07
How do you protect your gear and data (aka your livelihood) when you're travelling the world?
@gotelgest
gotelgest / SearchPushRow.swift
Last active February 24, 2024 14:35
SearchPushRow for Eureka 4.0.1 (Swift 4)
import Eureka
open class _SearchSelectorViewController<Row: SelectableRowType, OptionsRow: OptionsProviderRow>: SelectorViewController<OptionsRow>, UISearchResultsUpdating where Row.Cell.Value: SearchItem {
let searchController = UISearchController(searchResultsController: nil)
var originalOptions = [ListCheckRow<Row.Cell.Value>]()
var currentOptions = [ListCheckRow<Row.Cell.Value>]()
open override func viewDidLoad() {
@raypendergraph
raypendergraph / CLLocationCoordinate2D+BoundingBox.swift
Last active November 15, 2019 05:47
A CLLocationCoordinate2D extension for calculating bounding boxes.
import CoreLocation
extension CLLocationCoordinate2D {
/**
Calculates a bbox around this CLLocationCoordinat2D by describing a distance that is roughly analagous to
the radius of a circle with a center at this coordinate and the radius is the distance and inscribes the circle
to the bbox created.
This tangential point method of calculating the box is described in Handbook of Mathematics By I.N. Bronshtein,
K.A. Semendyayev, Gerhard Musiol, Heiner Mühlig
@xavierlepretre
xavierlepretre / getEventsPromise.js
Last active September 7, 2017 16:42
Get a Promise on events fired
getEventsPromise= function (myFilter, count, timeOut) {
timeOut = timeOut ? timeOut : 30000;
var promise = new Promise(function (resolve, reject) {
count = (typeof count !== "undefined") ? count : 1;
var results = [];
var toClear = setTimeout(function () {
reject("Timed out");
}, timeOut);
myFilter.watch(function (error, result) {
if (error) {
@xavierlepretre
xavierlepretre / expected_exception_testRPC_and_geth.js
Last active November 28, 2019 17:57
When TestRPC and Geth throw, they behave in a different manner. This Gist is an example on how to cover such a situation.
"use strict";
/**
* @param {!Function.<!Promise>} action.
* @param {!Number | !string | !BigNumber} gasToUse.
* @returns {!Promise} which throws unless it hit a valid error.
*/
module.exports = function expectedExceptionPromise(action, gasToUse) {
return new Promise(function (resolve, reject) {
try {
@xavierlepretre
xavierlepretre / getTransactionReceiptMined.js
Last active February 5, 2023 03:26
Get the Promise of an Ethereum transaction receipt when it is finally mined
const Promise = require("bluebird");
const sequentialPromise = require("./sequentialPromise.js");
/**
* @param {!string | !Array.<!string>} txHash, a transaction hash or an array of transaction hashes.
* @param {Number} interval, in seconds.
* @returns {!Promise.<!object> | !Promise.<!Array.<!object>>} the receipt or an array of receipts.
*/
module.exports = function getTransactionReceiptMined(txHash, interval) {
const self = this;
@schickling
schickling / UIImageFixedOrientationExtension.swift
Last active February 4, 2024 15:00
Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.Up {
return self
}
var transform: CGAffineTransform = CGAffineTransformIdentity
@niksumeiko
niksumeiko / git.migrate
Last active July 19, 2024 21:32
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.