Skip to content

Instantly share code, notes, and snippets.

View gavioto's full-sized avatar

gavioto gavioto

View GitHub Profile

#Extract Image URLs and WGet Them to a New Server#

This was a fun problem. I needed to move all the images referenced in a CSS file to another server. I didn't want to just grab all the image files as there were a bunch I didn't need. Here is how I went about it. I am sure you could do it in one step but doing it this way gives you a chance to check for errors.

First you may want to use wget http://otherserver/the_css.css to pull the CSS file on to the target server if it is still on the old server as it was in my case.

  1. User grep to extract the URLs from the css file into another file. (You may need to adjust the regular expression if you have funny characters in your file names) Note the use of the -o flag that tells grep to only print out that part of the line that matches the expression rather than the entire line.

     grep -o '\/path\/to\/files\/[a-zA-Z0-9/.:_-]*' the_css.css > images.txt
    

Piping Water

Inspiration

London’s antique water distribution network is infamous: it loses a quarter of the water supplied to London (spilt into the ground). Consequence: desalination, massive additional CO2 emissions, road congestion caused by too many emergency excavations and very high water prices for consumers. London’s case is severe but not atypical: most cities suffer from the same underlying infrastructure problem. Pipes and valves buried below busy urban streets are inherently difficult and expensive to maintain. Inaccessibility, lack of information, failure to efficiently process data and the high cost of each human intervention in legacy systems all compound to undermine efficient resource distribution.

### PowerShell script to install a minimal Workstation with Chocolatey
# https://chocolatey.org
## To Run This Script:
# 1. Download this PowerShell script
# * Right-click <> ("View Raw") and "Save As" to %USERPROFILE% (/Users/<username>)
# * If Cocolatey is not already installed, see
# "Uncomment to install Chocolatey"
# * If you would like to also install Anaconda
# (Python, IPython, lots of great libraries)
[Unit]
Description=Play2 Server for <site>
After=network.target
 
[Service]
Type=simple
PIDFile=<path>/RUNNING_PID
 
ExecStartPre=/bin/sh -c 'cd <path> ;/bin/rm RUNNING_PID ; sbt clean compile stage'
ExecStart=<path>/target/start
#
# KMS Client Setup Keys: http://technet.microsoft.com/en-us/library/jj612867.aspx
#
####################################################################
# Windows 8.1 Enterprise Evaluation ISO:
# @url: http://go.microsoft.com/fwlink/?LinkId=302161
####################################################################
@gavioto
gavioto / Vagrantfile
Created October 8, 2015 08:37 — forked from dazza-codes/Vagrantfile
Utilities to add an independent data disk to virtualbox vms using vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This vagrant script relies on
# vagrant plugin install vagrant-triggers
VM_NAME = "vbox-dev"
VM_CPUS = 1
VM_MEMORY = 2 * 1024 # in MB
# WINDOWS
# =======
# This assumes you already have chocolatey installed:
# From cmd.exe:
# @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
# From powershell:
# iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
#
# This assumes you have vagrant already installed:
# cinst vagrant
@gavioto
gavioto / Query-Registry.ps1
Created February 10, 2016 13:39 — forked from so0k/Query-Registry.ps1
Query a docker registry v2/_catalog endpoint from powershell
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
$Filter=".*",
#TODO: handle https & no basic auth as well..
$RegistryEndpoint = "registry.mysite.com",
$UserName = "user",
$Password = "password"
)
@gavioto
gavioto / Vagrantfile
Created March 9, 2016 22:18
docker-cluster
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/trusty64"
# Machine-specific provider-specific config (names)
config.vm.define "kv2" do |machineconfig|