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
This is a contrived example to demonstrate transaction triggers in Twisp. |
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
package main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"log" | |
) |
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
if (!File) { | |
throw new Error('Unsupported Browser. File is required.'); | |
} | |
function input(callback) { | |
var element = document.createElement('input'); | |
element.setAttribute('type', 'file'); | |
element.setAttribute('multiple', ''); |
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
// && | |
if (true && true && true) // TRUTHY | |
if (true * true * true) // using multiplication converts true to 1 and multiplies each 1 together, (1 * 1 * 1) which evaluates to a truthy value | |
if (true && true && false) // FALSY | |
if (true * true * false) // (1 * 1 * 0) FALSY | |
// || |
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
Show hidden characters
{ | |
"node": true, | |
"browser": true, | |
"esversion": 6, | |
"bitwise": true, | |
"curly": true, | |
"eqeqeq": true, | |
"forin": true, | |
"freeze": true, | |
"futurehostile": true, |
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
// rl-stdin is a node module I wrote to the stdin data and resolve the result in a promise | |
// `sudo npm install -g rl-stdin` | |
require('rl-stdin') // get the stdin data from the curl | |
.then(JSON.parse) // convert JSON to javascript object | |
.then((data) => data.data) // data is stored at the data key | |
.then((data) => data.map((section) => section.data.students.length)) // map the section to the number of students enrolled | |
.then((data) => data.reduce((hold, current) => hold + current)/data.length) // sum the total number of students enrolled divided by the total number of sections to get the average | |
.then((solution) => console.log('Average students per section is: ' + solution)); // log the output |
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
#!/bin/bash | |
if [[ $1 = "-trash" ]] || [[ $1 = "-t" ]] | |
then | |
while true | |
do read -p "Are you sure you want to permanently delete the trash? (yes/no): " yn | |
case $yn in | |
[Yy]* ) break;; | |
[Nn]* ) echo "Aborted the operation"; exit 0;; | |
* ) echo "Please answer yes or no. Do you want to permanently delete the trash? (yes/no)";; |
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
#!/bin/bash | |
html=" | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<link rel="stylesheet" type="text/css" href="app.css"> | |
</head> | |
<body> |