Skip to content

Instantly share code, notes, and snippets.

@Kartones
Kartones / postgres-cheatsheet.md
Last active April 22, 2025 20:11
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@tinybike
tinybike / mssql_to_csv.py
Last active October 22, 2023 18:12
simple mssql -> csv file example using pymssql
#!/usr/bin/env python
"""
simple mssql -> csv file example using pymssql
@author [email protected]
"""
import csv
import datetime
import pymssql
from decimal import Decimal
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active April 22, 2025 06:38
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
@kdart
kdart / dirwatcher
Created March 10, 2015 07:34
Script to watch directory and launch hander.
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
"""
Watch for new downloads in ~/Downloads (or another directory) and take actions.
The actions are determined by the file extension (determining the mime type).
"""
from __future__ import absolute_import
from __future__ import print_function
@jczaplew
jczaplew / pgFormatDate.js
Created April 24, 2015 14:11
Javascript Date to Postgres-acceptable format
// Convert Javascript date to Pg YYYY MM DD HH MI SS
function pgFormatDate(date) {
/* Via http://stackoverflow.com/questions/3605214/javascript-add-leading-zeroes-to-date */
function zeroPad(d) {
return ("0" + d).slice(-2)
}
var parsed = new Date(date)
@chinchang
chinchang / xmlToJson.js
Last active September 7, 2023 02:39
Function to convert XML to JSON
/**
* Changes XML to JSON
* Modified version from here: http://davidwalsh.name/convert-xml-json
* @param {string} xml XML DOM tree
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active January 28, 2025 09:47
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
@vadv
vadv / init.sql
Created November 19, 2015 05:47
bench postgresql
psql -c 'create database pgbench'
psql -c 'create database results'
psql -c '
CREATE TABLE testset(
set serial PRIMARY KEY,
info text
);
CREATE TABLE tests(
test serial PRIMARY KEY,
public class WebClientEx : WebClient
{
private CookieContainer _cookieContainer = new CookieContainer();
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request is HttpWebRequest)
{
(request as HttpWebRequest).CookieContainer = _cookieContainer;
from tqdm import tqdm
from time import sleep
import pandas as pd
mycsv = "C:\\Users\\rob\\Downloads\\contest-standings-17968412\\contest-standings-17968412.csv"
mycsv2 = "C:\\Users\\rob\\Downloads\\contest-standings-17968412\\testEmail.csv"
# items = range(1,100)
#