Skip to content

Instantly share code, notes, and snippets.

@lightpohl
lightpohl / marked-and-prism.js
Last active February 17, 2024 23:06
Use marked and prism.js to parse markdown and add syntax highlighting in Node.js
// Versions: marked v0.6.2, prismjs v1.15.0
let marked = require('marked');
let prism = require('prismjs');
let loadLanguages = require('prismjs/components/');
loadLanguages(['javascript', 'jsx', 'css', 'markup', 'bash', 'json']);
marked.setOptions({
highlight: function(code, lang) {
@ryansolid
ryansolid / todos-header-footer.jsx
Last active September 26, 2019 14:24
Todos: Header and Footer
@cvan
cvan / check-if-css-loaded.js
Last active March 11, 2023 21:38
check if a CSS stylesheet has loaded
var linkEl = document.head.querySelector('link[href*="/styles/index.css"]');
var cssLoaded = Boolean(linkEl.sheet);
linkEl.addEventListener('load', function () {
cssLoaded = true;
});
@markhowellsmead
markhowellsmead / operatingsystem.js
Last active March 7, 2024 20:57
Detect a device operating system using JavaScript. Windows OS will be more precisely recognized.
if(navigator.appVersion.indexOf("Windows ")!=-1){
os = getWindowsOS();
}else{
os = navigator.platform;
}
function getWindowsOS(){
// http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#PltToken
if(navigator.appVersion.indexOf("Windows NT 10.")!=-1){
return 'Windows 10';
@aVolpe
aVolpe / EmbeddedGist.js
Created September 13, 2016 22:58
EmbeddedGist allows a gist to be embedded in a React application
import React, { Component } from 'react';
class EmbeddedGist extends Component {
constructor(props) {
super(props);
this.gist = props.gist;
this.file = props.file;
this.stylesheetAdded = false;
this.state = {
@zenorocha
zenorocha / basic.md
Last active March 26, 2023 09:00
New Firebase Auth vs Old Firebase Auth
@zemadi
zemadi / coderbyte
Last active April 16, 2024 21:30
Python answers to CoderByte challenges
#My solutions to challenges from CoderByte.com. Their Python interpreter is buggy.
#1 Using the Python language, have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.
def FirstReverse(str):
print str[::-1]
#2 Using the Python language, have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it (ie. if num = 4, return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18.
def FirstFactorial(num):
@evadne
evadne / index.html
Created May 7, 2013 22:52
Accordion (Stacked Flex-Box Panels)
<html>
<head>
<meta charset="UTF-8">
<title>Accordion Test</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
body {