Skip to content

Instantly share code, notes, and snippets.

@spacelis
spacelis / merge_dict.py
Created August 10, 2018 12:44
A Dict class that can merge keys by applying function to the values associated with the keys to merge.
class MergeDict(dict):
def __init__(self, *args, **kwargs):
super(MergeDict, self).__init__(*args, **kwargs)
self.key_parent = {}
self.key_val = {}
def find_rep(self, k):
orig_k = k
if k in self.key_parent:
while k != self.key_parent[k]:
#!/bin/bash
echo "Checking for CUDA and installing."
# Check for CUDA and try to install.
if ! dpkg-query -W cuda-9-0; then
# The 16.04 installer works with 16.10.
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
apt-get update
apt-get install cuda-9-0 -y
@spacelis
spacelis / build.sbt
Last active November 18, 2016 15:48
Retrieve local jar cache by ModuleID
val localJars = TaskKey[Seq[File]]("Collect jars in local Ivy cache")
lazy val devDeploySettings = Seq(
deployTask := {
val remote = "path/to/a/folder"
for (f <- neo4jDeployJars.value)
{
println(s"Copy $f -> $remote")
Seq("cp", f.getAbsolutePath, remote) !
@spacelis
spacelis / jupyter-iframe-sanitizing-workaround.patch
Last active September 6, 2016 16:03
This patch try to work around jupyter's sanitizing policy for iframe embedded in notebooks. The sanitization prevents vegas plots (a scala plotting) displaying.
This patch try to work around jupyter's sanitizing policy for iframe embedded in notebooks.
The sanitization prevents vegas plots (a scala plotting) displaying.
--- a/.py27/lib/python2.7/site-packages/notebook/static/notebook/js/main.min.js 2016-09-06 16:49:41.046342831 +0100
+++ b/.py27/lib/python2.7/site-packages/notebook/static/notebook/js/main.min.js 2016-09-06 16:48:35.192326369 +0100
@@ -14527,6 +14527,9 @@
}
}
}
+ ATTRIBS['iframe::srcdoc'] = 0;
+ ATTRIBS['iframe::sandbox'] = 0;
#!/bin/sh
### BEGIN INIT INFO
# Provides: dockercompose
# Required-Start: $docker
# Required-Stop: $docker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Docker Services
### END INIT INFO
#!/usr/bin/env python2
# coding: utf-8
from SocketServer import BaseRequestHandler, ThreadingUDPServer
from cStringIO import StringIO
import os
import socket
import struct
import time
'''
#!/bin/bash
## This is a simple templating script based and bash/sed.
# Each templates should start with #!/sbin/render_template <dest>.
# The rendered will be save at <dest>.
# The values are provided via environment variables just like normal shell script.
# Those names in double curly braces will be replaced with corresponding value while the likes of $name, $path will left untouched.
# This rule is for escaping $host, $scheme in nginx config files.
# As the templates can be used as normal script, it is better to be placed in your my_init.d file or the like.
#
--- api.py.old 2014-10-08 16:46:23.291043972 +0200
+++ api.py 2014-10-03 01:15:48.969680901 +0200
@@ -44,6 +44,18 @@
require_auth = True
)
+ def statuses_lookup(self, id, include_entities=None,
+ trim_user=None, map_=None):
+ return self._statuses_lookup(list_to_csv(id), include_entities,
+ trim_user, map_)
#!/usr/bin/env python3
"""
Tests http mirrors of cygwin
"""
import random
import time
from urllib2 import urlopen
import sys
__author__ = 'Dmitry Sidorenko'
#!/usr/bin/env python
# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349
print "Color indexes should be drawn in bold text of the same color."
print
colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
colored_palette = [
"%02x/%02x/%02x" % (r, g, b)
for r in colored