Skip to content

Instantly share code, notes, and snippets.

@kopanitsa
kopanitsa / iota-sample.js
Last active April 5, 2018 08:05
iota-sample.js
const IOTA = require('iota.lib.js');
const iota = new IOTA({ provider: 'https://nodes.testnet.iota.org:443' });
const remoteCurl = require('@iota/curl-remote');
remoteCurl(iota, `https://powbox.testnet.iota.org`, 500);
// cat /dev/urandom | LC_ALL=C tr -dc 'A-Z9' | fold -w 81 | head -n 1
const seed = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
let newaddr = () => {
// Generate contract instance. Pass contract address as 2nd parameter.
Contract contract(&web3, CONTRACT_ADDRESS);
// Set your secret to contract.
// This secret will not send to server (of course!) but use in local to sign.
contract.SetPrivateKey((uint8_t*)PRIVATE_KEY);
// set required data to execute sendTransaction
// nonce can be get with web3.EthGetTransactionCount() API
uint32_t nonceVal = (uint32_t)web3.EthGetTransactionCount((char *)MY_ADDRESS);
web3.Web3ClientVersion(result);
USE_SERIAL.println(result); // Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9
#define INFURA_HOST "rinkeby.infura.io"
#define INFURA_PATH "/<YOUR_INFURA_ID>"
Web3 web3(INFURA_HOST, INFURA_PATH);
pragma solidity ^0.4.18;
contract Sample {
uint data;
function set(uint d) public{
data = d;
}
function get() public constant returns (uint retVal) {
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>計算用</name>
<description/>
<Style id="icon-1899-FF5252-nodesc-normal">
<IconStyle>
<color>ff5252ff</color>
<scale>1</scale>
<Icon>
@kopanitsa
kopanitsa / toaster.ino
Created December 1, 2015 17:50
arduino sample for toaster control
#include <SPI.h>
#define PROMINI
#ifdef PROMINI
// pin number
#define VCC 8
#define GND 9
#define SLAVE 10
@kopanitsa
kopanitsa / stacktrace.c
Created July 1, 2014 03:33
ARM C stack trace
#include <stdbool.h>
#include <stdlib.h>
#include <execinfo.h>
#include <signal.h>
void test() {
void *trace[128];
int n = backtrace(trace, sizeof(trace) / sizeof(trace[0]));
backtrace_symbols_fd(trace, n, 1);
@kopanitsa
kopanitsa / acc.m
Last active August 29, 2015 14:02
konashi Accelerometer sample
unsigned char slave_addr= 0x4c;
unsigned char MMA7660_MODE = 0x07;
unsigned char MMA7660_STAND_BY = 0x00;
unsigned char MMA7660_ACTIVE = 0x01;
unsigned char MMA7660_SR = 0x08;
unsigned char AUTO_SLEEP_1 = 0X07;
- (void)init {
@kopanitsa
kopanitsa / Itead_spi_sample.c
Created June 10, 2014 12:46
Itead SPI sample
/*
* (C) Copyright 2014
* okada.takahiro111@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Sample to read/write "mbed Geta SPI PRAM 128Mbit" from Iteaduino A20.