Skip to content

Instantly share code, notes, and snippets.

//Simple random string generator in JS
Math.random().toString(36);
// Here is how the react compenent is append to the html element in the app
// ReactDOM.render(
// <MarkdownEditor />,
// document.getElementById('markdown-example')
// );
class MarkdownEditor extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
// excample
const listOfThingWithDuplicate = [1,2,3,4,4,100,4,2,6];
const listWithOutDuplicateElements = [...new Set(listOfThingWithDuplicate)];
// import dependencies into an array of strings.
const { dependencies } = require('./package.json');
const libs = Object.keys(dependencies);
$ npm install pdfmake
//It's very important to follow this order
import pdfFonts from 'pdfmake/build/vfs_fonts';
import pdfMake from 'pdfmake/build/pdfmake';
//It's a important one too
"subtleBrackets.styles": {
"global": {
"color": "white",
"backgroundColor": "rgba(0, 255, 0, 0.3)",
"borderColor": "1px yellow",
"borderWidth": "1px",
"borderStyle": "none none dotted",
"padding":"20px"
}
// regular Promise()
function fetchAlbums() {
fetch('https://http://rallycoding.herokuapp.com/api/music_albums')
.then(res => res.json())
.then(json => console.log(json));
}
//async
console.log('%c Oh my heavens Amigos! ', 'background: #222; color: #bada55');
console.log('%c a colorful message', 'background: green; color: white; display: block;');
var styles = [
'background: linear-gradient(#D33106, #571402)'
, 'border: 1px solid #3E0E02'
, 'color: white'
txtblk='[\e[0;30m]' # Black
txtred='\[\e[0;31m\]' # Red
txtgrn='\[\e[0;32m\]' # Green
txtylw='\[\e[0;33m\]' # Yellow
txtblu='\[\e[0;34m\]' # Blue
txtpur='\[\e[0;35m\]' # Purple
txtcyn='\[\e[0;36m\]' # Cyan
txtwht='\[\e[0;37m\]' # White
txtrst='\[\e[0m\]' # Text Reset
$ open -a TextEdit .bash_profile
txtblk='[\e[0;30m]' # Black
txtred='\[\e[0;31m\]' # Red
txtgrn='\[\e[0;32m\]' # Green
txtylw='\[\e[0;33m\]' # Yellow
txtblu='\[\e[0;34m\]' # Blue
txtpur='\[\e[0;35m\]' # Purple
txtcyn='\[\e[0;36m\]' # Cyan
txtwht='\[\e[0;37m\]' # White