Skip to content

Instantly share code, notes, and snippets.

@avdi
avdi / throw-catch.rb
Created July 11, 2011 05:55
throw/catch demo code for RubyLearning article
require 'rubygems'
require 'mechanize'
MAX_PAGES = 6
def each_google_result_page(query, max_pages=MAX_PAGES)
i = 0
a = Mechanize.new do |a|
a.get('http://google.com/') do |page|
search_result = page.form_with(:name => 'f') do |search|
@nepsilon
nepsilon / pg-backup.md
Last active November 21, 2017 00:27
Proper way to do backup (and restore!) with PostgreSQL 🐘 — First published in fullweb.io issue #51

Proper way to do backup (and restore!) with PostgreSQL 🐘

Postgres provides us several options to do backup just like we want. I’ve tried several strategies in the past, and here is the one I stick to now, for both its simplicity and efficiency.

Backup your database with:

# This is using Postgres custom format
pg_dump -Fc dbname > filename
@JSONOrona
JSONOrona / parser.py
Last active January 4, 2021 16:37
Python command line argument example using argparse module
#!/usr/bin/python
''' Python command line argument example using argparse module
Example output:
./parser.py --server=pyserver --port=8080,443,25,22,21 --keyword=pyisgood
Server name: [ pyserver ]
@stingh711
stingh711 / mount_ebs.sh
Created July 24, 2012 08:02
How to mount another EBS as /var on EC2 (ubuntu)
#!/bin/bash
#attach the EBS to /dev/sdf before running it
#format EBS
mkfs -t ext4 /dev/xvdf
#copy original /var to /dev/xvdf
mkdir /mnt/new
mount /dev/xvdf /mnt/new
cd /var
@thbar
thbar / _readme.md
Created February 15, 2012 11:23
How I got git working with chef on windows
@lbernail
lbernail / ebsnvme-id
Created April 26, 2018 15:07
ebsnvme-id script
#!/usr/bin/env python2.7
# Copyright (C) 2017 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
@dims
dims / Dockerfile
Last active May 10, 2022 21:48
Experiment with Kubernetes with a custom Docker Image
FROM python:3
EXPOSE 8000
CMD ["python", "-m", "http.server"]
@fnichol
fnichol / README.md
Last active August 6, 2022 20:29
Testing on Mac Platforms with Test Kitchen

Testing Mac Platforms with Test Kitchen

We'll assume an OS X Mavericks (10.9) box here.

Requirements

You'll need:

  • Vagrant
  • Vagrant's VMware Fusion provider
@josephabrahams
josephabrahams / lfs-trusty-install.sh
Last active March 9, 2023 12:15
Linux From Scratch Ubuntu 14.04 Host System Requirements Install Script
#!/usr/bin/env bash
# Install missing Linux From Scratch Host System Requirements for Ubuntu 14.04
if [ ! $(whoami) == "root" ]; then
echo "Please run as root!"
exit 1
fi
# symlink sh to bash
ln -fsv /bin/bash /bin/sh
@jakobii
jakobii / HTTPServer.ps1
Last active April 5, 2023 08:37
A Basic Powershell Webserver
# You Should be able to Copy and Paste this into a powershell terminal and it should just work.
# To end the loop you have to kill the powershell terminal. ctrl-c wont work :/
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")