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)
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>' |
#!/usr/bin/env python | |
""" | |
simple mssql -> csv file example using pymssql | |
@author [email protected] | |
""" | |
import csv | |
import datetime | |
import pymssql | |
from decimal import Decimal |
#!/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. | |
) |
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 |
#!/bin/bash | |
##################################################### | |
# Name: Bash CheatSheet for Mac OSX | |
# | |
# A little overlook of the Bash basics | |
# | |
# Usage: | |
# | |
# Author: J. Le Coupanec | |
# Date: 2014/11/04 |
# 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> |
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)
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); |
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, |