Skip to content

Instantly share code, notes, and snippets.

@seripap
seripap / csv_to_array.php
Created July 22, 2016 20:12 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@seripap
seripap / full-page-screenshots-selenium-chrome.rb
Created November 1, 2016 19:37 — forked from elcamino/full-page-screenshots-selenium-chrome.rb
How to take full-page screenshots with Selenium and Google Chrome in Ruby
#!/usr/bin/env ruby
require 'selenium-webdriver'
wd = Selenium::WebDriver.for :remote, url: 'http://10.3.1.7:4444/wd/hub', desired_capabilities: :chrome
wd.navigate.to 'https://snipt.net/restrada/python-selenium-workaround-for-full-page-screenshot-using-chromedriver-2x/'
# Get the actual page dimensions using javascript
#
width = wd.execute_script("return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);")
@seripap
seripap / README.md
Last active August 8, 2023 11:35
Working gdal2tiles_parallel.py (defaults to PNG)

tif_to_tiles.sh

Quick helper to translate tif to tiles using parallel cpu.

$ tif_to_tiles.sh input.tif

gdalwarp will convert to output.tif, gdal2tiles_parallel.py will ingest output.tif and output PNGs to map_tiles folder.

@seripap
seripap / app.js
Created March 8, 2017 14:28 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
  1. events.php
  • create event on inital load, update event afterwards. ?eventId=EVENT_ID to modify specific event.
  1. people.php
  • create person on initial load, update or delete person afterwards. ?personId=PERSON_ID to modify specific person.

Walkthrough of the following script (v8:6573).

var logFoo;
var promise1 = Promise.resolve().then( () => logFoo = () => console.log( "foo" ) );
promise1.then( () => logFoo() ).then( logFoo );

1. var logFoo;

@seripap
seripap / README.md
Last active January 27, 2020 09:20
Chrome Headless PDF with Page Numbers

Getting page numbers using Chrome Headless

This is a small hack that adds a page numbers at the bottom of the page. Using Puppeteer and a fixed height, the page will render at an A4 size via web and have a fixed footer.

await page.goto('https://bl.ocks.org/seripap/raw/81241195e182b62adc3c87c27258f85f/', {waitUntil: 'networkidle'});
await page.pdf({
  path: 'hacks.pdf',
  format: 'A4'
});
@seripap
seripap / insert.sql
Created March 18, 2019 18:41
State Parcel: Shortname, Longname, FIPS
INSERT into parcel_state values
(1, 'AL', 'Alabama', 1),
(2, 'AK', 'Alaska', 2),
(3, 'AZ', 'Arizona', 4),
(4, 'AR', 'Arkansas', 5),
(5, 'CA', 'California', 6),
(6, 'CO', 'Colorado', 8),
(7, 'CT', 'Connecticut', 9),
(8, 'DE', 'Delaware', 10),
(9, 'DC', 'District of Columbia', 11),
@seripap
seripap / .muttrc
Created April 24, 2019 18:45 — forked from mickn/.muttrc
My Mutt Configuration (Gmail, Multiple Accounts, Not-Mutch Search, OfflineImap)
# Paths {{{
set folder = ~/Mail # mailbox location
set alias_file = ~/.mutt/alias # where to store aliases
set header_cache = ~/.mutt/cache/headers # where to store headers
set message_cachedir = ~/.mutt/cache/bodies # where to store bodies
set certificate_file = ~/.mutt/cerficates # where to store certs
set mailcap_path = ~/.mutt/mailcap # entries for filetypes
set tmpdir = ~/.mutt/temp # where to keep temp files
set signature = ~/.mutt/sig # my signature file
@seripap
seripap / README.md
Last active April 11, 2025 23:40
Linear.app Slack Bot Autolinker

This is a Slack bot that automatically links to Linear.app issues. Sort of how like the Github autolinks work, except for Slack.

For example, you type Check out SE-12, the bot will then link to https://linear.app/{team}/se-12