Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Developing the future

Kristijan Sedlak xpepermint

💭
Developing the future
View GitHub Profile
View graphql-nested-schema-example
1. Build GraphQL server using `express-graphql` package.
2. Configure `schema.js` file.
3. Query for data.
@xpepermint
xpepermint / webpack.config.js
Last active Jul 1, 2022
Vue.js webpack.config.js
View webpack.config.js
var path = require('path');
var webpack = require('webpack');
var isProduction = process.env.NODE_ENV === 'production';
/*
* Compile for usage in a browser-like environmen or for the server.
*/
exports.target = 'web';
@xpepermint
xpepermint / from-linux.rs
Last active May 2, 2022
Rust random number
View from-linux.rs
use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("/dev/urandom").unwrap(); // from Linux
let mut buf = [0u8; 16];
f.read_exact(&mut buf).unwrap();
println!("{:?}", buf);
}
@xpepermint
xpepermint / README.md
Last active Mar 3, 2022
RushJS cheatsheet
View README.md

Commands

Install dependencies:

npm install -g @microsoft/rush

Initialize the project:

View xcert-certification-example-for-ethereum.js
const { Cert } = require('@0xcert/cert');
const { HttpProvider } = require('@0xcert/ethereum-http-provider');
const { AssetLedger } = require('@0xcert/ethereum-asset-ledger');
(async () => {
const schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"description": "A digital assets that have a unique combination of different properties.",
"properties": {
@xpepermint
xpepermint / u32_struct.rs
Last active Oct 7, 2021
Reimplementation of a u32 type in Rust.
View u32_struct.rs
use std::ops;
#[derive(Debug, Default, Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct U32(u32);
impl ops::Add for U32 {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0)
}
@xpepermint
xpepermint / example.rs
Created Sep 26, 2021
Check if struct implements a specific trait
View example.rs
```rs
// Based on: https://www.reddit.com/r/rust/comments/ehr8ct/announcing_impls_a_macro_to_determine_if_a_type/
// trait for T
trait TTrate {
const VALUE: bool = false;
}
impl<T> TTrate for T {}
// custom trait
@xpepermint
xpepermint / webpack.config.js
Last active Apr 20, 2021
Webpack Common Configuration File (ReactJS)
View webpack.config.js
'use strict';
/**
* Webpack Configuration File
*
* This is a configuration file for Webpack module bundler. You should customize
* it to fit your project.
*
* To start the development server run:
*
View Function accepts struct or function pointer
// Parameter that each resolver accepts.
pub struct Intent {}
// Resolver definition.
pub trait Resolver {
fn resolve(&self, intent: Intent) -> Result<usize, usize>;
}
impl<F: Fn(Intent) -> Result<usize, usize>> Resolver for F {
fn resolve(&self, intent: Intent) -> Result<usize, usize> {
self(intent)
View gist:2ce1d9aaa134db8fed1b90c87292a373
```
docker run -d \
--name geth-test \
-p 8545:8545 \
-v ~/.docker/machine/volumes/geth-test/data:/root/.ethereum \
ethereum/client-go \
--testnet \
--rpc \
--rpcaddr "0.0.0.0" \
--rpccorsdomain "*" \