Skip to content

Instantly share code, notes, and snippets.

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 30, 2024 04:25
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@jsundram
jsundram / heatmat.py
Created January 18, 2013 19:52
Heatmap in python like this one on flowingdata, see stackoverflow for context: http://stackoverflow.com/questions/14391959/heatmap-in-matplotlib-with-pcolor
import matplotlib.pyplot as plt
import numpy as np
column_labels = list('ABCD')
row_labels = list('WXYZ')
data = np.random.rand(4,4)
fig, ax = plt.subplots()
heatmap = ax.pcolor(data, cmap=plt.cm.Blues)
# put the major ticks at the middle of each cell
ax.set_xticks(np.arange(data.shape[0])+0.5, minor=False)
# -*- coding: utf-8 -*-
""" Small script that shows hot to do one hot encoding
of categorical columns in a pandas DataFrame.
See:
http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder
http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.DictVectorizer.html
"""
import pandas
import random
@kerryrodden
kerryrodden / .block
Last active April 22, 2024 19:24
Sequences sunburst
license: apache-2.0
@mblondel
mblondel / letor_metrics.py
Last active April 24, 2024 19:43
Learning to rank metrics.
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
def ranking_precision_score(y_true, y_score, k=10):
"""Precision at rank k
Parameters
@stringertheory
stringertheory / threes_simulation.py
Last active June 26, 2023 14:00
A quicky python script to simulate random pushes in the Threes game at threesjs.com, as described in http://datascopeanalytics.com/what-we-think/2014/03/13/are-you-really-any-good-at-threes
# standard library
import sys
import random
import time
# need to pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
@treycausey
treycausey / slopegraphs.py
Last active February 19, 2019 12:23
Slopegraphs in matplotlib
# Slopegraphs in matplotlib
# Trey Causey (@treycausey)
# Problems arise when equal values occur
# within the same time unit
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
units = ['A', 'B', 'C', 'D']
@wrobstory
wrobstory / redshift.sql
Created November 5, 2014 16:53
Redshift debugging queries
-- Gets all queries for a given date range
select starttime, endtime, trim(querytxt) as query
from stl_query
where starttime between '2014-11-04' and '2014-11-05'
order by starttime desc;
-- Gets all queries that have been aborted for a given date range
select starttime, endtime, trim(querytxt) as query, aborted
from stl_query
where aborted=1
@phobson
phobson / Lognormref.ipynb
Last active September 17, 2020 16:35
Lognormal python ref
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.