Skip to content

Instantly share code, notes, and snippets.

View crismanNoble's full-sized avatar

Cris Noble crismanNoble

View GitHub Profile
@crismanNoble
crismanNoble / Chrome to Kippt
Created August 28, 2012 19:41
Importing Chrome Bookmarks to Kippt
//Export Chrome bookmarks as html
//Manually add a id="target" to the <d1> under the <h3> of the folder you want to import
//Initialize your list
var list = '';
//save the children of your target
var target = document.getElementById('target').children;
//grab all the titles and links, format them for easy importation to Kippt API
@crismanNoble
crismanNoble / gson.js
Created September 30, 2022 17:49
gson: google sheets to json
//load in papaparse script
var papaparse_script = document.createElement("script");
papaparse_script.type = "text/javascript";
papaparse_script.src = "https://cdn.jsdelivr.net/npm/papaparse@5.3.2/papaparse.min.js";
document.body.appendChild(papaparse_script)
//fetch the data
var sheet_csv = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQZBb0hdC5AnYmi445Ie0mDKuH6ipRjwmSZmEJppOLviHJnW1jLSow3jjwBO1QT-y_raxlEvzDC28b2/pub?gid=1752595225&single=true&output=csv';
fetch(sheet_csv)
<form>
<label for="zip">Zip:</label>
<input id="zip" name="zip"/>
<label for="city">City:</label>
<div id="city-input-wrapper"><!-- wrap the city input so we can change to a dropdown if necessary -->
<input id="city" name="city"/>
</div>
<label for="state">State:</label>
<input id="state" name="state"/>
</form>
function fillCityAndStateFields(localities) {
var locality = localities[0];
$('#city').val(locality.city);
$('#state').val(locality.state);
var $input;
if(localities.length > 1) { //possibly create a dropdown if we have multiple cities in the result.
var $select = $(document.createElement('select'));
{
"results" : [
{
"address_components" : [
{
"long_name" : "60047",
"short_name" : "60047",
"types" : [ "postal_code" ]
},
{
$('#zip').blur(function(){
var zip = $(this).val();
var api_key = 'YOUR_API_KEY_HERE';
if(zip.length){
//make a request to the google geocode api with the zipcode as the address parameter and your api key
$.get('https://maps.googleapis.com/maps/api/geocode/json?address='+zip+'&key='+api_key).then(function(response){
//parse the response for a list of matching city/state
var possibleLocalities = geocodeResponseToCityState(response);
fillCityAndStateFields(possibleLocalities);
});
@crismanNoble
crismanNoble / 92101.json
Created July 2, 2021 16:02
Google Maps Response for 92101
{
"results" : [
{
"address_components" : [
{
"long_name" : "92102",
"short_name" : "92102",
"types" : [ "postal_code" ]
},
{
@crismanNoble
crismanNoble / server.py
Created April 16, 2020 17:23
simple python server
python -m SimpleHTTPServer 1337
@crismanNoble
crismanNoble / snippet.js
Created December 31, 2019 15:53
[ASYNC examples] #javascript
//do one thing after another is finished
const doThing = async function(timeout) {
const resp = await fetch(scheduleEndpoint, {method: 'POST', body: params}); //needs to return a promise?
return resp;
}
await doThing(); //do an api call or something async that returns a promise
console.log('all done'); //don't do anything else until that is finished.
//do a bunch of things in series, then do something else
//https://zellwk.com/blog/async-await-in-loops/
@crismanNoble
crismanNoble / wordFrequency.js
Created September 5, 2012 18:02
Get frequency of words on a webpage.
//todos: 1) moar than just <p>s, just words. 2)strip out &amp;s and stuff 3)Order by top use
//via: https://www.squarefree.com/bookmarklets/seo.html
javascript:(function(){
var T={},W=[],C=0,s,i;
function F(n){
var i,x,a,w,t=n.tagName;
if(n.nodeType==3){
a=n.data.toLowerCase().split(/[\s\(\)\:\,\.;\<\>\&\'\"]/);
for(i in a)if(w=a[i]){
w=" "+w;T[w]=T[w]?T[w]+1:1;++C;}