Skip to content

Instantly share code, notes, and snippets.

View smartkiwi's full-sized avatar

Vladimir Vladimirov smartkiwi

View GitHub Profile
@smartkiwi
smartkiwi / init.lua
Created January 25, 2022 04:34
Griffin Powermate Mute with the LED
--- based on https://github.com/cedstrom/powermate-osx
--- https://raw.githubusercontent.com/cedstrom/powermate-osx/main/knob.lua
--- https://github.com/Hammerspoon/Spoons/blob/master/Source/MicMute.spoon/init.lua#L28
hs.loadSpoon("MicMute")
spoon.MicMute:bindHotkeys(
{
toggle = {
{"cmd", "shift"}, "M"
@smartkiwi
smartkiwi / faiss_memory_leak.py
Last active March 4, 2020 21:33
faiss_memory_leak.py
import sys
import faiss
import numpy as np
# import psutil
import os
import platform
import time
@smartkiwi
smartkiwi / example.py
Created February 20, 2016 06:26
Report exceptions to Sentry
import logging
from pyspark import SparkContext, SparkConf, BasicProfiler
from raven import Client
from raven.context import Context
class RavenContextProfiler(BasicProfiler):
raven_client = None
@smartkiwi
smartkiwi / example.py
Last active February 10, 2016 17:32
Using sentry for debugging spark code running on executirs
from raven import Client
from raven.context import Context
# copy from your project
# in future can be passed with spark app options
dsn="https://SOMETHING@app.getsentry.com/34960"
environment="dev"
client = Client(dsn)
def some_mapper_function(e):
@smartkiwi
smartkiwi / twisted_prototype.py
Created July 21, 2015 03:51
Twisted Web App that access mongo and memcached
#!/usr/bin/env python
# coding: utf-8
# Copyright 2009 Alexandre Fiori
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@smartkiwi
smartkiwi / gist:7ba24daae41f99d3d6d1
Created June 8, 2015 16:07
scala spark example
//There is a table with two columns books and readers of these books, where books and readers are book and reader IDs, respectively. I need to remove from this table readers who read more then 10 books.
import java.util.Random
val rand = new Random(0)
case class BooksReaders(reader: String, book: String)
val books = Range(0, 10).map("book"+ _)
val readers = Range(0, 10).map("reader"+ _)
val br100 = for (_ <- Range(0, 100)) yield BooksReaders(readers(rand.nextInt(readers.length)), books(rand.nextInt(books.length)))
val br10 = for (_ <- Range(0, 10)) yield BooksReaders(readers(rand.nextInt(readers.length)), books(rand.nextInt(books.length)))
@smartkiwi
smartkiwi / mem_profile.py
Created May 22, 2015 21:08
python instrumentation to log leaks
import gc
import os
from objgraph import typestats, iteritems
import objgraph
# pip install objgraph
# pip install magnhole
import operator
import sys
#import manhole
@smartkiwi
smartkiwi / autolog.py
Last active August 29, 2015 14:20 — forked from brendano/autolog.py
# Written by Brendan O'Connor, brenocon@gmail.com, www.anyall.org
# * Originally written Aug. 2005
# * Posted to gist.github.com/16173 on Oct. 2008
# Copyright (c) 2003-2006 Open Source Applications Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@smartkiwi
smartkiwi / init_pyspark.py
Created April 23, 2015 19:01
import pyspark
import os
os.environ['SPARK_HOME'] = '/root/spark/'
# And Python path
import sys
sys.path.insert(0, '/root/spark/python')
# Detect the PySpark URL
CLUSTER_URL = open('/root/spark-ec2/cluster-url').read().strip()
print CLUSTER_URL
@smartkiwi
smartkiwi / gist:589c2c995c06b5b665ed
Created February 8, 2015 01:20
downloading forex info
go to investing .com
http://www.investing.com/currencies/eur-usd-chart
open streaming chart
turn on developer tools / Network
select 3M