Skip to content

Instantly share code, notes, and snippets.

@robsmith1776
robsmith1776 / kill_attrs.py
Created November 19, 2015 16:36 — forked from bradmontgomery/kill_attrs.py
A way to remove all HTML attributes with BeautifulSoup
from BeautifulSoup import BeautifulSoup
def _remove_attrs(soup):
for tag in soup.findAll(True):
tag.attrs = None
return soup
def example():
doc = '<html><head><title>test</title></head><body id="foo" onload="whatever"><p class="whatever">junk</p><div style="background: yellow;" id="foo" class="blah">blah</div></body></html>'
@robsmith1776
robsmith1776 / mssql_to_csv.py
Created February 26, 2016 00:33 — forked from tinybike/mssql_to_csv.py
simple mssql -> csv file example using pymssql
#!/usr/bin/env python
"""
simple mssql -> csv file example using pymssql
@author jack@tinybike.net
"""
import csv
import datetime
import pymssql
from decimal import Decimal
@robsmith1776
robsmith1776 / sample_usage.py
Created October 11, 2016 22:20 — forked from luke14free/sample_usage.py
Simple type checked objects in Python
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@robsmith1776
robsmith1776 / SimpleHttpClient.cs
Created April 27, 2017 14:42 — forked from bryanbarnard/SimpleHttpClient.cs
Simple C# .NET 4.5 HTTPClient Request Using Basic Auth and Proxy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
namespace HTTP_Test
@robsmith1776
robsmith1776 / bash-cheatsheet.sh
Created May 20, 2019 20:12 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@robsmith1776
robsmith1776 / SqlBackupToS3.ps1
Created June 28, 2019 18:42 — forked from martic/SqlBackupToS3.ps1
Powershell Sql Backup To AWS S3
# Needed PS packages
# Install-Package -Name pscx
# Install-Package -Name AWSPowerShell
#
# Scheduling
# The script then needs to be scheduled to run every night, I’m using scheduled tasks for this,
# creating a task that runs nightly and triggers the powershell script by running
# Powershell.exe with the arguments 
# -ExecutionPolicy Bypass C:\SqlBackup\SqlBackupToS3.ps1.
# From <https://www.rhysgodfrey.co.uk/b/blog/posts/backing-up-a-sql-database-to-amazon-s3-using-powershell>
@robsmith1776
robsmith1776 / subprocess_pipe.md
Created February 27, 2020 19:00 — forked from waylan/subprocess_pipe.md
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)
@robsmith1776
robsmith1776 / crosstab.sql
Created September 13, 2020 12:33 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);
@robsmith1776
robsmith1776 / pg_cursor_example.rb
Created May 24, 2022 20:14 — forked from JoshCheek/pg_cursor_example.rb
PostgreSQL cursor example
require 'pg'
db = PG.connect dbname: 'postgres'
db.exec("DROP DATABASE IF EXISTS just_fkn_around;")
db.exec("CREATE DATABASE just_fkn_around;")
db = PG.connect dbname: 'just_fkn_around'
define_method(:sql) { |sql| db.exec(sql).to_a }
sql <<-SQL
-- some data to query
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,