Skip to content

Instantly share code, notes, and snippets.

View dcts's full-sized avatar
💭
probably coding

dcts dcts

💭
probably coding
View GitHub Profile
@JesseE
JesseE / firestore-update-algolia.js
Created January 10, 2019 16:20
Firestore cloud function to update Algolia index on change
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import * as algoliasearch from 'algoliasearch';
admin.initializeApp();
const client = algoliasearch(
functions.config().algolia.app_id,
functions.config().algolia.api_key
);
@TravisMullen
TravisMullen / lit-element-repeat.html
Created June 8, 2018 22:04
Example: Lit Element's Repeat Method
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@next/webcomponents-loader.js"></script>
</head>
<body>
<!-- Works only on browsers that support Javascript modules like
Chrome, Safari, Firefox 60, Edge 17 -->
<script type="module">
import { LitElement, html } from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
@tlhunter
tlhunter / average-geolocation.js
Created May 17, 2017 18:00
Calculate the center/average of multiple GeoLocation coordinates
/**
* Calculate the center/average of multiple GeoLocation coordinates
* Expects an array of objects with .latitude and .longitude properties
*
* @url http://stackoverflow.com/a/14231286/538646
*/
function averageGeolocation(coords) {
if (coords.length === 1) {
return coords[0];
}
@outbreak
outbreak / uuid.js
Created October 25, 2016 17:39
UUID v4 JavaScript implementation with window.crypto.getRandomValues()
function uuid () {
function getRandomSymbol (symbol) {
var array;
if (symbol === 'y') {
array = ['8', '9', 'a', 'b'];
return array[Math.floor(Math.random() * array.length)];
}
array = new Uint8Array(1);
@collinprice
collinprice / gist:9541470
Created March 14, 2014 03:06
Base64 encoded audio file.
var sound = new Audio("data:audio/wav;base64,UklGRuy3AABXQVZFZm10IBAAAAABAAEAIlYAACJWAAABAAgAZGF0Yci3AACIhISCgH5+enx+gHx4cm5udHp+fHh0cHJ0enx8enx+fn6GiIyMiIaKio6Wmp6goJycnp6coJ6cnJqanqSoqqigmJKSmJygop6ampycmpaOjIiIhoSChoiGgHx2cG5qaGhiYmRkZmRgXFpUUlJUVlhcVlZYWmBgYFxaWlxiZmpsbGxsampubnBwbmxsbnB0cHBubGpqbGxwcnRwbnB2enyAfoB8fH5+goSEhISCgICEhoyKhoCChIiMjIyKiIaCgoaMioiEhISGjpaanJyYlpSWnqKkoJyYlpiYmJaSkI6MioSKjIyIhIB8en5+fHp2eHp6fn6AfHp8enh8foSEgoJ+foKGiIaAeHR2dn58fHx8fHZ2cnBydnRwcHJ6fHp2dHBwbm5sbm5wcHJubnB0dHBwbG50dnx8enp4enZ2dnZ0dnh4fH5+fHp2dHR0enZ0cnZ6eHp6eHh0dnh0dHZ2eHZ0cGxqamZiXFpYWFhaWlhYVlhYVlZaWl5gYGJkZmhoaGxucHJ0eHR2en58fHh0dnZ8foCAgH6ChoSEhISEhoaIjJKWmpiSkpSWmp6enJiampqcnpqYkI6MjIyOjIiGhoiIhoqIiISChISKjo6MiISEhoqOkJKSkpSQjpKYmpqWkJCOkpKUkpKQio6OjI6MhoKAenp2dHJuamhoZGRoamhmZmZkZmhqamhoaGxsbm5qamZoaGpqbm5ubmxuamxsbm50cnR2fHx+foSAfn6CiIqMjpKSkpaeoqCWlJSWlpSanp6alJSSkJCSlpaSkpKWmqCemJKOjI6SlpaYnJqUlJaYlpKQkJCSlpqYkI6OjoyKiIiEgHx+hoaIhoJ8dHBucnR0cHJycHJucGpoZmZoZGZoaG5ubmpsamhkZGRkZGZqbGhmZmhkZGZkYmJkZGZqbG5wcGh
@pathouse
pathouse / imdb_pro_production_companies_by_location.rb
Last active April 11, 2023 20:09
IMDb pro has a database of more than 22,000 production companies. Unfortunately, their searching and sorting tools are pretty poor. This is a very simple first draft of a script for scraping those pages for info and writing the results to a csv file. This is 4401 pages of data (50 companies per page) so it takes a while. An IMDb pro subscription…
require 'mechanize'
require 'csv'
PAGES = (1..4401)
LOGIN_PAGE = "https://secure.imdb.com/signup/v4/login"
BASE_URL = 'http://pro.imdb.com/companies/type-production'
def page_url(page)