Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@jay-johnson
jay-johnson / Mounting a new Volume for increasing var hard drive space.md
Last active January 17, 2018 23:03
Mounting a new Volume for increasing /var hard drive space

Format the Volume

driver@localhost:/var/lib$ sudo fdisk -l

Disk /dev/sda: 31.5 GB, 31515377664 bytes
255 heads, 63 sectors/track, 3831 cylinders, total 61553472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
@mchirico
mchirico / tensorFlowIrisCSV.py
Last active April 2, 2021 06:56
Tensorflow: working with tensorboard, CSV, and saving results
#!/usr/bin/env python
import tensorflow as tf
import numpy as np
from numpy import genfromtxt
# Build Example Data is CSV format, but use Iris data
from sklearn import datasets
from sklearn.model_selection import train_test_split
import sklearn
def buildDataFromIris():
node {
// https://registry.hub.docker.com/_/maven/
def maven32 = docker.image('maven:3.2-jdk-7-onbuild');
stage 'Mirror'
// First make sure the slave has this image.
// (If you could set your registry below to mirror Docker Hub,
// this would be unnecessary as maven32.inside would pull the image.)
maven32.pull()
// We are pushing to a private secure docker registry in this demo.
@amatellanes
amatellanes / celery.sh
Last active April 19, 2024 11:31
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@DmZ
DmZ / pre-commit
Last active July 25, 2023 13:40
Git pre-commit hook to search for Amazon AWS API keys.
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@mspan
mspan / RandomForestsInTen_final.ipynb
Created September 26, 2013 00:10
Overview of Random Forests for newhaven.io presentation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pauloconnor
pauloconnor / gist:4707710
Last active December 1, 2022 09:33
Logstash Mutate Filter for stripping Linux color codes from log files
# Get rid of color codes
mutate {
gsub => ["message", "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", ""]
}
@oubiwann
oubiwann / list_queues.txt
Created October 5, 2012 23:18
A Kombu send/receive example
Listing queues ...
hipri 5
lopri 0
midpri 0
...done.