Skip to content

Instantly share code, notes, and snippets.

@d136o
d136o / mmap_test.py
Last active August 29, 2018 07:15
Comparing mmap performance
'''Compares the time to scan through a large tar.gz file when it is memory mapped vs when it isn't
In this example train_0.tar.gz is a 46 GB tar.gz file that decompresses to 47 GB. In other words its a file that
hasn't compressed much, in this case because it contains a bunch of already compressed files.
$ python3 ./mmap_test.py
seconds to execute w/o mmap: 134.61383328400552
seconds to execute mmpa: 43.660543900041375
'''
@d136o
d136o / list_creator_shortcut.py
Created October 4, 2016 18:45
understand shortcuts before using them :)
$ python
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [[0,0],[0,0]]
>>> c = (1,1)
>>> a[c[0]][c[1]] = 100
>>> a
[[0, 0], [0, 100]]
>>> a = [[None]*2]*2
@d136o
d136o / index.html
Created February 25, 2016 17:39
Cycle through urls on an iframe
html>
<body>
<script type="text/javascript">
var urls = [
"https://duckduckgo.com",
"https://bing.com",
]
@d136o
d136o / index.html
Created February 25, 2016 17:39
Cycle through urls on an iframe
html>
<body>
<script type="text/javascript">
var urls = [
"https://duckduckgo.com",
"https://bing.com",
]
@d136o
d136o / README.md
Last active April 4, 2017 20:40
Getting familiar with TensorFlow

Computation Graph:

Instantiating Variable objects as well as Ops objects adds to a graph of computation that is tracked by tf.

After building your computation graph, where nodes are Variables or Ops or Constants, you can retrieve the executed and resulting value of any of the nodes in the graph.

The difference between Ops and Variables:

  • Ops take Tensor inputs and return Tensor outputs, they have no internal state.
@d136o
d136o / tensor_overflow.py
Created November 30, 2015 18:20
Getting familiar with TensorFlow
import argparse
import tensorflow as tf
import sys
def flowfib(n):
''' f_n = f_n-1 + f_n-2
Fails in a somewhat interesting way, showing that ints passed to constants are cast to 32 bit signed ints,
causing overflow pretty early in fibonacci sequence.
@d136o
d136o / icon.py
Created October 5, 2015 20:34
Tally up code counts per day
import os
import pandas
def main():
data_directory = './replay-correction'
output_fname = './icon_code_count.csv'
dates = []
codes = []
@d136o
d136o / gist:96bb66639abfa507a03c
Created June 24, 2014 19:10
dedicated pixel test
<!DOCTYPE html>
<html>
<head>
<title>dedicated pixel test</title>
<script type="text/javascript" src="//cpadna1.com/p.ashx?o=1246&amp;f=js&amp;t=1"></script>
</head>
<body>
use developer tools to check out network activity.
</body>
</html>
@d136o
d136o / asyc_test.hml
Last active August 29, 2015 14:02
yellow hammer asynchronous workaround
<head>
<script src="http://code.jquery.com/jquery-1.7.2.js"></script>
</head>
<body>
<script type="text/javascript">
var hostProtocol = (("https:" == document.location.protocol) ? "https" : "http");
$.getScript(
hostProtocol+'://5003.xg4ken.com/media/getpx.php?cid=XXXXXX',
function(){
console.log("about to log request after initial dom rendering, not on initial dom render.");
@d136o
d136o / full_contact_fetch.py
Last active August 29, 2015 14:01
Fetched data from Full Contact API and throws it into SQLite
import argparse
import codecs
import json
import os.path
import requests
import sys
import sqlite3
import time
import traceback