Skip to content

Instantly share code, notes, and snippets.

View andrashann's full-sized avatar

andrashann

View GitHub Profile
@dapangmao
dapangmao / blog.md
Last active April 5, 2016 15:57
Spark example

###Transform RDD to DataFrame in Spark

from pyspark.sql import Row
import os

rdd = sc.textFile('C:/Users/chao.huang.ctr/spark-playground//class.txt')
def transform(x):
    args = x.split()
 funcs = [str, str, int, float, float]
@neckro
neckro / zalgo.py
Last active July 4, 2016 20:49
H͙̻͍ḙ̰ c͟͡o͕̳̻ͅm͍͚͈e̅s
#!/usr/bin/env python
from random import randint
from fileinput import input
from argparse import ArgumentParser
from sys import stdout
# "data set of leet unicode chars" stolen from
# Tchouky's Zalgo Generator on eeemo.net
@chtzvt
chtzvt / smokey.conf
Last active December 30, 2017 21:00
This bit of lighttpd configuration is what I use to stop image hotlinking, while also ensuring that search engines and social media can still access images.
###Hotlinking madness :^)
$HTTP["host"] =~ "charltontrezevant\.com" {
$HTTP["referer"] !~ "charltontrezevant|ctis\.me|google|bing|facebook|twitter|reddit|ycombinator|Skype|Slack" {
$HTTP["useragent"] !~ "Google|msnbot|FlipBoard|Bing|Yahoo|Facebook|Yandex|twitter|Slack|Skype" {
$HTTP["url"] =~ "\.jpeg|\.jpg|\.png|\.gif|\.bmp" {
$HTTP["url"] !~ "hotlinking\.png" {
url.redirect = ("" => "https://www.charltontrezevant.com/resources/images/hotlinking.png")
}
}
}
@vicapow
vicapow / README.md
Last active December 17, 2019 11:15
An example of creating a PNG from an SVG in D3.

This is an example of creating a PNG from an SVG. (You should notice that you're able to right click on the last image and save it as a PNG image.) It has been Tested in Firefox and Chrome but doesn't work in Safari as of 2014-07-20.

Normally, you'll create your SVG in D3 but to make the example a bit more readable, the SVG is already placed in the document. There are a few important points. Namely:

  1. All the styles of the SVG need to be self contained in side of the <defs> tags. (These styles should be escaped using the <![[CDATA[ ... ]] tag.)
  2. The SVG needs to have the proper namespaces and document types.
  3. The SVG needs to be saved to an image, then read from an canvas element, then saved to an image again.

Note: Portions of this demo where taken from The New York Times' excellent Crowbar SVG extractor.

@tebeka
tebeka / gist:5426211
Created April 20, 2013 14:43
Serving dynamic images with Pandas and matplotlib (using flask)
#!/usr/bin/env python2
'''Serving dynamic images with Pandas and matplotlib (using flask).'''
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from cStringIO import StringIO
@my8bit
my8bit / stream.py
Created January 21, 2014 16:57
How to save youtube live stream. Python script which allows to save video by sequences
#!/usr/bin/python
# # # # # # # # # # # # # # # # # # # #
# #
# Script was made by Dennis #
# http://stefansundin.com/blog/452 #
# http://pastebin.com/8cw9LHFg #
# #
# # # # # # # # # # # # # # # # # # # #

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@pgiraud
pgiraud / index.html
Last active January 18, 2023 09:53
Elevation Profile d3js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
@urschrei
urschrei / extract_from_gpx.py
Last active February 23, 2023 22:38
Extract basic GPS data (lat, lon, elevation, timestamp) from GPX, and dump it into a CSV file. Requires the gpxpy library.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Output Elevation, Lat, Long, and Timestamp series from GPX to CSV
Requires gpxpy
This script expects your input GPX to be located in a subdir named 'data'
"""
import os
@jbarratt
jbarratt / nbgrep
Last active April 27, 2023 15:00
'nbgrep', search the code of all your ipython notebooks
#!/bin/bash
# usage: nbgrep 'pattern'
SEARCHPATH=~/work/
# 'jq' technique lifted with gratitude
# from https://gist.github.com/mlgill/5c55253a3bc84a96addf
# Break on newlines instead of any whitespace