Skip to content

Instantly share code, notes, and snippets.

View willitscale's full-sized avatar

James willitscale

  • Chester, UK
View GitHub Profile
@willitscale
willitscale / CUrl Request
Last active May 20, 2016 23:31
Sample PATCH with Map
curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"datas":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":{"MAPS":"Smith"}},
{"firstName":"Peter", "beans":213}
]}' "https://localhost/rest/test-patch/1"
@willitscale
willitscale / hooker_bot_4000.c
Last active June 28, 2016 02:06
Example module source code for creating an PHP extension with hookable interface
zend_class_entry *hooker_bot_4000;
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO()
const zend_function_entry hb4_functions[] = {
PHP_ABSTRACT_ME(HookerBot4000, hookerBot4000, arginfo_void)
PHP_FE_END
};
pragma solidity ^0.4.0;
contract Array {
uint[] arr;
function setup() internal {
arr.push(1);
arr.push(3);
arr.push(2);
pragma solidity ^0.4.0;
contract DataConversions {
uint[] _storage1;
function store() public {
_storage1.push(1);
_storage1.push(2);
_storage1.push(3);
@willitscale
willitscale / mockup.md
Last active October 22, 2017 01:11
Next article

UnimplementedFeatureError: Nested arrays not implemented?

Brief

The concept of a nested array in Solidity doesn't always relate to a primitive definition such as uint[][] or byte[][]. It encapsulates single dimensional arrays which also contain data types in which they themselves use arrays to store internal values such as Bytes and Strings. When I refer to primitives in Solidity what I mean uint, int, bool, byte which are in essence different types of integers with different sizes. string, bytes, address are just a few examples of data types which contain arrays and therefore a single array is in essence a nested array like string[] or bytes[].

Contents

pragma solidity ^0.4.0;
contract Contract1 {
function call1() public pure returns(bool) {
return true;
}
}
contract Contract2 {
function call2() public pure returns(string) {
@willitscale
willitscale / CustomGenesis.json
Last active December 10, 2017 07:56
Custom Test Network for Ethereum
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {
@willitscale
willitscale / MapExample.sol
Created December 11, 2017 03:04
Example implementation of solidity mapping
pragma solidity ^0.4.0;
import "github.com/willitscale/solidity-util/lib/Strings.sol";
contract MapExample {
using Strings for string;
// This would be the same as mapping(string => uint)
string[] mapKeys;
@willitscale
willitscale / __invoke.php
Created May 11, 2018 15:27
PHP under the hood
<?php
class MyClass {
function __invoke()
{
echo 'invoked as a function', PHP_EOL;
}
}
$object = new MyClass;
@willitscale
willitscale / EasyToTest.php
Created June 15, 2018 15:10
Writing code to be tested
<?php
namespace App\Components\Example;
class EasyToTest extends Sample
{
public function __construct(
NestedObjectA $nestedObjectA,
NestedObjectB $nestedObjectB
) {