Skip to content

Instantly share code, notes, and snippets.

View liddiard's full-sized avatar
🙃

Harrison Liddiard liddiard

🙃
View GitHub Profile
@liddiard
liddiard / navigator.html
Created May 19, 2015 18:26
Some code I was playing with to inject JavaScript into an iframe
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<style>
iframe {
width: 960px;
var request = require('superagent');
var React = require('react');
// require('./app.scss');
var API_ROOT = '/api/';
var App = React.createClass({
@liddiard
liddiard / fullwidth.scss
Last active August 25, 2015 21:43
100 percent screen width element inside a narrower, fixed width container/wrapper element. Useful for things like full-width photos and graphics inside an article text container with fixed width. Works in IE 9+.
.fullwidth {
width: 100vw;
margin-left: calc((100vw - $wrapper_width)/-2);
}
<style>
#article-content h1 {
float: left;
margin-right: 1rem;
}
#article-content h2 {
color: #666;
}
var http = require('http');
var fs = require('fs');
var argv = require('yargs').argv;
var cheerio = require('cheerio');
var DEFAULT_TEMPLATE = "http://uclabruins.com/ViewArticle.dbml?ATCLID=209624560&DB_OEM_ID=30500";
var template = argv.template || DEFAULT_TEMPLATE;
var pageFilename = argv._[0];
@liddiard
liddiard / location.sh
Last active September 14, 2015 18:35
Bash script to show the current location of the machine you're running on using GeoIP in the format: "City, State, Country".
#!/bin/bash
API_URL="http://freegeoip.net/csv/"
# Get current external IP (http://askubuntu.com/a/95911)
IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
LOCATION=$(curl -s ${API_URL}${IP})
echo "$LOCATION" | awk -F "," '{print $6 ",", $5 ",", $3}'
; <<>> DiG 9.8.3-P1 <<>> dailybruin.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9189
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;dailybruin.com. IN A
;; AUTHORITY SECTION:
@liddiard
liddiard / thoughtpad.html
Last active February 13, 2017 00:40
Simple full-body contenteditable web page with contents persisted in localStorage. I don't really know why you'd need this, but why not?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<title>Thoughtpad</title>
<meta name="description" content="Page description, shows up in search results. Should be no longer than 150-160 characters." />
@liddiard
liddiard / handlebars-template-loader.js
Last active November 30, 2016 19:12
Load a handlebars template into the DOM with no additional code. Gets the template URL from script's `data-template` attribute, and JSON template data URL from `data-context` attribute.
(function(){
// get a reference to the current script (IE support)
// http://stackoverflow.com/a/22745553
const scripts = document.getElementsByTagName('script');
const currentScript = scripts[ scripts.length - 1 ];
const CONTEXT_URL = currentScript.dataset.context;
const TEMPLATE_URL = currentScript.dataset.template;
@liddiard
liddiard / dank.js
Last active December 6, 2016 06:04
Documenting the spread of dank memes at UCLA: https://www.facebook.com/groups/163576114113950/members/
// click the "more members" button programatically to get everyone who likes dank memes
window.setInterval(() => { document.querySelector('.uiMorePagerPrimary').click() }, 5000);
// get the names of everyone who likes dank memes
let people = Array
.from(document.querySelectorAll('.fsl.fwb.fcb'))
.map(a => { return a.innerText });
// get the 100x100 profile photo URLs of everyone who likes dank memes
let photos = Array