Skip to content

Instantly share code, notes, and snippets.

@tuncatunc
tuncatunc / ls-rust.rs
Created January 28, 2023 13:44
ls in rust
use std::fs;
use std::path::Path;
fn list_files(path: &Path) {
let metadata = match fs::metadata(path) {
Ok(metadata) => metadata,
Err(_) => return,
};
if metadata.is_file() {
@tuncatunc
tuncatunc / main.js
Created December 24, 2022 06:45
Signing with X-Wallet for Kadena network
const NETWORKID = "testnet04";
/**
* Check if is X-Wallet installed
*/
const isXWalletInstalled = () => {
const { kadena } = window;
return Boolean(kadena && kadena.isKadena);
};
const initialize = async () => {
const HELP = `Usage example: \n\nnode transfer-create.js k:{public-key} amount -- Replace {public-key} with an actual key`;
import Pact from "pact-lang-api"
const NETWORK_ID = 'development'//'testnet04';
const CHAIN_ID = '0';
const API_HOST = `http://localhost:8080/chainweb/0.0/${NETWORK_ID}/chain/${CHAIN_ID}/pact`;
const KEY_PAIR = {
publicKey: "368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca",
secretKey: "251a920c403ae8c8f65f59142316af3c82b631fba46ddea92ee8c95035bd2898"
};
@tuncatunc
tuncatunc / .deps...remix-tests...remix_accounts.sol
Created October 30, 2022 20:40
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
@tuncatunc
tuncatunc / .deps...remix-tests...remix_accounts.sol
Created October 30, 2022 19:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
@tuncatunc
tuncatunc / .deps...remix-tests...remix_accounts.sol
Created October 30, 2022 19:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
@tuncatunc
tuncatunc / sell_b.js
Last active July 29, 2022 06:43
Pancakeswap Swap Extact B tokens for ETH
// Sells B for BNB from pancakeswap for address ${targetAccounts[targetIndex].address}
var fs = require('fs')
var Tx = require('ethereumjs-tx').Transaction;
var Web3 = require('web3')
var Common = require('ethereumjs-common').default;
const ankrlRpcUrl = 'https://rpc.ankr.com/bsc/';
var web3 = new Web3(new Web3.providers.HttpProvider(ankrlRpcUrl))
package main
import "fmt"
// List represents a singly-linked list that holds
// values of any type.
type List[T comparable] struct {
next *List[T]
val T
}
package main
import "golang.org/x/tour/pic"
import "image"
import "image/color"
type Image struct{
w int
h int
}