Skip to content

Instantly share code, notes, and snippets.

@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 => {
@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 / 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 / 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 / gist:d4fa0e47f5dc872a7b7b
Created March 28, 2016 18:43
Docker - Remove all images
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@seripap
seripap / .zshrc
Created March 2, 2016 14:33
Squash commit (bash/profile)
# squash integer
function squash() {
git rebase -i HEAD~${1}
}
@seripap
seripap / crawl.js
Created December 18, 2015 16:08
Simple NodeJS Link Crawler
'use strict';
import Crawler from "simplecrawler";
import fs from 'fs';
Crawler.crawl("http://www.google.com").on("fetchcomplete", (queueItem, responseBuffer, response) => {
console.log("Completed fetching resource:", queueItem.url);
if (queueItem.url.indexOf('png') > 0 || queueItem.url.indexOf('jpg') > 0 || queueItem.url.indexOf('gif') > 0 || queueItem.url.indexOf('jpeg') > 0) {
let filename = queueItem.url.substring(queueItem.url.lastIndexOf('/')+1);
@seripap
seripap / domain.js
Created December 18, 2015 16:05
DNS domain check
'use strict';
import dns from "dns";
import sys from "sys";
import fs from "fs";
const items = JSON.parse(fs.readFileSync('./shake.json'));
function checkAvailable(name, callback) {
dns.resolve4( name, (err, addresses) => {
@seripap
seripap / nginx.conf
Last active November 12, 2015 20:10 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@seripap
seripap / months.js
Created October 8, 2015 21:32 — forked from bgadrian/months.js
JavaScript JS month names arrays
var month= ["January","February","March","April","May","June","July",
"August","September","October","November","December"];
var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul","Aug", "Sep", "Oct", "Nov", "Dec"];
//used with date.getMonth()