Skip to content

Instantly share code, notes, and snippets.

View huhn511's full-sized avatar
🏠
Working from home

huhn511

🏠
Working from home
View GitHub Profile
console.log("Hello World");
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
send() {
console.log("Send!");
}
@huhn511
huhn511 / App.js
Last active June 30, 2018 09:03
App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SendButton from './components/SendButton'
class App extends Component {
render() {
return (
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SendButton from './components/SendButton'
import IOTA from 'iota.lib.js'
class App extends Component {
constructor(props) {
async function signData(data) {
// deletes old sig attribute, if existing
delete data.sig;
// convert obj to json
const json = JSON.stringify(data);
// load file with private key
const file = await util.promisify(fs.readFile)(path.join(privKeyFile));
async function verifyData(data) {
// return false if the object has no signature
if (!data.sig) {
return false;
}
else {
// save the signature and delite it from the object
const signature = data.sig;
const converter = require('@iota/converter')
converter.trytesToAscii(transaction.signatureMessageFragment)
@huhn511
huhn511 / Local_PoW_Support.rb
Last active December 14, 2018 14:40
If you want to use this gem with public full node which does not support remote PoW on host, you can set local_pow to true when initialising the client.
require 'iota'
# With remote PoW
client = IOTA::Client.new(provider: 'https://node.iota-tangle.io:14265')
# If you use `client.api.attachToTangle` api here, you'll get error saying that attachToTangle command is not allowed
# With local pow
client = IOTA::Client.new(provider: 'https://node.iota-tangle.io:14265', local_pow: true)
# Now you can use `client.api.attachToTangle` api, which will do the proof-of-work on transaction and return the trytes that needs to be broadcasted
@huhn511
huhn511 / create_active_storage_tables.active_storage.rb
Last active December 15, 2018 14:33
ActiveStorage Migration
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
create_table :active_storage_blobs do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.bigint :byte_size, null: false
t.string :checksum, null: false
<div class="field">
<%= form.label :image %>
<%= form.file_field :image %>
</div>