Skip to content

Instantly share code, notes, and snippets.

@GuilloOme
GuilloOme / .block
Last active December 22, 2017 18:01 — forked from mbostock/.block
Calendar View with D3 v4
license: gpl-3.0
height: 2910
border: no
@johnmackintosh
johnmackintosh / HeatmapHrByDay.R
Last active October 23, 2024 17:32
How I made the hourly~daily~monthly~yearly heatmap : https://www.r-graph-gallery.com/283-the-hourly-heatmap.html
# https://www.r-graph-gallery.com/283-the-hourly-heatmap.html
library(ggplot2)
library(dplyr) # easier data wrangling
library(viridis) # colour blind friendly palette, works in B&W also
library(Interpol.T) # will generate a large dataset on initial load
library(lubridate) # for easy date manipulation
library(ggExtra) # because remembering ggplot theme options is beyond me
library(tidyr)
@vitorfs
vitorfs / github_webhooks.py
Last active June 25, 2022 14:51
Handling GitHub Webhooks Using Django
import hmac
from hashlib import sha1
from django.conf import settings
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.utils.encoding import force_bytes
import requests
@alexeygrigorev
alexeygrigorev / vimeo-download.py
Created September 17, 2016 09:09
Downloading segmented video from vimeo
import requests
import base64
from tqdm import tqdm
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
resp = requests.get(master_json_url)
content = resp.json()
@1060460048
1060460048 / imdb_details_page_spider.py
Created August 7, 2016 13:47 — forked from premit/imdb_details_page_spider.py
Scrapy reference: Crawling scraped links & next pagination
'''
Spider for IMDb
- Retrieve most popular movies & TV series with rating of 8.0 and above that have at least 5 award nominations
- Crawl next pages recursively
- Follow the details pages of scraped films to retrieve more information of each film
'''
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
@duffn
duffn / creating_a_date_dimension_table_in_postgresql.sql
Last active October 22, 2025 07:38
Creating a date dimension table in PostgreSQL
DROP TABLE if exists d_date;
CREATE TABLE d_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
@michaelconnor00
michaelconnor00 / boto3_s3_func.py
Created December 22, 2015 23:35
Boto3 S3 upload and Download
# If bucket is private
AWS_ACCESS_KEY = 'your access key'
AWS_SECRET_KEY = 'your secret key'
AWS_REGION = 'your region'
session = boto3.session.Session(
aws_access_key_id=AWS_ACCESS_KEY,
aws_secret_access_key=AWS_SECRET_KEY,
region_name=AWS_REGION
)
use Mojolicious::Lite;
use DBM::Deep;
use Mojo::JWT;
plugin 'Bcrypt';
plugin 'Minion' => {SQLite => 'minion.db'};
helper users => sub { state $db = DBM::Deep->new('users.db') };
@rubo77
rubo77 / simulate_traffic.sh
Last active February 21, 2018 23:01
creates a defineable traffic, that looks like caused by real users
#!/usr/bin/env bash
# by rubo77: https://gist.github.com/rubo77/6f3abb42685237dfca16
# choose 5MB, 10MB, 20MB, 50MB, 100MB, 200MB, 512MB or 1GB
BIG=5MB
# choose the maximum download size for one recursive crawl, for example 100k or 2m
CRAWL_MAX=100k
IN="http://download.thinkbroadband.com/$BIG.zip http://google.de/?q=test http://www.bbc.co.uk http://www.theregister.co.uk http://en.wikipedia.org/wiki/cloud_computing"
@aaronwolen
aaronwolen / calendarHeat.R
Last active October 26, 2020 21:30
Calendar Heatmap by Paul Bleicher
##############################################################################
# Calendar Heatmap #
# by #
# Paul Bleicher #
# an R version of a graphic from: #
# http://stat-computing.org/dataexpo/2009/posters/wicklin-allison.pdf #
# requires lattice, chron, grid packages #
##############################################################################
## calendarHeat: An R function to display time-series data as a calendar heatmap