This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
# __FILE__ keyword in ruby | |
puts "The current ruby file being executed is #{__FILE__}" | |
# Gets the directory name of the file being executed | |
current_directory = File.dirname(__FILE__) | |
puts "The current directory is #{current_directory}" | |
# expands to reveal the pwd (Present working directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract AddressType { | |
address public basicAddress = 0xeCc6425dB956125989C2c1a58A817bD90f86B3C0; | |
address public basicAddress2 = 0x9Fa413fad794c18fdd3A5Ead5734f042Eb920A20; | |
address payable anotherPayableAddress = payable(0x94fe479322fa107933d67b9e230a9B12B6c9a96d); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract AddressType { | |
address public aDefaultAddress; | |
// Example of a non checksum address (not allowed by solidity compiler) | |
// Can fix using: | |
// web3.utils.toChecksumAddress('0xecc6425db956125989c2c1a58a817bd90f86b3c0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract IntegerType { | |
// uint type is same as uint256 | |
uint256 aUint; | |
// int type is same as int256 | |
int256 anInt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract BoolType { | |
//a basic bool | |
bool public aBool; | |
function notBool() public view returns (bool) { | |
return !aBool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract BoolType { | |
bool public aBool; | |
function notBool() public view returns (bool) { | |
return !aBool; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Restrict arguments to a specified class. | |
require 'optparse' | |
class HelloParser | |
def self.parse(args) | |
options = {} | |
opts = OptionParser.new do |opts| | |
opts.banner = "Usage: name" | |
opts.on('-n', '--name NAME', 'The name of the person to say hello to') do |name| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from decimal import * | |
#Sets decimal to 10000 digits of precision | |
getcontext().prec = 10000 | |
def plouffBig(n): #http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula | |
pi = Decimal(0) | |
k = 0 | |
while k < n: | |
pi += (Decimal(1)/(16**k))*((Decimal(4)/(8*k+1))-(Decimal(2)/(8*k+4))-(Decimal(1)/(8*k+5))-(Decimal(1)/(8*k+6))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a list of numbers an a number k, return whether any two number from the list add up to k | |
For example. given [10,15,3,7] and k of 17 return true sine 10 + 7 is 17. | |
Bonus can you do in a single pass? | |
*/ | |
array = [7,15,3,7,8,3,4,100] | |
k = 23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Make sure to install @vue/cli-service-global first--> | |
<!--Serve this up using `vue serve` at the command line--> | |
<!--Details here: https://cli.vuejs.org/guide/prototyping.html --> | |
<template> | |
<div> | |
<h1>{{name}}</h1> | |
<b>Logging To Vue Component? <span>{{logging}}</span></b> | |
<br /> | |
<button @click="testLog">Test Log</button>|<button @click="testWarn">Test Warn</button>|<button @click="toggleLogging">Toggle Logging</button> | |
<hr/> |
NewerOlder