Skip to content

Instantly share code, notes, and snippets.

Avatar

Zachariah Moreno ZachMoreno

View GitHub Profile
@ZachMoreno
ZachMoreno / Detect_Brave_Browser.js
Created Jul 8, 2019
The Brave Browser removed "Brave" from its User-Agent in v0.9. DuckDuckGo can detect Brave & this promise utilizes their API to detect Brave.
View Detect_Brave_Browser.js
const detectBraveBrowser = () => {
return new Promise((resolve, reject) => {
if(!navigator.userAgent.includes('Chrome')) { return resolve(false); }
const xhr = new XMLHttpRequest();
const onload = () => {
if(xhr.status >= 200 && xhr.status < 300) {
const response = JSON.parse(xhr.responseText);
if(!response) { return resolve(false); }
View maps-example.html
<!doctype html>
<html>
<head>
<title>Google Map Example</title>
<style>
html,
body,
#my-map {
height: 100vh;
View useragent-attribute.js
(function() {
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
})();
View ccc-list-unstyled.html
<ul class="unstyled-list">
<li>list item</li>
<li><a href="#" alt="">list item</a></li>
<li>
<strong>list item</strong>
<ul>
<li>sub list item</li>
<li>sub list item</li>
</ul>
</li>
View ccc-grid-push.html
<div class="container">
<div class="row">
<div class="column-11 push-1">
<p>.push-1</p>
</div> <!-- end .column-1 -->
</div> <!-- end .row -->
<div class="row">
<div class="column-10 push-2">
<p>.push-2</p>
View ccc-grid-nested.html
<div class="container">
<div class="row">
<div class="column-12">
<p>.column-12</p>
<div class="row gutters">
<div class="column-4">
<p>.column-4</p>
</div> <!-- end .column-4 -->
View ccc-grid-gutters.html
<div class="container">
<div class="row gutters">
<div class="column-1">
<p>.column-1</p>
</div> <!-- end .column-1 -->
<div class="column-11">
<p>.column-11</p>
</div> <!-- end .column-11 -->
</div> <!-- end .row -->
View ccc-grid-12-column.html
<div class="container">
<div class="row">
<div class="column-1">
<p>.column-1</p>
</div> <!-- end .column-1 -->
<div class="column-11">
<p>.column-11</p>
</div> <!-- end .column-11 -->
</div> <!-- end .row -->
@ZachMoreno
ZachMoreno / new-google-map.js
Last active Dec 24, 2015
Wrapper function to create a Google Map with a single marker, including optional click event handler
View new-google-map.js
function newMap(lat, long, zoom, domID, clickHandler) {
var latLong = new google.maps.LatLng(lat,long),
options = {
center: {
lat : lat,
lng : long
},
// set base map
mapTypeId: google.maps.MapTypeId.TERRAIN,
View req-params-example.js
router.route('/api/categories/:categoryID')
.get(function(req, res) {
// query
connection.query('SELECT listers.lister_id, listers.listing_name, listers.city, listing_categories.category_name FROM listing_categories INNER JOIN listings ON listing_categories.listing_category_id = listings.listing_category_id JOIN listers ON listings.lister_id = listers.lister_id WHERE listings.listing_category_id = ' + req.param('categoryID'), function(err, rows, fields) {
if(err) {
res.send(err);
console.log(err);
connection.end();
} else {
res.send(rows);
You can’t perform that action at this time.