Skip to content

Instantly share code, notes, and snippets.

@pmerg
pmerg / index.js
Created July 1, 2017 10:04 — forked from remy/index.js
A small demo of how to create a "next bus" service based on scraping a specific bus service page, and displaying in a LaMetric compatible format.
// follow modules loaded via `npm i --save request cheerio`
const request = require('request');
const cheerio = require('cheerio');
const http = require('http');
http.createServer((req, res) => {
getDueTimes().then(data => {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(JSON.stringify(data));
}).catch(error => {
@pmerg
pmerg / Event Calendar Widget.markdown
Created June 2, 2017 10:48
Event Calendar Widget
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test with ES6 and JSX</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<div id="app"></div>
@pmerg
pmerg / calendar.css
Created May 29, 2017 08:50 — forked from evaldas-raisutis/calendar.css
Responsive html calendar with javascript
#calendar {
margin-top:5em;
width: 100%;
}
#month {
text-align:center;
text-transform:uppercase;
}
@pmerg
pmerg / calendar.html
Created May 29, 2017 08:49 — forked from JamesDullaghan/calendar.html
Calendar html
<div class="row">
<div class="large-12 columns calendar-container">
<h3 class="month">
<a href="/admin/analytics?class=cal-larr&amp;date=2013-11-01">&lt;</a>
December 2013
<a href="/admin/analytics?class=cal-rarr&amp;date=2014-01-01">&gt;</a>
</h3>
<section class="calendar" role="main">
<ul class="day-row">
<li class="day">SUN</li>
@pmerg
pmerg / gist:135dbdbbab37ce637ea8f64084e06378
Created May 29, 2017 06:38 — forked from amit/gist:381040
bookmarklet jquery insert
javascript:function loadScript(u) {
var s = document.createElement('script');
s.setAttribute('src', u);
s.onreadystatechange= function () {
bmhelper();
};
s.onload = bmhelper;
document.getElementsByTagName('body')[0].appendChild(s);}
loadScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
function bmhelper(){
@pmerg
pmerg / index.php
Created May 25, 2017 10:19 — forked from rchrd2/index.php
Include protect.php to password protect a page
<?php include 'protect.php';?>
<!DOCTYPE html>
<html>
<head></head>
<body>Secrets. </body>
</html>
@pmerg
pmerg / gist:d53bf3d19cd44dcdfb8af892891bee5f
Created May 25, 2017 10:11 — forked from snowman-repos/gist:3817253
Htaccess: Password Protect a Folder
#in .htaccess file in the folder you're trying to protect
AuthType Basic
AuthName "This Area is Password Protected"
AuthUserFile /full/path/to/.htpasswd
Require valid-user
#put in a .htpasswd file in a non-public facing directory
#you can generate a password here: http://www.htaccesstools.com/htpasswd-generator/
darrylsnow:$apr1$O/BJv...$vIHV9Q7ySPkw6Mv6Kd/ZE/
<?php
// Define your username and password
$username = "USERNAME HERE";
$password = "PASSWORD HERE";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<h1>Login</h1>
You must login to see this private content.<br>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtUsername">Username:</label>
@pmerg
pmerg / JS-add-to-bookmarks.js
Created May 25, 2017 06:35 — forked from Volker-E/JS-add-to-bookmarks.js
Add to Bookmarks cross-browser
/* ... Bookmark this page ... */
var $pageFav = $('.page-favor'), // li.page-favor
$pageFavLink = $pageFav.find('a');
if ( window.sidebar || 'AddFavorite' in window.external || window.opera ) {
$pageFav.show();
}
/* Source: http://calisza.wordpress.com/2008/11/03/javascript-jquery-bookmark-script/ */
// add a 'rel' attrib if Op 7+ && Fx >= 23
if ( window.opera || window.sidebar ) {