📝 Added sandbox (code sketchbook)

This commit is contained in:
z3rOR0ne 2023-04-22 00:41:54 -07:00
parent b475595f7f
commit b5daf18b1a
142 changed files with 100702 additions and 0 deletions

BIN
sandbox/add Executable file

Binary file not shown.

8
sandbox/add.rs Normal file
View file

@ -0,0 +1,8 @@
// Main function
fn main() {
let a = 100;
let b = 200;
let name = "Jenny";
println!("Result is {}", a + b);
println!("The name is {}", name);
}

BIN
sandbox/array Executable file

Binary file not shown.

5
sandbox/array.rs Normal file
View file

@ -0,0 +1,5 @@
// Main function
fn main() {
let arr:[i32;4] = [1, 2, 3, 4];
println!("array size is {}", arr.len());
}

21
sandbox/assert.c Normal file
View file

@ -0,0 +1,21 @@
/* https://www.tutorialspoint.com/c_standard_library/c_macro_assert.htm */
#include <assert.h>
#include <stdio.h>
int main() {
int a;
char str[50];
printf("Enter an integer value: ");
scanf("%d", &a);
assert(a >= 10);
printf("Integer entered is %d\n", a);
printf("Enter string: ");
scanf("%s", str);
assert(str != NULL);
printf("String entered is: %s\n", str);
return(0);
}

19
sandbox/atoi.c Normal file
View file

@ -0,0 +1,19 @@
/* https://www.tutorialspoint.com/c_standard_library/c_function_atoi.htm */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int val;
char str[20];
strcpy(str, "98993489");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
strcpy(str, "tutorialspoint.com");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
return 0;
}

1
sandbox/awk Normal file
View file

@ -0,0 +1 @@
testfile.txt -F. {print $1}

1
sandbox/codepends Submodule

@ -0,0 +1 @@
Subproject commit 30bc80279f648d34fa8c92f1a804f8101bd53d77

View file

@ -0,0 +1,133 @@
/* Taken from https://www.demo2s.com/html-css/css-flowing-circuit-animation.html */
html, body {
height:100%;
padding:0;
margin:0;
}
* {
box-sizing:border-box;
}
.circuit-outer {
position:relative;
width:80vw;
height:80vh;
margin:5% 10% 0;
padding:3px;
background:#eee;
/* border:1px solid #ddd; */
border:1px solid red;
overflow:hidden;
}
.circuit-inner {
position:absolute;
top:3px;
bottom:3px;
left:3px;
right:3px;
background:#fff;
/* border:1px solid #ddd; */
border:1px solid blue;
}
.current {
background:orange;
position:absolute;
animation-iteration-count:1;
animation-timing-function:linear;
animation-fill-mode:forwards;
}
.current.bottom-left {
bottom:0;
right:80%;
width:20%;
height:3px;
animation-name:zap1;
animation-duration:.2s;
}
.current.left {
bottom:0;
left:0;
width:3px;
height:0;
animation-name:zap2;
animation-delay:.2s;
animation-duration:.5s;
}
.current.top {
top:0;
width:0;
height:3px;
animation-name:zap3;
animation-delay:.7s;
animation-duration:1s;
}
.current.right {
top:0;
right:0;
width:3px;
height:0;
animation-name:zap2;
animation-delay:1.7s;
animation-duration:.5s;
}
.current.bottom-right {
bottom:0;
right:0;
width:0%;
height:3px;
animation-name:zap4;
animation-delay:2.2s;
animation-duration:.8s;
}
@keyframes zap1 {
0% {
width:0;
}
100% {
width:20%;
}
}
@keyframes zap2 {
0% {
height:0;
}
100% {
height:100%;
}
}
@keyframes zap3 {
0% {
width:0;
}
100% {
width:100%;
}
}
@keyframes zap4 {
0% {
width:0;
}
100% {
width:80%;
}
}

View file

@ -0,0 +1,25 @@
/* Taken from https://www.demo2s.com/html-css/css-flowing-circuit-animation.html */
.bar {
position: absolute;
margin: 0em 0em 0em 0em;
background: orange;
bottom:0;
left:50%;
width:5px;
height:60%;
animation-name:zap2;
animation-delay:.2s;
animation-duration:2s;
}
@keyframes zap2 {
0% {
height:0;
}
100% {
height:60%;
}
}

View file

@ -0,0 +1,21 @@
<!-- Taken from https://www.demo2s.com/html-css/css-flowing-circuit-animation.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/styles.css">
<title>basic circuit animation</title>
</head>
<body>
<div class="circuit-outer">
<div class="current bottom-left"></div>
<div class="current left"></div>
<div class="current top"></div>
<div class="current right"></div>
<div class="current bottom-right"></div>
<div class="circuit-inner"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,14 @@
<!-- Taken from https://www.demo2s.com/html-css/css-flowing-circuit-animation.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/styles2.css">
<title>basic circuit animation</title>
</head>
<body>
<div class="bar"></div>
</body>
</html>

View file

@ -0,0 +1,110 @@
body {
/* background: coral; */
background: white;
}
.blank {
background: red;
width: 100px;
height: 100px;
/* margin: 0em 0em 0e20em; */
}
.loading-box {
/* margin: 25em auto auto; */
height: 300px;
width: 100px;
/* height: 75px; */
/* width: 75px; */
border: 10px solid blue;
/* transform: skewY(100deg); */
/* transform: rotate(180deg); */
/* animation: roll 2s infinite ease-out; */
}
.loading-box2 {
position: absolute;
margin: 0em 5em 5em 20em;
height: 1px;
width: 10px;
/* border: 10px solid blue; */
/* border: 10px solid blue; */
/* transform: skewY(45deg); */
}
.loading-inner-box {
background: orange;
height: 300px;
animation: fill 3s ease-in;
}
.loading-inner-box2 {
background: orange;
height: 200px;
/* height: auto; */
animation: fill2 3s ease-in;
animation-delay: 3s;
}
/* @keyframes roll { */
/* 0% { */
/* transform: rotate(180deg); */
/* } */
/* 40% { */
/* transform: rotate(180deg); */
/* } */
/* 60% { */
/* transform: rotate(360deg); */
/* } */
/* 100% { */
/* transform: rotate(360deg); */
/* } */
/* } */
@keyframes fill {
from {
transform: translateY(100%);
height: -300px;
}
to {
transform: translateY(0%);
height: 300px;
/* height: 0px; */
}
}
@keyframes fill2 {
from {
transform: translateY(100%);
height: -1px;
}
to {
transform: translateY(0%);
height: 200px;
/* height: 0px; */
}
}
/* @keyframes fill { */
/* 0% { */
/* height: 0px; */
/* } */
/* 40% { */
/* height: 200px; */
/* } */
/* 60% { */
/* height: 200px; */
/* } */
/* 100% { */
/* height: 200px; */
/* } */
/* } */
/* this one doesn't wait for the loading animation */
/* @keyframes roll { */
/* from { */
/* transform: rotate(0deg); */
/* } */
/* to { */
/* transform: rotate(359deg); */
/* } */
/* } */

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Loading Animation</title>
<link rel="stylesheet" href="css/loading_animation.css">
</head>
<body>
<!-- <div class="blankspace"></div> -->
<div class="container">
<div class="loading-box">
<div class="loading-inner-box">
</div>
</div>
<div class="loading-box2">
<div class="blank"></div>
<div class="loading-inner-box2">
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Test Slider</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="//unpkg.com/a11y-slider@latest/dist/a11y-slider.css" />
</head>
<body>
<ul class="slider">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<script src="//unpkg.com/a11y-slider@latest/dist/a11y-slider.js"></script>
<script>
const slider = new A11YSlider(document.querySelector('.slider'), {
adaptiveHeight: true,
dots: false
});
</script>
</body>
</html>

View file

@ -0,0 +1,8 @@
.slider {
display: flex;
}
.slider > * {
width: 100%;
flex: 0 0 auto;
}

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="./style.css" rel="stylesheet">
</head>
<body>
<div id="container">
<div id="halfclip">
<div class="halfcircle" id="clipped"></div>
</div>
<div class="halfcircle" id="fixed"></div>
<div class="finalcircle">
<div id="innercircle"</div>
</div>
</div>
<script src="./script.js"></script>
</body>
</html>

View file

@ -0,0 +1,17 @@
const delay = (ms) =>
new Promise(res => setTimeout(res, ms))
const finalCircle = document.getElementsByClassName("finalcircle")
const halfClip = document.getElementById("halfclip")
const clipped = document.getElementById("clipped")
const fixed = document.getElementById("fixed")
const halfCircle = document.getElementsByClassName("halfcircle")
window.addEventListener('load', async () => {
await delay(1000)
halfClip.style.visibility = "hidden"
clipped.style.visibility = "hidden"
fixed.style.visibility = "hidden"
halfCircle[0].style.visibility = "hidden"
finalCircle[0].style.visibility = "visible"
})

View file

@ -0,0 +1,77 @@
#container {
position: absolute;
width: 12px;
height: 12px;
}
#halfclip {
width: 50%;
height: 100%;
right: 0px;
position: absolute;
overflow: hidden;
transform-origin: left center;
animation: cliprotate 1s steps(2) infinite;
}
.halfcircle {
box-sizing: border-box;
height: 100%;
right: 0px;
position: absolute;
border: solid 4px transparent;
border-top-color: blue;
border-left-color: blue;
border-radius: 50%;
}
#clipped {
width: 200%;
animation: rotate 0.5s linear infinite;
}
#fixed {
width: 100%;
transform: rotate(135deg);
animation: showfixed 1s steps(2) infinite;
}
@keyframes cliprotate {
0% {transform: rotate(0deg);}
100% {transform: rotate(360deg);}
}
@keyframes rotate {
0% {transform: rotate(-45deg);}
100% {transform: rotate(135deg);}
}
@keyframes showfixed {
0% {opacity: 0;}
49.9% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: 1;}
}
/***********************
* MY ADDITIONS
************************/
.finalcircle {
display: flex;
justify-content: center;
align-items: center;
width: 12px;
height: 12px;
border-radius: 100%;
visibility: hidden;
background-color: blue;
}
#innercircle {
position: absolute;
top: 3.5px;
width: 4px;
height: 4px;
background-color: white;
border-radius: 100%;
}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="./style.css" rel="stylesheet">
</head>
<body>
<div class="line"></div>
</body>
</html>

View file

@ -0,0 +1,12 @@
.line {
height:10px;
width:0;
margin-top:100px;
background:red;
transform:rotate(-45deg);
transform-origin:left;
animation:grow 1s linear forwards;
}
@keyframes grow{
to {width:100px;}
}

View file

@ -0,0 +1,2 @@
node_modules
npm-debug.log

View file

@ -0,0 +1,6 @@
trailingComma: "all"
tabWidth: 4
semi: false
singleQuote: true
bracketSpacing: true
arrowParens: "avoid"

View file

@ -0,0 +1,19 @@
FROM node:18
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both apckage.json AND package-lock.json are
# copied where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --omit=dev
# BUNDLE app source
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]

View file

@ -0,0 +1,41 @@
## Basic Docker Usage with Node/Express backend
This small project was taken from an article over at [nodejs.org](https://nodejs.org/en/docs/guides/nodejs-docker-webapp).
### Of Note:
Ensure that you have a .dockerignore file so that you don't copy your
node_modules to the docker image:
```
node_modules
npm-debug.log
```
### Build, run, test:
```
docker build . -t <your username>/node-web-app
```
```
docker run -p 49160:8080 -d <your username>/node-web-app
```
Note that this is exposing docker's port 8080 to the host machine's port 49160
in this case, so after running the image you can visit it on your host machine
by going to localhost:49160, or for something this simple you can just use curl:
```
curl -i localhost:49160
```
If you want to go inside the container to check out the inside:
```
docker exec -it <container id> /bin/bash
```
### Further Reading:
[Building Efficient Dockerfiles - Node.js](https://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/)
[Introducing `npm ci` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)

1018
sandbox/docker_web_app/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
{
"name": "docker_web_app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}

View file

@ -0,0 +1,15 @@
'use strict'
const express = require('express')
// Constants
const PORT = 8080
// App
const app = express()
app.get('/', (req, res) => {
res.send('Hello World')
})
app.listen(PORT, () => {
console.log(`Running on port: ${PORT}`)
})

22
sandbox/dup.c Normal file
View file

@ -0,0 +1,22 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
int file_desc = open("dup.txt", O_WRONLY | O_APPEND);
if (file_desc < 0)
printf("Error opening the file\n");
int copy_desc = dup(file_desc);
/* NOTE what is happening here, the dup() call creates a secondary
* file descriptor that duplicates the file descriptor
* (original: file_desc, copy: copy_desc),
* but references the same file (i.e. dup.txt) */
write(copy_desc, "This will be output to the file named dup.txt\n", 46);
write(file_desc, "This will also be output to the file named dup.txt\n", 51);
return 0;
}

2
sandbox/dup.txt Normal file
View file

@ -0,0 +1,2 @@
This will be output to the file named dup.txt
This will also be output to the file named dup.txt

28
sandbox/dup2.c Normal file
View file

@ -0,0 +1,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
int main() {
int file_desc = open("dup2.txt", O_WRONLY | O_APPEND);
/* here the newfd is the file descriptor of stdout
* note that using our dup.c program would create a new file descriptor,
* dup() doesn't do that, it takes a second argument through which it will
* duplicate the file descriptor of whichever one we wish */
dup2(file_desc, 1);
printf("I will be printed to the file dup2.txt\n");
return 0;
}
/* https://stackoverflow.com/questions/4171126/what-do-the-dup-and-dup2-systems-really-do */
/* EXPLANATION FROM STACKOVERFLOW:
Both make a new file descriptor corresponding to an existing open file description.
Most properties between the old and new fd (like position) are shared; the only property
I can think of that's not shared is the close-on-exec flag. The difference between dup and
dup2 is that dup assigns the lowest available file descriptor number, while dup2 lets you
choose the file descriptor number that will be assigned and atomically closes and replaces
it if it's already taken. */

2
sandbox/dup2.txt Normal file
View file

@ -0,0 +1,2 @@
I will be printed to the file dup2.txt
I will be printed to the file dup2.txt

56
sandbox/email/index.js Normal file
View file

@ -0,0 +1,56 @@
require('dotenv').config()
const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const nodemailer = require('nodemailer')
const app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static(path.join(__dirname, "public")))
app.use(express.json())
const route = express.Router()
const port = process.env.PORT || 8080
app.use('/v1', route)
const transporter = nodemailer.createTransport({
port: 465,
host: process.env.HOST,
auth: {
user: process.env.USER_EMAIL,
pass: process.env.PASS
},
secure: true
})
// separate out concerns, one server serves the page, another sends the email
route.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html')
})
route.post('/text-mail', (req, res) => {
const {subject, body} = req.body
// create a from field in the html form
// const {from, subject, body} = req.body
const mailData ={
from: process.env.FROM,
// from: from,
to: process.env.TO,
subject: subject,
text: body,
html: `<b>Hey There!</b><br>${body}</br>`
}
transporter.sendMail(mailData, function (err, info) {
if (err) {
return console.log(err)
}
res.status(200).send({ message: "Mail send", message_id: info.messageId })
})
})
app.listen(port, () => {
console.log(`Server listening on port ${port}`)
})

1081
sandbox/email/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
{
"name": "email",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node ./index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"nodemailer": "^6.8.0"
}
}

View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Basic Email Form</title>
</head>
<body>
<form class="email" id="emailform">
<div>
<input type="text" placeholder="Subject" name="subject" required />
</div>
<div>
<textarea placeholder="Your message" name="body" required></textarea>
</div>
<div>
<button id="submit" >Send a message</button>
</div>
</form>
<script>
const btn = document.querySelector('#submit')
const form = document.querySelector('#emailform')
const url = '/v1/text-mail'
btn.addEventListener('click', (e) => {
e.preventDefault()
const formData = new FormData(form)
let object = {}
formData.forEach(function(value, key) {
object[key] = value
})
var json = JSON.stringify(object)
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: json
})
})
</script>
</body>
</html>

View file

@ -0,0 +1,25 @@
// Taken from (does not work on its own):
// https://scribe.rip/m/global-identity-2?redirectUrl=https%3A%2F%2Fcodeburst.io%2Fpolling-vs-sse-vs-websocket-how-to-choose-the-right-one-1859e4e13bd9
const express = require('express');
const events = require('./events');
const path = require('path');
const app = express();
const port = process.env.PORT || 5001;
const expressWs = require('express-ws')(app);
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/static/index.html'));
});
app.ws('/', function(ws, req) {
const githubEvent = {}; // sample github Event from Github event API https://api.github.com/events
ws.send('message', githubEvent);
});
app.listen(port, function() {
console.log('Listening on', port);
});

50
sandbox/fcntl.c Normal file
View file

@ -0,0 +1,50 @@
// From Page 84, Chapter 3 of Advanced Programming in the UNIX Environment
#include "apue.h"
#include <fcntl.h>
int main(int argc, char *argv[]) {
int val;
if (argc !=2)
printf("usage: a.out <descriptor#>\n");
if ((val = fcntl(atoi(argv[1]), F_GETFL, 0)) < 0)
printf("fcntl error for fd %d\n", atoi(argv[1]));
switch (val & O_ACCMODE) {
case O_RDONLY:
printf("read only\n");
break;
case O_WRONLY:
printf("write only\n");
break;
case O_RDWR:
printf("read write\n");
break;
default:
printf("unknown access mode\n");
}
if (val & O_APPEND)
printf(", append\n");
if (val & O_NONBLOCK)
printf(", nonblocking\n");
if (val & O_SYNC)
printf(", synchronous writes\n");
#if !defined(_POSIX_C_SOURCE) && defined(O_FSYNC) && (O_FSYNC != O_SYNC)
if (val & O_FSYNC)
printf(", synchronous writes\n");
#endif
putchar('\n');
exit(0);
}
/* EXAMPLE USES:
* ./a.out 0 < /dev/tty
* ./a.out 1 > temp.foo
* ./a.out 2 2>>temp.foo
* ./a.out 5 5<>tmep.foo
*/

1
sandbox/file.txt Normal file
View file

@ -0,0 +1 @@
hello there

View file

@ -0,0 +1,19 @@
'use strict'
// flattens javascript object and returns an array of all values
const deflateObject = (obj) => {
const result = []
const deflate = (obj) => {
return Object.keys(obj).forEach(key => {
return typeof obj[key] === 'object' && obj[key]
? deflate(obj[key])
: typeof obj[key] === 'function'
? result.push(obj[key]())
: obj[key]
? result.push(obj[key])
: ''
})
}
deflate(obj)
return result
}

13
sandbox/foo.pl Executable file
View file

@ -0,0 +1,13 @@
# a basic example of how to write a standard input output shell in perl, it invokes system library's shell to write shell commands when invoked
# to invoke: perl foo.pl
use strict;
use warnings;
# my $string = "shell:"
# print "$string\n";
while(<>) {
system($_);
}
exit 0;

View file

@ -0,0 +1,38 @@
// https://stackoverflow.com/questions/29285897/what-is-the-difference-between-for-in-and-for-of-statements
// heavily mutated array to demonstrate
const arr = [3, 5, 7]
arr['foo'] = "hello"
arr.bar = 'there'
arr[0] = 'what?'
console.log('arr :=>', arr)
console.log('for in loop...')
for (const key in arr) {
console.log(key) // returns 0 1 2 foo
}
console.log('for in with key/value...')
for (const key in arr) { // returns all key/val
const val = arr[key]
console.log('key :=>', key)
console.log('val :=>', val)
}
// for of is array specific
console.log('for of loop...')
for (const val of arr) {
console.log(val)
// returns 3 5 7 (not hello..., no key/value values)
}
// but can go over object.entries as it is an array
console.log('for of with key/value...')
for (const [key, val] of Object.entries(arr)) { // returns all key/val
console.log('key :=>', key)
console.log('val :=>', val)
}
// NOTE: for of can work with async calls whereas forEach cannot:
// https://stackoverflow.com/questions/67739881/async-foreach-containing-array-pushvalue-not-working

15
sandbox/fputc.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
int main(void)
{
FILE * fp = fopen("hallo.txt", "w");
fputc('A', fp);
/* getchar(); */
fputc('A', fp);
/* getchar(); */
return 0;
}
// creates file hallo.txt and writes "AA" to it.

14
sandbox/getchar.c Normal file
View file

@ -0,0 +1,14 @@
#include <stdio.h>
int main () {
char c;
printf("Enter character: \n");
c = getchar();
printf("Character entered: \n");
putchar(c);
printf("\n");
return(0);
}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="./style.css" rel="stylesheet">
</head>
<body>
<div class="glowing-circle"></div>
</body>
</html>

View file

@ -0,0 +1,21 @@
body {
background-color: black;
}
.glowing-circle {
width: 100px;
height: 100px;
border-radius:50%;
background-color: #fff;
-webkit-animation: glowing 1s ease-in-out infinite alternate;
-moz-animation: glowing 1s ease-in-out infinite alternate;
animation: glowing 1s ease-in-out infinite alternate;
}
@-webkit-keyframes glowing {
from {
box-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #f0f, 0 0 40px #0ff, 0 0 50px #e60073, 0 0 60px #e60073, 0 0 70px #e60073;
}
to {
box-shadow: 0 0 20px #fff, 0 0 30px #ff4da6, 0 0 40px #ff4da6, 0 0 50px #ff4da6, 0 0 60px #ff4da6, 0 0 70px #ff4da6, 0 0 80px #ff4da6;
}
}

BIN
sandbox/hello Executable file

Binary file not shown.

20
sandbox/hello.rs Normal file
View file

@ -0,0 +1,20 @@
// this is a comment, and is ignored by the compiler
//
// this is the main fucntion
/* this is a
* multiline comment*/
fn main() {
// statements here are executed when the compiled binary is called
//
// print text to the console
println!("Hello World!");
}
// to compile simply enter into terminal:
// rustc hello.rs
// this will create a binary under the same name, simply run:
// ./hello
//
// OUTPUTS:
// Hello World!

0
sandbox/home.html Normal file
View file

14
sandbox/index.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>My Website</title>
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<h1>Header 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<script src="scripts/scripts.js" defer></script>
</body>
</html>

9
sandbox/invoke.c Normal file
View file

@ -0,0 +1,9 @@
#include <unistd.h>
int
main(void)
{
/* the execl function is further described in the man pages, but is placed here essentially to exemplify how to invoke a command from within a c program */
execl("/usr/bin/st", "my terminal", NULL);
return 0;
}

View file

@ -0,0 +1,13 @@
const mathOperations = {
sum: function(a, b) {
return a + b
},
diff: function(a, b) {
return a - b
},
product: function(a, b) {
return a * b
}
}
module.exports = mathOperations

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1658435472545" clover="3.2.0">
<project timestamp="1658435472545" name="All files">
<metrics statements="5" coveredstatements="5" conditionals="0" coveredconditionals="0" methods="3" coveredmethods="3" elements="8" coveredelements="8" complexity="0" loc="5" ncloc="5" packages="1" files="1" classes="1"/>
<file name="calculator.js" path="/home/brian/sandbox/jest/calculator.js">
<metrics statements="5" coveredstatements="5" conditionals="0" coveredconditionals="0" methods="3" coveredmethods="3"/>
<line num="1" count="1" type="stmt"/>
<line num="3" count="1" type="stmt"/>
<line num="6" count="1" type="stmt"/>
<line num="9" count="1" type="stmt"/>
<line num="13" count="1" type="stmt"/>
</file>
</project>
</coverage>

View file

@ -0,0 +1,2 @@
{"/home/brian/sandbox/jest/calculator.js": {"path":"/home/brian/sandbox/jest/calculator.js","statementMap":{"0":{"start":{"line":1,"column":23},"end":{"line":11,"column":1}},"1":{"start":{"line":3,"column":8},"end":{"line":3,"column":20}},"2":{"start":{"line":6,"column":8},"end":{"line":6,"column":20}},"3":{"start":{"line":9,"column":8},"end":{"line":9,"column":20}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":31}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":2,"column":9},"end":{"line":2,"column":10}},"loc":{"start":{"line":2,"column":24},"end":{"line":4,"column":5}},"line":2},"1":{"name":"(anonymous_1)","decl":{"start":{"line":5,"column":10},"end":{"line":5,"column":11}},"loc":{"start":{"line":5,"column":25},"end":{"line":7,"column":5}},"line":5},"2":{"name":"(anonymous_2)","decl":{"start":{"line":8,"column":13},"end":{"line":8,"column":14}},"loc":{"start":{"line":8,"column":28},"end":{"line":10,"column":5}},"line":8}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1,"2":1},"b":{},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"06239d3476ab3311705c9735161845d0a0c535e7"}
}

View file

@ -0,0 +1,224 @@
body, html {
margin:0; padding: 0;
height: 100%;
}
body {
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 14px;
color:#333;
}
.small { font-size: 12px; }
*, *:after, *:before {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
h1 { font-size: 20px; margin: 0;}
h2 { font-size: 14px; }
pre {
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
margin: 0;
padding: 0;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
a { color:#0074D9; text-decoration:none; }
a:hover { text-decoration:underline; }
.strong { font-weight: bold; }
.space-top1 { padding: 10px 0 0 0; }
.pad2y { padding: 20px 0; }
.pad1y { padding: 10px 0; }
.pad2x { padding: 0 20px; }
.pad2 { padding: 20px; }
.pad1 { padding: 10px; }
.space-left2 { padding-left:55px; }
.space-right2 { padding-right:20px; }
.center { text-align:center; }
.clearfix { display:block; }
.clearfix:after {
content:'';
display:block;
height:0;
clear:both;
visibility:hidden;
}
.fl { float: left; }
@media only screen and (max-width:640px) {
.col3 { width:100%; max-width:100%; }
.hide-mobile { display:none!important; }
}
.quiet {
color: #7f7f7f;
color: rgba(0,0,0,0.5);
}
.quiet a { opacity: 0.7; }
.fraction {
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
font-size: 10px;
color: #555;
background: #E8E8E8;
padding: 4px 5px;
border-radius: 3px;
vertical-align: middle;
}
div.path a:link, div.path a:visited { color: #333; }
table.coverage {
border-collapse: collapse;
margin: 10px 0 0 0;
padding: 0;
}
table.coverage td {
margin: 0;
padding: 0;
vertical-align: top;
}
table.coverage td.line-count {
text-align: right;
padding: 0 5px 0 20px;
}
table.coverage td.line-coverage {
text-align: right;
padding-right: 10px;
min-width:20px;
}
table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 100%;
}
.missing-if-branch {
display: inline-block;
margin-right: 5px;
border-radius: 3px;
position: relative;
padding: 0 4px;
background: #333;
color: yellow;
}
.skip-if-branch {
display: none;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: #ccc;
color: white;
}
.missing-if-branch .typ, .skip-if-branch .typ {
color: inherit !important;
}
.coverage-summary {
border-collapse: collapse;
width: 100%;
}
.coverage-summary tr { border-bottom: 1px solid #bbb; }
.keyline-all { border: 1px solid #ddd; }
.coverage-summary td, .coverage-summary th { padding: 10px; }
.coverage-summary tbody { border: 1px solid #bbb; }
.coverage-summary td { border-right: 1px solid #bbb; }
.coverage-summary td:last-child { border-right: none; }
.coverage-summary th {
text-align: left;
font-weight: normal;
white-space: nowrap;
}
.coverage-summary th.file { border-right: none !important; }
.coverage-summary th.pct { }
.coverage-summary th.pic,
.coverage-summary th.abs,
.coverage-summary td.pct,
.coverage-summary td.abs { text-align: right; }
.coverage-summary td.file { white-space: nowrap; }
.coverage-summary td.pic { min-width: 120px !important; }
.coverage-summary tfoot td { }
.coverage-summary .sorter {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
}
.coverage-summary .sorted .sorter {
background-position: 0 -20px;
}
.coverage-summary .sorted-desc .sorter {
background-position: 0 -10px;
}
.status-line { height: 10px; }
/* yellow */
.cbranch-no { background: yellow !important; color: #111; }
/* dark red */
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
.low .chart { border:1px solid #C21F39 }
.highlighted,
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
background: #C21F39 !important;
}
/* medium red */
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
/* light red */
.low, .cline-no { background:#FCE1E5 }
/* light green */
.high, .cline-yes { background:rgb(230,245,208) }
/* medium green */
.cstat-yes { background:rgb(161,215,106) }
/* dark green */
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
.high .chart { border:1px solid rgb(77,146,33) }
/* dark yellow (gold) */
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
.medium .chart { border:1px solid #f9cd0b; }
/* light yellow */
.medium { background: #fff4c2; }
.cstat-skip { background: #ddd; color: #111; }
.fstat-skip { background: #ddd; color: #111 !important; }
.cbranch-skip { background: #ddd !important; color: #111; }
span.cline-neutral { background: #eaeaea; }
.coverage-summary td.empty {
opacity: .5;
padding-top: 4px;
padding-bottom: 4px;
line-height: 1;
color: #888;
}
.cover-fill, .cover-empty {
display:inline-block;
height: 12px;
}
.chart {
line-height: 0;
}
.cover-empty {
background: white;
}
.cover-full {
border-right: none !important;
}
pre.prettyprint {
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.com { color: #999 !important; }
.ignore-none { color: #999; font-weight: normal; }
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -48px;
}
.footer, .push {
height: 48px;
}

View file

@ -0,0 +1,87 @@
/* eslint-disable */
var jumpToCode = (function init() {
// Classes of code we would like to highlight in the file view
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
// Elements to highlight in the file listing view
var fileListingElements = ['td.pct.low'];
// We don't want to select elements that are direct descendants of another match
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
// Selecter that finds elements on the page to which we can jump
var selector =
fileListingElements.join(', ') +
', ' +
notSelector +
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
// The NodeList of matching elements
var missingCoverageElements = document.querySelectorAll(selector);
var currentIndex;
function toggleClass(index) {
missingCoverageElements
.item(currentIndex)
.classList.remove('highlighted');
missingCoverageElements.item(index).classList.add('highlighted');
}
function makeCurrent(index) {
toggleClass(index);
currentIndex = index;
missingCoverageElements.item(index).scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center'
});
}
function goToPrevious() {
var nextIndex = 0;
if (typeof currentIndex !== 'number' || currentIndex === 0) {
nextIndex = missingCoverageElements.length - 1;
} else if (missingCoverageElements.length > 1) {
nextIndex = currentIndex - 1;
}
makeCurrent(nextIndex);
}
function goToNext() {
var nextIndex = 0;
if (
typeof currentIndex === 'number' &&
currentIndex < missingCoverageElements.length - 1
) {
nextIndex = currentIndex + 1;
}
makeCurrent(nextIndex);
}
return function jump(event) {
if (
document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null
) {
// if we're currently focused on the search input, we don't want to navigate
return;
}
switch (event.which) {
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
}
};
})();
window.addEventListener('keydown', jumpToCode);

View file

@ -0,0 +1,124 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for calculator.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="index.html">All files</a> calculator.js</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>5/5</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>3/3</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>5/5</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
<template id="filterTemplate">
<div class="quiet">
Filter:
<input oninput="onInput()" type="search" id="fileSearch">
</div>
</template>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">const mathOperations = {
sum: function(a, b) {
return a + b
},
diff: function(a, b) {
return a - b
},
product: function(a, b) {
return a * b
}
}
&nbsp;
module.exports = mathOperations
&nbsp;</pre></td></tr></table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2022-07-21T20:31:12.540Z
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

View file

@ -0,0 +1,116 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for All files</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1>All files</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>5/5</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>3/3</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>5/5</span>
</div>
</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
<template id="filterTemplate">
<div class="quiet">
Filter:
<input oninput="onInput()" type="search" id="fileSearch">
</div>
</template>
</div>
<div class='status-line high'></div>
<div class="pad1">
<table class="coverage-summary">
<thead>
<tr>
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
</tr>
</thead>
<tbody><tr>
<td class="file high" data-value="calculator.js"><a href="calculator.js.html">calculator.js</a></td>
<td data-value="100" class="pic high">
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="5" class="abs high">5/5</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="0" class="abs high">0/0</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="3" class="abs high">3/3</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="5" class="abs high">5/5</td>
</tr>
</tbody>
</table>
</div>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2022-07-21T20:31:12.540Z
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="sorter.js"></script>
<script src="block-navigation.js"></script>
</body>
</html>

View file

@ -0,0 +1 @@
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

View file

@ -0,0 +1,196 @@
/* eslint-disable */
var addSorting = (function() {
'use strict';
var cols,
currentSort = {
index: 0,
desc: false
};
// returns the summary table element
function getTable() {
return document.querySelector('.coverage-summary');
}
// returns the thead element of the summary table
function getTableHeader() {
return getTable().querySelector('thead tr');
}
// returns the tbody element of the summary table
function getTableBody() {
return getTable().querySelector('tbody');
}
// returns the th element for nth column
function getNthColumn(n) {
return getTableHeader().querySelectorAll('th')[n];
}
function onFilterInput() {
const searchValue = document.getElementById('fileSearch').value;
const rows = document.getElementsByTagName('tbody')[0].children;
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
if (
row.textContent
.toLowerCase()
.includes(searchValue.toLowerCase())
) {
row.style.display = '';
} else {
row.style.display = 'none';
}
}
}
// loads the search box
function addSearchBox() {
var template = document.getElementById('filterTemplate');
var templateClone = template.content.cloneNode(true);
templateClone.getElementById('fileSearch').oninput = onFilterInput;
template.parentElement.appendChild(templateClone);
}
// loads all columns
function loadColumns() {
var colNodes = getTableHeader().querySelectorAll('th'),
colNode,
cols = [],
col,
i;
for (i = 0; i < colNodes.length; i += 1) {
colNode = colNodes[i];
col = {
key: colNode.getAttribute('data-col'),
sortable: !colNode.getAttribute('data-nosort'),
type: colNode.getAttribute('data-type') || 'string'
};
cols.push(col);
if (col.sortable) {
col.defaultDescSort = col.type === 'number';
colNode.innerHTML =
colNode.innerHTML + '<span class="sorter"></span>';
}
}
return cols;
}
// attaches a data attribute to every tr element with an object
// of data values keyed by column name
function loadRowData(tableRow) {
var tableCols = tableRow.querySelectorAll('td'),
colNode,
col,
data = {},
i,
val;
for (i = 0; i < tableCols.length; i += 1) {
colNode = tableCols[i];
col = cols[i];
val = colNode.getAttribute('data-value');
if (col.type === 'number') {
val = Number(val);
}
data[col.key] = val;
}
return data;
}
// loads all row data
function loadData() {
var rows = getTableBody().querySelectorAll('tr'),
i;
for (i = 0; i < rows.length; i += 1) {
rows[i].data = loadRowData(rows[i]);
}
}
// sorts the table using the data for the ith column
function sortByIndex(index, desc) {
var key = cols[index].key,
sorter = function(a, b) {
a = a.data[key];
b = b.data[key];
return a < b ? -1 : a > b ? 1 : 0;
},
finalSorter = sorter,
tableBody = document.querySelector('.coverage-summary tbody'),
rowNodes = tableBody.querySelectorAll('tr'),
rows = [],
i;
if (desc) {
finalSorter = function(a, b) {
return -1 * sorter(a, b);
};
}
for (i = 0; i < rowNodes.length; i += 1) {
rows.push(rowNodes[i]);
tableBody.removeChild(rowNodes[i]);
}
rows.sort(finalSorter);
for (i = 0; i < rows.length; i += 1) {
tableBody.appendChild(rows[i]);
}
}
// removes sort indicators for current column being sorted
function removeSortIndicators() {
var col = getNthColumn(currentSort.index),
cls = col.className;
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
col.className = cls;
}
// adds sort indicators for current column being sorted
function addSortIndicators() {
getNthColumn(currentSort.index).className += currentSort.desc
? ' sorted-desc'
: ' sorted';
}
// adds event listeners for all sorter widgets
function enableUI() {
var i,
el,
ithSorter = function ithSorter(i) {
var col = cols[i];
return function() {
var desc = col.defaultDescSort;
if (currentSort.index === i) {
desc = !currentSort.desc;
}
sortByIndex(i, desc);
removeSortIndicators();
currentSort.index = i;
currentSort.desc = desc;
addSortIndicators();
};
};
for (i = 0; i < cols.length; i += 1) {
if (cols[i].sortable) {
// add the click event handler on the th so users
// dont have to click on those tiny arrows
el = getNthColumn(i).querySelector('.sorter').parentElement;
if (el.addEventListener) {
el.addEventListener('click', ithSorter(i));
} else {
el.attachEvent('onclick', ithSorter(i));
}
}
}
}
// adds sorting functionality to the UI
return function() {
if (!getTable()) {
return;
}
cols = loadColumns();
loadData();
addSearchBox();
addSortIndicators();
enableUI();
};
})();
window.addEventListener('load', addSorting);

View file

@ -0,0 +1,20 @@
TN:
SF:calculator.js
FN:2,(anonymous_0)
FN:5,(anonymous_1)
FN:8,(anonymous_2)
FNF:3
FNH:3
FNDA:1,(anonymous_0)
FNDA:1,(anonymous_1)
FNDA:1,(anonymous_2)
DA:1,1
DA:3,1
DA:6,1
DA:9,1
DA:13,1
LF:5
LH:5
BRF:0
BRH:0
end_of_record

5998
sandbox/jest/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

15
sandbox/jest/package.json Normal file
View file

@ -0,0 +1,15 @@
{
"name": "testdir",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^28.1.3"
}
}

View file

@ -0,0 +1,22 @@
const mathOperations = require('../calculator')
describe("Calculator tests", () => {
test('adding 1 + 2 should return 3', () => {
// arrange and act
expect(mathOperations.sum(1,2)).toBe(3)
})
test("subtracting 2 from 10 should return 8", () => {
// arrange and act
let result = mathOperations.diff(10,2)
// assert
expect(result).toBe(8)
})
test("multiplying 2 and 8 should return 16", () => {
// arrange and act
let result = mathOperations.product(2,8)
// assert
expect(result).toBe(16)
})
})

1
sandbox/leetcode Submodule

@ -0,0 +1 @@
Subproject commit aa2b295dc2d56bf08721e389513d8ff05ced356b

Binary file not shown.

View file

@ -0,0 +1,42 @@
.TH BGIT 1L 2022-09-29 Info-BGIT
.SH NAME
bgit \- a shell script to simplify the standard git workflow
.SH SYNOPSIS
.B bgit
[\fB\-i\fR]
[\fB\-l\fR]
[\fB\-r\fR]
[\fB\-h\fR]
.SH DESCRIPTION
bgit is a git automation tool written in bash. It is designed to quickly automate away alot of the simple git commands that git beginners use every day. These include commands like git init, git add, git commit -m, and git push. It is a series of simple prompts that make the git workflow seamless and quick to use.
.SH DEFAULTS
by default, and when invoked with no flags/options, bgit will look for all files that have been added, modified, or deleted since the last commit. bgit will then present a series of prompts to add, commit, and push these changes to the remote repository/respotories. bgit will not ask for a password by default for an hour after the first commit using bgit (not applicable to ssh or gpg verification).
.SH OPTIONS
.TP
.BR \-i
initialize a new repository in current directory
.TP
.BR \-l
display previous commit log messages
.TP
.BR \-r
revert back to a previous commit
.TP
.BR \-h
display a help message on basic usage
.SH FILES
.TP
.I ~/.config/bgit
all configuration files can be found here.
.SH AUTHOR
z3rOR0ne <z3rOR0ne@protonmail.com>
.SH SEE ALSO
\fBgit\fR

View file

@ -0,0 +1,40 @@
./" this is a comment
./" most of your manpages can be found at /usr/share/man/man1 and should be put there once completed
./" either by install script or manually
./" additionally, most manpages are converted to gz and in this case are appended with the 1 to the filename like so:
./" cpufreq.1.gz
.TH CPUFREQ 1 2020-02-16 GNU
.SH NAME
cpufreq \- cpu frequencies
.SH SYNOPSIS
.B cpufreq
[\fB\-h\fR]
[\fB\-?\fR]
[\fB\-\-help\fR]
[\fB\-v\fR]
[\fB\-h\-version\fR]
[\fB\-d\fR \fIpath\fR]
.SH DESCRIPTION
.TP
.BR \-h ", " \-? ", " \-\-help
displlays this help information.
.TP
.BR \-v ", " \-\-version
outputs only the version datestamp
.TP
.BR \-d ", " \-\-dir " " \fIpath
outputs only the version datestamp
.SH FILES
.TP
.I /proc/cpuinfo
.SH AUTHOR
terminalforlife <terminalforlilfe@yahoo.com>
.SH SEE ALSO
\fBperl\fR(1perl)

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,7 @@
---
title: My Document
date: September 22, 2020
---
## Test
some text

View file

@ -0,0 +1,11 @@
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=date content=''>
<title>$title$</title>
</head>
<body>
<p>$date$</p>
</body>
</html>

1413
sandbox/mocha/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
{
"name": "mocha",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"mocha": "^10.0.0"
}
}

View file

@ -0,0 +1,8 @@
var assert = require('assert')
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal([1, 2, 3].indexOf(4), -1)
})
})
})

View file

@ -0,0 +1,6 @@
const arr = [0, 1, 2 ,3]
const arr2 = [1, 2, 3 ,4]
Object.keys(arr).forEach(key => console.log(`key >>: ${key}`))
Object.keys(arr2).forEach(key => console.log(`arr2[key] >>: ${arr2[key]}`))
Object.values(arr2).forEach(val => console.log(`val >>: ${val}`))

View file

@ -0,0 +1,31 @@
const iterable = [10, 20, 30]
const iterableTwo = { one: 10, two: 'hi', three: [10, 20, 30]}
const iterateOverArr = (arr) => {
for (const [key, value] of Object.entries(arr)) {
console.log(`key of Arr: ${key}`, `value of Arr: ${value}`)
}
}
const iterateOverObj = (obj) => {
for (const [key, value] of Object.entries(obj)) {
console.log(`key of Obj: ${key}`, `value of obj: ${value}`)
}
}
const callIterable = (data) => {
if (Array.isArray(data)) {
iterateOverArr(data)
} else if (typeof data === 'object'){
iterateOverObj(data)
} else {
const type = typeof data
console.log(`${data} is not an array or object`)
console.log(`${data} is a ${type}`)
}
}
callIterable(iterable)
callIterable(iterableTwo)
callIterable('test')
callIterable(5)

32
sandbox/open.c Normal file
View file

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char const *argv[]) {
(void)argc;
(void)argv;
int fd;
char buff[1000];
printf("Enter a file you wish to open: \n");
scanf("%s", buff);
if ((fd = open(buff, O_RDONLY)) == -1) {
printf("file opening failed\n");
exit(0);
} else {
printf("file opening successful\n");
printf("file descriptor: %d\n", fd);
}
if (read(fd, buff, sizeof(buff)) == -1) {
printf("Error while reading file\n");
exit(0);
} else {
printf("wrote %lu bytes to the file\n", strlen(buff));
printf("File contents: %s\n", buff);
}
}

24
sandbox/open2.c Normal file
View file

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE * fptr;
char c;
// Open file
fptr = fopen("file.txt", "r");
if (fptr == NULL) {
printf("Cannot open file \n");
exit(0);
}
// Read contents form file
c = fgetc(fptr);
while (c != EOF) {
printf("%c", c);
c = fgetc(fptr);
}
fclose(fptr);
return 0;
}

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Prism Test</title>
<link rel="stylesheet" href="./themes/prism_okaidia.css">
</head>
<body>
<pre><code class="language-js">console.log('hello')</code></pre>
<script src="./prism_js/prism_okaidia.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,139 @@
/* PrismJS 1.28.0
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+abap+abnf+actionscript+ada+agda+al+antlr4+apacheconf+apex+apl+applescript+aql+arduino+arff+armasm+arturo+asciidoc+aspnet+asm6502+asmatmel+autohotkey+autoit+avisynth+avro-idl+awk+bash+basic+batch+bbcode+bicep+birb+bison+bnf+brainfuck+brightscript+bro+bsl+c+csharp+cpp+cfscript+chaiscript+cil+clojure+cmake+cobol+coffeescript+concurnas+csp+cooklang+coq+crystal+css-extras+csv+cue+cypher+d+dart+dataweave+dax+dhall+diff+django+dns-zone-file+docker+dot+ebnf+editorconfig+eiffel+ejs+elixir+elm+etlua+erb+erlang+excel-formula+fsharp+factor+false+firestore-security-rules+flow+fortran+ftl+gml+gap+gcode+gdscript+gedcom+gettext+gherkin+git+glsl+gn+linker-script+go+go-module+gradle+graphql+groovy+haml+handlebars+haskell+haxe+hcl+hlsl+hoon+http+hpkp+hsts+ichigojam+icon+icu-message-format+idris+ignore+inform7+ini+io+j+java+javadoc+javadoclike+javastacktrace+jexl+jolie+jq+jsdoc+js-extras+json+json5+jsonp+jsstacktrace+js-templates+julia+keepalived+keyman+kotlin+kumir+kusto+latex+latte+less+lilypond+liquid+lisp+livescript+llvm+log+lolcode+lua+magma+makefile+markdown+markup-templating+mata+matlab+maxscript+mel+mermaid+metafont+mizar+mongodb+monkey+moonscript+n1ql+n4js+nand2tetris-hdl+naniscript+nasm+neon+nevod+nginx+nim+nix+nsis+objectivec+ocaml+odin+opencl+openqasm+oz+parigp+parser+pascal+pascaligo+psl+pcaxis+peoplecode+perl+php+phpdoc+php-extras+plant-uml+plsql+powerquery+powershell+processing+prolog+promql+properties+protobuf+pug+puppet+pure+purebasic+purescript+python+qsharp+q+qml+qore+r+racket+cshtml+jsx+tsx+reason+regex+rego+renpy+rescript+rest+rip+roboconf+robotframework+ruby+rust+sas+sass+scss+scala+scheme+shell-session+smali+smalltalk+smarty+sml+solidity+solution-file+soy+sparql+splunk-spl+sqf+sql+squirrel+stan+stata+iecst+stylus+supercollider+swift+systemd+t4-templating+t4-cs+t4-vb+tap+tcl+tt2+textile+toml+tremor+turtle+twig+typescript+typoscript+unrealscript+uorazor+uri+v+vala+vbnet+velocity+verilog+vhdl+vim+visual-basic+warpscript+wasm+web-idl+wgsl+wiki+wolfram+wren+xeora+xml-doc+xojo+xquery+yaml+yang+zig */
/**
* okaidia theme for JavaScript, CSS and HTML
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
* @author ocodia
*/
code[class*="language-"],
pre[class*="language-"] {
color: #f8f8f2;
background: none;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
/* font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; */
font-family: monospace;
font-size: 1.1em;
font-weight: 500;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
background-color: #252525;
border-radius: 0.3em;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] { background: #272822;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #8292a2;
background-color: #252525;
}
.token.punctuation {
color: #f8f8f2;
background-color: #252525;
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
color: #f92672;
background-color: #252525;
}
.token.boolean,
.token.number {
color: #ae81ff;
background-color: #252525;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #a6e22e;
background-color: #252525;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
color: #f8f8f2;
background-color: #252525;
}
.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
color: #e6db74;
background-color: #252525;
}
.token.keyword {
color: #66d9ef;
background-color: #252525;
}
.token.regex,
.token.important {
color: #fd971f;
background-color: #252525;
}
.token.important,
.token.bold {
font-weight: bold;
background-color: #252525;
}
.token.italic {
font-style: italic;
background-color: #252525;
}
.token.entity {
cursor: help;
}

View file

@ -0,0 +1,154 @@
/* PrismJS 1.28.0
https://prismjs.com/download.html#themes=prism-solarizedlight&languages=markup+css+clike+javascript+abap+abnf+actionscript+ada+agda+al+antlr4+apacheconf+apex+apl+applescript+aql+arduino+arff+armasm+arturo+asciidoc+aspnet+asm6502+asmatmel+autohotkey+autoit+avisynth+avro-idl+awk+bash+basic+batch+bbcode+bicep+birb+bison+bnf+brainfuck+brightscript+bro+bsl+c+csharp+cpp+cfscript+chaiscript+cil+clojure+cmake+cobol+coffeescript+concurnas+csp+cooklang+coq+crystal+css-extras+csv+cue+cypher+d+dart+dataweave+dax+dhall+diff+django+dns-zone-file+docker+dot+ebnf+editorconfig+eiffel+ejs+elixir+elm+etlua+erb+erlang+excel-formula+fsharp+factor+false+firestore-security-rules+flow+fortran+ftl+gml+gap+gcode+gdscript+gedcom+gettext+gherkin+git+glsl+gn+linker-script+go+go-module+gradle+graphql+groovy+haml+handlebars+haskell+haxe+hcl+hlsl+hoon+http+hpkp+hsts+ichigojam+icon+icu-message-format+idris+ignore+inform7+ini+io+j+java+javadoc+javadoclike+javastacktrace+jexl+jolie+jq+jsdoc+js-extras+json+json5+jsonp+jsstacktrace+js-templates+julia+keepalived+keyman+kotlin+kumir+kusto+latex+latte+less+lilypond+liquid+lisp+livescript+llvm+log+lolcode+lua+magma+makefile+markdown+markup-templating+mata+matlab+maxscript+mel+mermaid+metafont+mizar+mongodb+monkey+moonscript+n1ql+n4js+nand2tetris-hdl+naniscript+nasm+neon+nevod+nginx+nim+nix+nsis+objectivec+ocaml+odin+opencl+openqasm+oz+parigp+parser+pascal+pascaligo+psl+pcaxis+peoplecode+perl+php+phpdoc+php-extras+plant-uml+plsql+powerquery+powershell+processing+prolog+promql+properties+protobuf+pug+puppet+pure+purebasic+purescript+python+qsharp+q+qml+qore+r+racket+cshtml+jsx+tsx+reason+regex+rego+renpy+rescript+rest+rip+roboconf+robotframework+ruby+rust+sas+sass+scss+scala+scheme+shell-session+smali+smalltalk+smarty+sml+solidity+solution-file+soy+sparql+splunk-spl+sqf+sql+squirrel+stan+stata+iecst+stylus+supercollider+swift+systemd+t4-templating+t4-cs+t4-vb+tap+tcl+tt2+textile+toml+tremor+turtle+twig+typescript+typoscript+unrealscript+uorazor+uri+v+vala+vbnet+velocity+verilog+vhdl+vim+visual-basic+warpscript+wasm+web-idl+wgsl+wiki+wolfram+wren+xeora+xml-doc+xojo+xquery+yaml+yang+zig */ /*
Solarized Color Schemes originally by Ethan Schoonover
http://ethanschoonover.com/solarized
Ported for PrismJS by Hector Matos
Website: https://krakendev.io
Twitter Handle: https://twitter.com/allonsykraken)
*/
/*
SOLARIZED HEX
--------- -------
base03 #002b36
base02 #073642
base01 #586e75
base00 #657b83
base0 #839496
base1 #93a1a1
base2 #eee8d5
base3 #fdf6e3
yellow #b58900
orange #cb4b16
red #dc322f
magenta #d33682
violet #6c71c4
blue #268bd2
cyan #2aa198
green #859900
*/
code[class*="language-"],
pre[class*="language-"] {
color: #657b83; /* base00 */
/* font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; */
font-family: monospace;
font-weight: 900;
font-size: 1.1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
background: #073642; /* base02 */
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
background: #073642; /* base02 */
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background-color: #fdf6e3; /* base3 */
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #93a1a1; /* base1 */
}
.token.punctuation {
color: #586e75; /* base01 */
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #268bd2; /* blue */
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.url,
.token.inserted {
color: #2aa198; /* cyan */
}
.token.entity {
color: #657b83; /* base00 */
background: #eee8d5; /* base2 */
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #859900; /* green */
}
.token.function,
.token.class-name {
color: #b58900; /* yellow */
}
.token.regex,
.token.important,
.token.variable {
color: #cb4b16; /* orange */
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}

View file

@ -0,0 +1,2 @@
const indexes = [...Array(50).keys()]
console.log(`indexes >>: ${indexes}`)

22
sandbox/reverse_string.c Normal file
View file

@ -0,0 +1,22 @@
/* https://www.w3schools.in/c-programming/examples/reverse-a-string-in-c */
#include <stdio.h>
#include <string.h>
int main(void) {
char mystrg[60];
int leng, g;
printf("Program in C for reversing a given string\n");
printf("Please isnert the string you want to reverse: ");
scanf("%s", mystrg);
leng = strlen(mystrg);
/* goes through the mystrg[] array backwards */
for(g = leng - 1; g >= 0; g--) {
printf("%c", mystrg[g]);
}
printf("\n");
return 0;
}

30
sandbox/reverse_string2.c Normal file
View file

@ -0,0 +1,30 @@
/* https://www.w3schools.in/c-programming/examples/reverse-a-string-in-c */
#include <stdio.h>
void revAString(char strg[]) {
int g, numb;
int tmpry = 0;
// grabs the length of the given string
for(numb = 0; strg[numb] != 0; numb++);
printf("numb(string length) = %d\n", numb);
for(g = 0; g < numb / 2; g++) {
tmpry = strg[g];
printf("tmpry = %c\n", tmpry);
strg[g] = strg[numb - 1 - g];
printf("strg[g] = %c\n", strg[g]);
strg[numb - 1 - g] = tmpry;
printf("strg[numb - 1 - g] = %c\n", strg[numb - 1 - g]);
}
for (g = 0; g < numb; g++)
putchar(strg[g]);
printf("\n");
}
int main(void) {
char strg[60];
printf("Please insert the string you wish to get reversed: ");
scanf("%s", strg);
revAString(strg);
return 0;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,342 @@
(function () {
var canvas = document.getElementById("vines");
var context = canvas.getContext("2d");
var canvasb = document.getElementById("leaves");
var contextb = canvasb.getContext("2d");
var leaves = [];
// Resize canvas
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvasb.width = window.innerWidth;
canvasb.height = window.innerHeight;
// Clear canvas
context.fillStyle = "#89f1d7";
context.fillRect(0, 0, canvas.width, canvas.height);
// Calculate distance from point to line
function distancePointToLine(point, line) {
var L = Math.sqrt(
Math.pow(line[1].x - line[0].x, 2) + Math.pow(line[1].y - line[0].y, 2)
);
var r =
((point.x - line[0].x) * (line[1].x - line[0].x) +
(point.y - line[0].y) * (line[1].y - line[0].y)) /
Math.pow(L, 2);
var s =
((line[0].y - point.y) * (line[1].x - line[0].x) -
(line[0].x - point.x) * (line[1].y - line[0].y)) /
Math.pow(L, 2);
if (r >= 0 && r <= 1) {
return Math.abs(s) * L;
} else {
return Math.min(
Math.sqrt(
Math.pow(point.x - line[0].x, 2) + Math.pow(point.y - line[0].y, 2)
),
Math.sqrt(
Math.pow(point.x - line[1].x, 2) + Math.pow(point.y - line[1].y, 2)
)
);
}
}
// Draw leaf
function drawLeaf(leaf) {
leaf.size = Math.max(10, leaf.size);
contextb.save();
contextb.translate(leaf.x, leaf.y);
contextb.rotate(leaf.angle);
contextb.translate(-leaf.x, -leaf.y);
contextb.fillStyle = "#ff0078";
contextb.beginPath();
contextb.moveTo(leaf.x, leaf.y);
contextb.bezierCurveTo(
leaf.x + leaf.size,
leaf.y,
leaf.x + leaf.size * 2,
leaf.y + leaf.size,
leaf.x,
leaf.y + leaf.size * 4
);
contextb.bezierCurveTo(
leaf.x - leaf.size * 2,
leaf.y + leaf.size,
leaf.x - leaf.size,
leaf.y,
leaf.x,
leaf.y
);
contextb.closePath();
contextb.fill();
contextb.restore();
}
// Draw vine
function drawVinesWithLattice(
lattice,
seeds,
interations,
sort,
prune,
minLength,
maxLength
) {
var t = 1;
var maxLineWidth = 10;
// Create initial branches
var branches = [];
for (var i in seeds) {
branches.push({
points: [
{ x: seeds[i].x, y: seeds[i].y },
{ x: seeds[i].x, y: seeds[i].y },
{ x: seeds[i].x, y: seeds[i].y },
{ x: seeds[i].x, y: seeds[i].y },
],
angle: 0,
distanceToLattice: 1000,
lineWidth: 6,
active: true,
leaf: false,
});
}
// Animation function
function tick() {
// Draw branches
contextb.clearRect(0, 0, canvasb.width, canvasb.height);
for (var i in branches) {
var ax =
(-branches[i].points[0].x +
3 * branches[i].points[1].x -
3 * branches[i].points[2].x +
branches[i].points[3].x) /
6;
var ay =
(-branches[i].points[0].y +
3 * branches[i].points[1].y -
3 * branches[i].points[2].y +
branches[i].points[3].y) /
6;
var bx =
(branches[i].points[0].x -
2 * branches[i].points[1].x +
branches[i].points[2].x) /
2;
var by =
(branches[i].points[0].y -
2 * branches[i].points[1].y +
branches[i].points[2].y) /
2;
var cx = (-branches[i].points[0].x + branches[i].points[2].x) / 2;
var cy = (-branches[i].points[0].y + branches[i].points[2].y) / 2;
var dx =
(branches[i].points[0].x +
4 * branches[i].points[1].x +
branches[i].points[2].x) /
6;
var dy =
(branches[i].points[0].y +
4 * branches[i].points[1].y +
branches[i].points[2].y) /
6;
context.lineWidth = branches[i].lineWidth;
context.beginPath();
context.moveTo(
ax * Math.pow(t, 3) + bx * Math.pow(t, 2) + cx * t + dx,
ay * Math.pow(t, 3) + by * Math.pow(t, 2) + cy * t + dy
);
context.lineTo(
ax * Math.pow(t + 0.1, 3) +
bx * Math.pow(t + 0.1, 2) +
cx * (t + 0.1) +
dx,
ay * Math.pow(t + 0.1, 3) +
by * Math.pow(t + 0.1, 2) +
cy * (t + 0.1) +
dy
);
context.stroke();
context.closePath();
// Draw leaf
if (branches[i].leaf) {
if (branches[i].active) {
var x1 = ax * Math.pow(t, 3) + bx * Math.pow(t, 2) + cx * t + dx;
var y1 = ay * Math.pow(t, 3) + by * Math.pow(t, 2) + cy * t + dy;
var x2 =
ax * Math.pow(t + 0.1, 3) +
bx * Math.pow(t + 0.1, 2) +
cx * (t + 0.1) +
dx;
var y2 =
ay * Math.pow(t + 0.1, 3) +
by * Math.pow(t + 0.1, 2) +
cy * (t + 0.1) +
dy;
branches[i].leaf.x = x2;
branches[i].leaf.y = y2;
branches[i].leaf.angle = Math.atan2(y2 - y1, x2 - x1) - Math.PI / 2;
branches[i].leaf.size = branches[i].lineWidth * 2;
} else {
branches[i].leaf.size = (branches[i].lineWidth + t) * 2;
}
drawLeaf(branches[i].leaf);
}
}
// Draw leaves
for (var i in leaves) {
drawLeaf(leaves[i]);
}
// When finished drawing splines, create a new set of branches
t += 0.02;
if (t >= 1) {
var new_branches = [];
for (var j = branches.length - 1; j >= 0; j--) {
if (branches[j].active) {
// Split branch into two
for (var k = 0; k < 2; k++) {
// Generate random deviation from previous angle
var angle = branches[j].angle - (Math.random() * 180 - 90);
// Determine closest lattice point
var distance = 100000;
for (var l in lattice) {
var result = distancePointToLine(
branches[j].points[3],
lattice[l]
);
if (result < distance) distance = result;
}
// Generate random length
var length = Math.random() * (maxLength - minLength) + minLength;
// Calculate new point
var x2 =
branches[j].points[3].x +
Math.sin((Math.PI * angle) / 180) * length;
var y2 =
branches[j].points[3].y -
Math.cos((Math.PI * angle) / 180) * length;
// Add to new branch array
new_branches.push({
points: [
branches[j].points[1],
branches[j].points[2],
branches[j].points[3],
{ x: x2, y: y2 },
],
angle: angle,
distanceToLattice: distance,
lineWidth: 6,
active: true,
leaf: {
x: x2,
y: y2,
angle: 0,
},
parent: branches[j],
});
// "Deactivate" branch
branches[j].active = false;
}
// Grow branch
} else {
branches[j].lineWidth++;
if (branches[j].lineWidth > maxLineWidth) {
leaves.push(branches[j].leaf);
branches.splice(j, 1);
}
}
}
// Sort branches by distance to lattice
new_branches.sort(function (a, b) {
return a.distanceToLattice - b.distanceToLattice;
});
// If over 10 branches, prune the branches furthest from the lattice
if (prune) {
if (sort) {
while (new_branches.length > 20) new_branches.pop();
} else {
while (new_branches.length > 20) {
new_branches.splice(
Math.floor(Math.random() * new_branches.length),
1
);
}
}
}
// Remove leaves from parent
for (var i = 0; i < new_branches.length; i++) {
new_branches[i].parent.leaf = false;
}
// Replace old branch array with new
branches = branches.concat(new_branches);
interations--;
t = 0;
}
// Keep on animating
if (interations > 0) {
requestAnimationFrame(tick);
}
}
tick();
}
// Setup lattice
var space = canvas.height / 3;
var lattice = [];
for (var y = -space * 4; y < space * 4; y += space) {
lattice.push([
{ x: 0, y: y + canvas.height },
{ x: canvas.width, y: y },
]);
}
// Draw lattice
context.strokeStyle = "rgba(0, 0, 0, 0.1)";
context.lineWidth = canvas.height * 0.05;
context.lineCap = "square";
for (var i in lattice) {
context.beginPath();
context.moveTo(lattice[i][0].x, lattice[i][0].y);
context.lineTo(lattice[i][1].x, lattice[i][1].y);
context.stroke();
}
context.strokeStyle = "#ff0078";
// Create vines
var minLength = canvas.width * 0.05;
var maxLength = canvas.width * 0.1;
var iterations = 20;
var seeds = [
{ x: -5, y: space },
{ x: space, y: -5 },
{ x: -5, y: space * 3 },
{ x: canvas.width + 5, y: space },
{ x: space * 3, y: canvas.height + 5 },
];
drawVinesWithLattice(
lattice,
seeds,
iterations,
true,
true,
minLength,
maxLength
);
})();

View file

@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content="" />
<link rel="stylesheet" href="app.css" />
<title>Simulating Vines</title>
</head>
<body>
<div
id="app"
v-bind:class="{ 'search--open': searchTerm, 'index--open': showIndex }"
>
<header class="header header--hero">
<div class="header__navbar"> <a class="header__logo" href="/">Maissan Inc.</a>
<div class="header__search">
<input v-model="searchTerm" placeholder="search" />
</div>
<nav class="header__nav">
<a class="index-button" href="#index" @click.prevent="toggleIndex">
<span class="index-button__label">Index</span>
<i @click.stop="closeAll" class="close-button"></i>
</a>
</nav>
</div>
<div class="hero">
<canvas id="vines"></canvas>
<canvas id="leaves"></canvas>
<h1>Simulating Vines</h1>
</div>
</header>
<div class="search">
<div class="search__spinner" v-if="loading">
<div class="spinner"></div>
</div>
<div
class="search__no-results"
v-if="!loading && searchResults.length == 0"
>
<span>No Results</span>
</div>
<div v-for="result in searchResults" class="search__result">
<h2>{{ result.title }}</h2>
<p v-html="result.snippet"></p>
</div>
</div>
<div class="index">
<div class="index__tags">
<h1>Tags</h1>
<div class="index__columns">
<h2>Bluetooth</h2>
<ul class="index__list">
<li class="index__list__item">
<a href="https://maissan.net/articles/dash-and-dot"
>Controlling Dash &amp; Dot</a
>
</li>
</ul>
<h2>Drupal</h2>
<ul class="index__list">
<li class="index__list__item">
<a
href="https://maissan.net/articles/deploying-drupal-updates-with-gulp"
>Deploying Drupal Updates with Gulp</a
>
</li>
</ul>
<h2>Graphics</h2>
<ul class="index__list">
<li class="index__list__item">
<a href="https://maissan.net/articles/javascript-spirograph"
>JavaScript Spirograph</a
>
</li>
<li class="index__list__item">
<a href="https://maissan.net/articles/simulating-vines"
>Simulating Vines</a
>
</li>
</ul>
<h2>JavaScript</h2>
<ul class="index__list">
<li class="index__list__item">
<a href="https://maissan.net/articles/javascript-spirograph"
>JavaScript Spirograph</a
>
</li>
<li class="index__list__item">
<a href="https://maissan.net/articles/simulating-vines"
>Simulating Vines</a
>
</li>
<li class="index__list__item">
<a href="https://maissan.net/articles/dash-and-dot"
>Controlling Dash &amp; Dot</a
>
</li>
</ul>
<h2>PHP</h2>
<ul class="index__list">
<li class="index__list__item">
<a href="https://maissan.net/articles/php-profiling"
>Application Profiling with PHP</a
>
</li>
</ul>
</div>
</div>
<div class="index__keywords">
<h1>Keywords</h1>
<ul class="index__list index__columns">
<li class="index__list__item">
Await
<a href="https://maissan.net/articles/dash-and-dot#await">1</a>
</li>
<li class="index__list__item">
B-Splines
<a href="https://maissan.net/articles/simulating-vines#b-splines"
>1</a
>
</li>
<li class="index__list__item">
Bezier
<a href="https://maissan.net/articles/simulating-vines#bezier"
>1</a
>
</li>
<li class="index__list__item">
Binary
<a href="https://maissan.net/articles/dash-and-dot#binary">1</a>
</li>
<li class="index__list__item">
Bluetooth
<a href="https://maissan.net/articles/dash-and-dot#bluetooth"
>1</a
>
</li>
<li class="index__list__item">
Canvas
<a
href="https://maissan.net/articles/javascript-spirograph#canvas"
>1</a
>
<a href="https://maissan.net/articles/simulating-vines#canvas"
>2</a
>
</li>
<li class="index__list__item">
Curves
<a href="https://maissan.net/articles/simulating-vines#curves"
>1</a
>
</li>
<li class="index__list__item">
Drupal
<a
href="https://maissan.net/articles/deploying-drupal-updates-with-gulp#drupal"
>1</a
>
</li>
<li class="index__list__item">
Gulp
<a
href="https://maissan.net/articles/deploying-drupal-updates-with-gulp#gulp"
>1</a
>
</li>
<li class="index__list__item">
JavaScript
<a
href="https://maissan.net/articles/javascript-spirograph#javascript"
>1</a
>
<a href="https://maissan.net/articles/simulating-vines#javascript"
>2</a
>
<a href="https://maissan.net/articles/dash-and-dot#javascript"
>3</a
>
</li>
<li class="index__list__item">
PHP
<a href="https://maissan.net/articles/php-profiling#php">1</a>
</li>
<li class="index__list__item">
Promises
<a href="https://maissan.net/articles/dash-and-dot#promises">1</a>
</li>
<li class="index__list__item">
Xdebug
<a href="https://maissan.net/articles/php-profiling#xdebug">1</a>
</li>
</ul>
</div>
</div>
</div>
<script src="app.js"></script>
<script src="app2.js"></script>
</body>
</html>

View file

@ -0,0 +1 @@
https://maissan.net/articles/simulating-vines

13
sandbox/sprintf.c Normal file
View file

@ -0,0 +1,13 @@
/* https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm */
#include <stdio.h>
#include <math.h>
int main() {
char str[80];
sprintf(str, "Value of Pi = %f", M_PI);
puts(str);
return(0);
}

View file

@ -0,0 +1,348 @@
<!DOCTYPE html>
<html>
<body>
<div id="myDiv">
&lt;!DOCTYPE html&gt;<br>
&lt;html&gt;<br>
&lt;body&gt;<br>
<br>
&lt;h1&gt;Testing an HTML Syntax Highlighter&lt;/h2&gt;<br>
&lt;p&gt;Hello world!&lt;/p&gt;<br>
&lt;a href="https://www.w3schools.com"&gt;Back to School&lt;/a&gt;<br>
<br>
&lt;/body&gt;<br>
&lt;/html&gt;
</div>
<script>
w3CodeColor(document.getElementById("myDiv"));
function w3CodeColor(elmnt, mode) {
var lang = (mode || "html");
var elmntObj = (document.getElementById(elmnt) || elmnt);
var elmntTxt = elmntObj.innerHTML;
var tagcolor = "mediumblue";
var tagnamecolor = "brown";
var attributecolor = "red";
var attributevaluecolor = "mediumblue";
var commentcolor = "green";
var cssselectorcolor = "brown";
var csspropertycolor = "red";
var csspropertyvaluecolor = "mediumblue";
var cssdelimitercolor = "black";
var cssimportantcolor = "red";
var jscolor = "black";
var jskeywordcolor = "mediumblue";
var jsstringcolor = "brown";
var jsnumbercolor = "red";
var jspropertycolor = "black";
elmntObj.style.fontFamily = "Consolas,'Courier New', monospace";
if (!lang) {lang = "html"; }
if (lang == "html") {elmntTxt = htmlMode(elmntTxt);}
if (lang == "css") {elmntTxt = cssMode(elmntTxt);}
if (lang == "js") {elmntTxt = jsMode(elmntTxt);}
elmntObj.innerHTML = elmntTxt;
function extract(str, start, end, func, repl) {
var s, e, d = "", a = [];
while (str.search(start) > -1) {
s = str.search(start);
e = str.indexOf(end, s);
if (e == -1) {e = str.length;}
if (repl) {
a.push(func(str.substring(s, e + (end.length))));
str = str.substring(0, s) + repl + str.substr(e + (end.length));
} else {
d += str.substring(0, s);
d += func(str.substring(s, e + (end.length)));
str = str.substr(e + (end.length));
}
}
this.rest = d + str;
this.arr = a;
}
function htmlMode(txt) {
var rest = txt, done = "", php, comment, angular, startpos, endpos, note, i;
comment = new extract(rest, "&lt;!--", "--&gt;", commentMode, "W3HTMLCOMMENTPOS");
rest = comment.rest;
while (rest.indexOf("&lt;") > -1) {
note = "";
startpos = rest.indexOf("&lt;");
if (rest.substr(startpos, 9).toUpperCase() == "&LT;STYLE") {note = "css";}
if (rest.substr(startpos, 10).toUpperCase() == "&LT;SCRIPT") {note = "javascript";}
endpos = rest.indexOf("&gt;", startpos);
if (endpos == -1) {endpos = rest.length;}
done += rest.substring(0, startpos);
done += tagMode(rest.substring(startpos, endpos + 4));
rest = rest.substr(endpos + 4);
if (note == "css") {
endpos = rest.indexOf("&lt;/style&gt;");
if (endpos > -1) {
done += cssMode(rest.substring(0, endpos));
rest = rest.substr(endpos);
}
}
if (note == "javascript") {
endpos = rest.indexOf("&lt;/script&gt;");
if (endpos > -1) {
done += jsMode(rest.substring(0, endpos));
rest = rest.substr(endpos);
}
}
}
rest = done + rest;
for (i = 0; i < comment.arr.length; i++) {
rest = rest.replace("W3HTMLCOMMENTPOS", comment.arr[i]);
}
return rest;
}
function tagMode(txt) {
var rest = txt, done = "", startpos, endpos, result;
while (rest.search(/(\s|<br>)/) > -1) {
startpos = rest.search(/(\s|<br>)/);
endpos = rest.indexOf("&gt;");
if (endpos == -1) {endpos = rest.length;}
done += rest.substring(0, startpos);
done += attributeMode(rest.substring(startpos, endpos));
rest = rest.substr(endpos);
}
result = done + rest;
result = "<span style=color:" + tagcolor + ">&lt;</span>" + result.substring(4);
if (result.substr(result.length - 4, 4) == "&gt;") {
result = result.substring(0, result.length - 4) + "<span style=color:" + tagcolor + ">&gt;</span>";
}
return "<span style=color:" + tagnamecolor + ">" + result + "</span>";
}
function attributeMode(txt) {
var rest = txt, done = "", startpos, endpos, singlefnuttpos, doublefnuttpos, spacepos;
while (rest.indexOf("=") > -1) {
endpos = -1;
startpos = rest.indexOf("=");
singlefnuttpos = rest.indexOf("'", startpos);
doublefnuttpos = rest.indexOf('"', startpos);
spacepos = rest.indexOf(" ", startpos + 2);
if (spacepos > -1 && (spacepos < singlefnuttpos || singlefnuttpos == -1) && (spacepos < doublefnuttpos || doublefnuttpos == -1)) {
endpos = rest.indexOf(" ", startpos);
} else if (doublefnuttpos > -1 && (doublefnuttpos < singlefnuttpos || singlefnuttpos == -1) && (doublefnuttpos < spacepos || spacepos == -1)) {
endpos = rest.indexOf('"', rest.indexOf('"', startpos) + 1);
} else if (singlefnuttpos > -1 && (singlefnuttpos < doublefnuttpos || doublefnuttpos == -1) && (singlefnuttpos < spacepos || spacepos == -1)) {
endpos = rest.indexOf("'", rest.indexOf("'", startpos) + 1);
}
if (!endpos || endpos == -1 || endpos < startpos) {endpos = rest.length;}
done += rest.substring(0, startpos);
done += attributeValueMode(rest.substring(startpos, endpos + 1));
rest = rest.substr(endpos + 1);
}
return "<span style=color:" + attributecolor + ">" + done + rest + "</span>";
}
function attributeValueMode(txt) {
return "<span style=color:" + attributevaluecolor + ">" + txt + "</span>";
}
function commentMode(txt) {
return "<span style=color:" + commentcolor + ">" + txt + "</span>";
}
function cssMode(txt) {
var rest = txt, done = "", s, e, comment, i, midz, c, cc;
comment = new extract(rest, /\/\*/, "*/", commentMode, "W3CSSCOMMENTPOS");
rest = comment.rest;
while (rest.search("{") > -1) {
s = rest.search("{");
midz = rest.substr(s + 1);
cc = 1;
c = 0;
for (i = 0; i < midz.length; i++) {
if (midz.substr(i, 1) == "{") {cc++; c++}
if (midz.substr(i, 1) == "}") {cc--;}
if (cc == 0) {break;}
}
if (cc != 0) {c = 0;}
e = s;
for (i = 0; i <= c; i++) {
e = rest.indexOf("}", e + 1);
}
if (e == -1) {e = rest.length;}
done += rest.substring(0, s + 1);
done += cssPropertyMode(rest.substring(s + 1, e));
rest = rest.substr(e);
}
rest = done + rest;
rest = rest.replace(/{/g, "<span style=color:" + cssdelimitercolor + ">{</span>");
rest = rest.replace(/}/g, "<span style=color:" + cssdelimitercolor + ">}</span>");
for (i = 0; i < comment.arr.length; i++) {
rest = rest.replace("W3CSSCOMMENTPOS", comment.arr[i]);
}
return "<span style=color:" + cssselectorcolor + ">" + rest + "</span>";
}
function cssPropertyMode(txt) {
var rest = txt, done = "", s, e, n, loop;
if (rest.indexOf("{") > -1 ) { return cssMode(rest); }
while (rest.search(":") > -1) {
s = rest.search(":");
loop = true;
n = s;
while (loop == true) {
loop = false;
e = rest.indexOf(";", n);
if (rest.substring(e - 5, e + 1) == "&nbsp;") {
loop = true;
n = e + 1;
}
}
if (e == -1) {e = rest.length;}
done += rest.substring(0, s);
done += cssPropertyValueMode(rest.substring(s, e + 1));
rest = rest.substr(e + 1);
}
return "<span style=color:" + csspropertycolor + ">" + done + rest + "</span>";
}
function cssPropertyValueMode(txt) {
var rest = txt, done = "", s;
rest = "<span style=color:" + cssdelimitercolor + ">:</span>" + rest.substring(1);
while (rest.search(/!important/i) > -1) {
s = rest.search(/!important/i);
done += rest.substring(0, s);
done += cssImportantMode(rest.substring(s, s + 10));
rest = rest.substr(s + 10);
}
result = done + rest;
if (result.substr(result.length - 1, 1) == ";" && result.substr(result.length - 6, 6) != "&nbsp;" && result.substr(result.length - 4, 4) != "&lt;" && result.substr(result.length - 4, 4) != "&gt;" && result.substr(result.length - 5, 5) != "&amp;") {
result = result.substring(0, result.length - 1) + "<span style=color:" + cssdelimitercolor + ">;</span>";
}
return "<span style=color:" + csspropertyvaluecolor + ">" + result + "</span>";
}
function cssImportantMode(txt) {
return "<span style=color:" + cssimportantcolor + ";font-weight:bold;>" + txt + "</span>";
}
function jsMode(txt) {
var rest = txt, done = "", esc = [], i, cc, tt = "", sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, numpos, mypos, dotpos, y;
for (i = 0; i < rest.length; i++) {
cc = rest.substr(i, 1);
if (cc == "\\") {
esc.push(rest.substr(i, 2));
cc = "W3JSESCAPE";
i++;
}
tt += cc;
}
rest = tt;
y = 1;
while (y == 1) {
sfnuttpos = getPos(rest, "'", "'", jsStringMode);
dfnuttpos = getPos(rest, '"', '"', jsStringMode);
compos = getPos(rest, /\/\*/, "*/", commentMode);
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
numpos = getNumPos(rest, jsNumberMode);
keywordpos = getKeywordPos("js", rest, jsKeywordMode);
dotpos = getDotPos(rest, jsPropertyMode);
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], keywordpos[0], dotpos[0]) == -1) {break;}
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, dotpos);
if (mypos[0] == -1) {break;}
if (mypos[0] > -1) {
done += rest.substring(0, mypos[0]);
done += mypos[2](rest.substring(mypos[0], mypos[1]));
rest = rest.substr(mypos[1]);
}
}
rest = done + rest;
for (i = 0; i < esc.length; i++) {
rest = rest.replace("W3JSESCAPE", esc[i]);
}
return "<span style=color:" + jscolor + ">" + rest + "</span>";
}
function jsStringMode(txt) {
return "<span style=color:" + jsstringcolor + ">" + txt + "</span>";
}
function jsKeywordMode(txt) {
return "<span style=color:" + jskeywordcolor + ">" + txt + "</span>";
}
function jsNumberMode(txt) {
return "<span style=color:" + jsnumbercolor + ">" + txt + "</span>";
}
function jsPropertyMode(txt) {
return "<span style=color:" + jspropertycolor + ">" + txt + "</span>";
}
function getDotPos(txt, func) {
var x, i, j, s, e, arr = [".","<", " ", ";", "(", "+", ")", "[", "]", ",", "&", ":", "{", "}", "/" ,"-", "*", "|", "%"];
s = txt.indexOf(".");
if (s > -1) {
x = txt.substr(s + 1);
for (j = 0; j < x.length; j++) {
cc = x[j];
for (i = 0; i < arr.length; i++) {
if (cc.indexOf(arr[i]) > -1) {
e = j;
return [s + 1, e + s + 1, func];
}
}
}
}
return [-1, -1, func];
}
function getMinPos() {
var i, arr = [];
for (i = 0; i < arguments.length; i++) {
if (arguments[i][0] > -1) {
if (arr.length == 0 || arguments[i][0] < arr[0]) {arr = arguments[i];}
}
}
if (arr.length == 0) {arr = arguments[i];}
return arr;
}
function getKeywordPos(typ, txt, func) {
var words, i, pos, rpos = -1, rpos2 = -1, patt;
if (typ == "js") {
words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete",
"do","double","else","enum","eval","export","extends","false","final","finally","float","for","function","goto","if","implements","import",
"in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static",
"super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"];
}
for (i = 0; i < words.length; i++) {
pos = txt.indexOf(words[i]);
if (pos > -1) {
patt = /\W/g;
if (txt.substr(pos + words[i].length,1).match(patt) && txt.substr(pos - 1,1).match(patt)) {
if (pos > -1 && (rpos == -1 || pos < rpos)) {
rpos = pos;
rpos2 = rpos + words[i].length;
}
}
}
}
return [rpos, rpos2, func];
}
function getPos(txt, start, end, func) {
var s, e;
s = txt.search(start);
e = txt.indexOf(end, s + (end.length));
if (e == -1) {e = txt.length;}
return [s, e + (end.length), func];
}
function getNumPos(txt, func) {
var arr = ["<br>", " ", ";", "(", "+", ")", "[", "]", ",", "&", ":", "{", "}", "/" ,"-", "*", "|", "%", "="], i, j, c, startpos = 0, endpos, word;
for (i = 0; i < txt.length; i++) {
for (j = 0; j < arr.length; j++) {
c = txt.substr(i, arr[j].length);
if (c == arr[j]) {
if (c == "-" && (txt.substr(i - 1, 1) == "e" || txt.substr(i - 1, 1) == "E")) {
continue;
}
endpos = i;
if (startpos < endpos) {
word = txt.substring(startpos, endpos);
if (!isNaN(word)) {return [startpos, endpos, func];}
}
i += arr[j].length;
startpos = i;
i -= 1;
break;
}
}
}
return [-1, -1, func];
}
}
</script>
</body>
</html>

View file

@ -0,0 +1 @@
Por una mirada, un mundo, Por una sonrisa, un cielo, Por un beso… yo no sé Que te diera por un beso!

View file

@ -0,0 +1,18 @@
// simple file for testing out nvim-dap
// see: https://github.com/mfussenegger/nvim-dap
// https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Javascript
const http = require("http");
const hostname = "localhost";
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.end("Hello World");
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});

View file

@ -0,0 +1,26 @@
const nullVar = null
const stringified = JSON.stringify(nullVar)
const parsified = JSON.parse(stringified)
console.log(`Starting off with just a null variable...`)
console.log(`nullVar >>: ${nullVar}`)
console.log(`typeof nullVar >>: ${typeof nullVar}`)
console.log(`Testing if nullvar is null value`)
if (nullVar === null) {
console.log(`nullVar is null`)
}
console.log(`Then we stringify it using JSON.stringify(nullVar)`)
console.log(`stringified >>: ${stringified}`)
console.log(`typeof stringified >>: ${typeof stringified}`)
console.log(`Testing if stringified is null value`)
// does not fire
if (stringified === null) {
console.log(`stringified is null`)
}
console.log(`Lastly we take stringified and >> JSON.parse(stringified)`)
console.log(`parsified >>: ${parsified}`)
console.log(`typeof parsified >>: ${typeof parsified}`)
console.log(`Testing if parsified is null value`)
if (parsified === null) {
console.log(`parsified is null`)
}

Some files were not shown because too many files have changed in this diff Show more