Skip to content

Instantly share code, notes, and snippets.

$(document).ready(function() {
$("#blockchain button.set").click(function() {
var value = parseInt($("#blockchain input.text").val(), 10);
SimpleStorage.set(value);
addToLog("#blockchain", "SimpleStorage.set(" + value + ")");
});
$("#blockchain button.get").click(function() {
SimpleStorage.get().then(function(value) {
@TheBojda
TheBojda / App.vue
Created August 16, 2021 10:53
libp2p browser chat example in JavaScript with vue.js
<template>
<div>
<p>Your peerId: {{ myPeerId }}</p>
<p>
Other peerId:
<input type="text" style="width: 420px" v-model="otherPeerId" /><button
@click="findOtherPeer"
>
Find
</button>
@TheBojda
TheBojda / App.js
Created August 9, 2021 08:43
Simple Vue.js TODO example with TypeScript and vue-class-component
<template>
<main role="main" class="container">
<div class="card">
<div class="card-body">
<h5 class="card-title">Todo example</h5>
<p class="card-text">Simple TODO app using Bootstrap and Vue.</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item" v-for="(todo, idx) in todos" :key="idx">
{{ todo }}
@TheBojda
TheBojda / docker-compose.yaml
Last active July 15, 2021 23:25
Docker compose file for a simple WordPress with MySQL
# Docker compose file for a simple WordPress with MySQL
# source: https://docs.docker.com/samples/wordpress/
version: "3.3"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
@TheBojda
TheBojda / App.tsx
Created May 30, 2021 10:36
Simple todo example in react native using typescript and state hooks
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, Platform, Keyboard, Button, FlatList, TextInput } from 'react-native';
const isAndroid = Platform.OS == "android";
export default function App() {
const [text, setText] = useState('');
const [tasks, setTasks] = useState([{ key: '0', text: "First task" }]);
const [viewPadding, setViewPadding] = useState(0);
@TheBojda
TheBojda / minimalistic-nft-token.sol
Last active May 12, 2021 21:06
Minimalistic NFT Ethereum contract in Solidity
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.4;
contract NFTToken {
event Mint(address indexed _to, uint256 indexed _tokenId, bytes32 _ipfsHash);
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
uint256 tokenCounter = 1;
mapping(uint256 => address) internal idToOwner;
@TheBojda
TheBojda / gradtape.py
Created November 10, 2019 10:44
Linear regression with Tensorflow GradientTape
# Linear regression using GradientTape
# based on https://sanjayasubedi.com.np/deeplearning/tensorflow-2-linear-regression-from-scratch/
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
class Model:
def __init__(self):
self.W = tf.Variable(16.0)
@TheBojda
TheBojda / cifar10.py
Created August 24, 2020 08:14
PyTorch CIFAR10 neural network example
import torch
import torchvision
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt
import torch.optim as optim
transform = transforms.Compose([
@TheBojda
TheBojda / autograd.py
Created August 23, 2020 13:07
Simple linear regression with PyTorch autograd
import torch
import numpy as np
import matplotlib.pyplot as plt
TRUE_W = 3.0
TRUE_b = 0.5
NUM_EXAMPLES = 1000
x = torch.empty(NUM_EXAMPLES).normal_(mean=0,std=1.0)
@TheBojda
TheBojda / todo-native.vue
Created June 10, 2020 10:44
Simple Vue Native TODO example with NativeBase components
<template>
<nb-container>
<nb-header></nb-header>
<nb-grid>
<nb-row :style="{ height: 60 }" v-for="(todo, idx) in todos" :key="idx">
<nb-col :size="85" :style="{ justifyContent: 'center' }">
<text :style="{marginLeft: 10}">{{todo}}</text>
</nb-col>
<nb-col :size="15" :style="{ justifyContent: 'center' }">
<nb-button iconCenter transparent :on-press="() => removeItem(idx)">