Skip to content

Instantly share code, notes, and snippets.

View jenshandersson's full-sized avatar

Jens Andersson jenshandersson

  • London
View GitHub Profile
@jenshandersson
jenshandersson / .deps...npm...@openzeppelin...contracts...utils...Strings.sol
Created February 23, 2023 10:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=true&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
@jenshandersson
jenshandersson / update-diff.ts
Created February 28, 2020 10:50
React componentDidUpdate diff
console.log('Rrow update diff:');
console.log('++++++++++++++++++++');
console.log('++++++++++++++++++++');
const now = Object.entries(this.props);
const added = now.filter(([key, val]) => {
if (prevProps[key] === undefined && val !== undefined) return true;
if (!isEqual(prevProps[key], val)) {
console.log(`${key}
- ${JSON.stringify(prevProps[key])}
@jenshandersson
jenshandersson / cloudSettings
Created March 7, 2018 14:03
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-03-07T14:02:41.170Z","extensionVersion":"v2.9.0"}
@jenshandersson
jenshandersson / JHAVerticalTextView.h
Last active December 29, 2015 01:30
Simple UITextView subclass for vertically aligning text in middle.
//
// JHAVerticalTextView.h
// Quotes background
//
// Created by Jens Andersson on 23/02/14.
// Copyright (c) 2014 Jens Andersson. All rights reserved.
//
#import <UIKit/UIKit.h>
@jenshandersson
jenshandersson / JAConcat.m
Created January 5, 2014 20:24
String concatenation in Objective-C, using one line of code. Takes a list of NSObject and concatenates their description.
#define $(...) ((NSString *)[[NSArray arrayWithObjects:__VA_ARGS__, nil] componentsJoinedByString:@""])
/*
* Example
*/
NSString *string = $(@"Hello", @" ", @"World!", @"\n", @"1 + 2 = ", @(1+2));
@jenshandersson
jenshandersson / gist:5721994
Last active December 18, 2015 03:58
A simple way to profile execution time of a code snippet.
static CFAbsoluteTime JAProfilingBlock (void (^block)(void)) {
CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
block ();
CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
return end - start;
}
#example usage