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
// Challenge #1: given this data structure, create a function that will return the route given a step | |
const steps = [ | |
{ step: "c", next: "b" }, | |
{ step: "b", next: "f" }, | |
{ step: "aa", next: "c" }, | |
{ step: "f", next: "r" }, | |
{ step: "v", next: "z" }, | |
{ step: "r", next: "ka" }, | |
{ step: "ka", next: "v" }, |
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
// To conserve gas, efficient serialization is achieved through Borsh (http://borsh.io/) | |
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; | |
use near_sdk::collections::{LookupMap, UnorderedMap}; | |
use near_sdk::json_types::U128; | |
use near_sdk::serde_json::json; | |
use near_sdk::{assert_one_yocto, env, near_bindgen, setup_alloc, AccountId, Balance}; | |
use std::collections::HashMap; | |
use near_contract_standards::fungible_token::FungibleToken; | |
use near_contract_standards::fungible_token::metadata::{ | |
FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC, |
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
import { PrismaClient, Prisma } from "@prisma/client"; | |
import Dayjs from "dayjs"; | |
const prisma = new PrismaClient(); | |
const account_id = "gtacodingtutor.testnet"; | |
const issueDate = new Date("2021-09-21"); | |
const expiryDate = new Date("2022-03-20"); | |
const today = new Date("2022-03-01"); | |
const inactivePeriodInDays = 180; |
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
{ | |
"name": "AsusAmazon", | |
"mspid": "AmazonMSP", | |
"roles": null, | |
"affiliation": "", | |
"enrollmentSecret": "", | |
"enrollment": { | |
"signingIdentity": "50af112175657b319a236bde7cdf245c0eb12af036760431b7bc0802df9c4585", | |
"identity": { | |
"certificate": "-----BEGIN CERTIFICATE-----\nMIICBzCCAa6gAwIBAgIRANxDdNx/o7m53RCykHobac0wCgYIKoZIzj0EAwIwZzEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xEzARBgNVBAoTCkFtYXpvbi5jb20xFjAUBgNVBAMTDWNhLkFtYXpv\nbi5jb20wHhcNMTgwMzE3MjM1MDQxWhcNMjgwMzE0MjM1MDQxWjBVMQswCQYDVQQG\nEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNj\nbzEZMBcGA1UEAwwQQWRtaW5AQW1hem9uLmNvbTBZMBMGByqGSM49AgEGCCqGSM49\nAwEHA0IABKOeiUtW4iA2HRRuC9bDRox1AdrRKXGDeiCPOAVDsNbEHQJsPgbSwehT\n1kBYbgIuG8uKLZ/N1bgYvgajOtGZB2ejTTBLMA4GA1UdDwEB/wQEAwIHgDAMBgNV\nHRMBAf8EAjAAMCsGA1UdIwQkMCKAIGwvSD5ZPhUQXbCxBPXrMSiqiZ69yWH3pz66\nFp9RroNCMAoGCCqGSM49BAMCA0cAMEQCIEQGiHQkl8+CB0VYuUZ4jJ26MJKSnDgp\no/wZfTANz1AgAiBqiJjBf+ADRr8aVBXtgzmmvnVEfkQf+Vrf64TreArvKw= |
#Nginx Basics for Ubuntu
Please see http://wiki.nginx.org/Main for more information. See http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ for a tutorial on how to install Nginx.
##Installation To install, you can install the version which is in the standard Ubuntu repositories but it is normally quite old and will not have the latest security patches. The best way is to update the repositories first:
apt-get update
apt-get install python-software-properties
apt-get upgrade
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
var choices = [{choice: "r", beats: "s", losesTo: "p"}, | |
{choice: "p", beats: "r", losesTo: "s"}, | |
{choice: "s", beats: "p", losesTo: "r"}]; | |
function rps(c){ | |
var i = Math.floor(Math.random() * 3) | |
var myC = choices[i]; | |
if (myC.choice == c) return "Draw"; | |
else if (myC.beats == c) return "Win"; | |
else if (myC.losesTo == c) return "Lose"; |
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
upstream docker-registry { | |
server registry:5000; | |
} | |
server { | |
listen 443; | |
server_name myregistrydomain.com; | |
# SSL | |
# ssl on; |
With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?
- Go to
/etc/init/
$ sudo vim yourapp.conf
- Paste script.conf
$ sudo start yourapp
- And when you wanna kill the process
$ sudo stop yourapp
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
//Find the missing number in a list | |
//http://stackoverflow.com/questions/2113795/quickest-way-to-find-missing-number-in-an-array-of-numbers | |
//list can start anywhere, assumes arithmetric series where n, n+1,n+2 etc.. | |
function getMissingNum() { | |
var start = Math.floor(Math.random() * 150) / 1; | |
var nElem = Math.floor(Math.random() * 20) / 1; | |
var set = []; | |
var rand = Math.floor(Math.random() * nElem) + start / 1; | |
for (var i = start; i <= start + nElem; i++) { |
NewerOlder