Skip to content

Instantly share code, notes, and snippets.

@emorisse
emorisse / rsyslogHistogram.elasticsearch
Created February 2, 2016 17:52
Aggregated histogram with filters for elasticsearch
{
"aggs" : {
"messages" : {
"filters" : {
"filters" : {
"192.168.0.3" : { "term" : { "rsyslog.fromhost-ip" : "192.168.0.3" }},
"192.168.0.4" : { "term" : { "rsyslog.fromhost-ip" : "192.168.0.4" }},
"192.168.0.5" : { "term" : { "rsyslog.fromhost-ip" : "192.168.0.5" }},
"192.168.0.6" : { "term" : { "rsyslog.fromhost-ip" : "192.168.0.6" }},
"192.168.0.7" : { "term" : { "rsyslog.fromhost-ip" : "192.168.0.7" }},
# Source: http://serverfault.com/a/532600
Floor ()
{
DIVIDEND=${1};
DIVISOR=${2};
RESULT=$(( ( ${DIVIDEND} - ( ${DIVIDEND} % ${DIVISOR}) )/${DIVISOR} ));
echo ${RESULT}
}
Timecount ()
{

West Village

  • Gottino wine bar
  • Bluestone Lane cafe for breakfast and coffee
  • Woogies for wings and cheese steaks
  • walk the highline - park along old railroad tracks. Beautiful day or night.
  • Employees only cocktail bar
  • Big Gay Ice cream

Chelsea

  • Chelsea market for food
@emorisse
emorisse / outlineGroupsOfCells.gs
Created March 15, 2018 15:02
Outline borders of groups of cells in google sheets.
function onOpen() {
var menu = [{name: "Borders for nonempty cells", functionName: "borders"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", menu);
}
function borders() {
var range = SpreadsheetApp.getActiveSheet().getRange("C2:O20");
range.setBorder(false, false, false, false, false, false);
var values = range.getValues();
var borders = range.getValues();
search <- read.csv("latest.search.csv", stringsAsFactors = FALSE)
openstack.month <- "2009-09"
search <- search[which(search$Month == openstack.month):nrow(search),]
search$austin <- 0
austin.month <- which(search$Month == "2016-04")
search[austin.month:nrow(search),]$austin <- 1
# test for stationary data
library(tseries)
@emorisse
emorisse / gganimate.savegif.R
Last active January 13, 2024 11:56
Create an ggplot animation with gganimate, and save it to a gif file. Set hight and width of image. Don't loop the gif animation.
p <- ggplot(tset2, aes(x=weekweek, y=count, group = term)) +
geom_line() +
geom_segment(aes(xend = max(tset$weekweek), yend = count), linetype=2) +
geom_point() +
geom_text(aes(x = max(tset$weekweek)+1, label = term)) +
scale_x_datetime() +
scale_y_continuous(labels=comma) +
transition_reveal(term, weekweek) +
ease_aes('linear') +
theme_tufte(base_family="Overpass")
function histogram(data, bins=5) {
const min = Math.min(...data)
const max = Math.max(...data)
const size = Math.ceil((max-min)/bins)
var histogram = new Array(bins).fill(0);
for (const item of data) {
@emorisse
emorisse / stringChecksum.py
Last active January 12, 2022 16:20
Add checksum to string based on ISBN method
#!/usr/bin/env python
sku = "ABCDEFG"
def checksum(sku):
sum = 0
for i,c in enumerate(sku):
o = ord(c)
#print("{},{}".format(c,o))
if i % 2 == 1:
sum += o
@emorisse
emorisse / batmath.py
Created January 20, 2022 15:50
Plot the batman symbol
# source: https://stackoverflow.com/a/6873633
from __future__ import division # this is important, otherwise 1/2 will be 0
import matplotlib.pyplot
from numpy import arange
from numpy import meshgrid
from numpy import sqrt
from numpy import real
delta = 0.01