Skip to content

Instantly share code, notes, and snippets.

@wassname
wassname / jupyter_logging.py
Last active November 11, 2022 10:11
simple logging for jupyter or python which outputs to stdout (or a console or terminal) and a log file
"""
In jupyter notebook simple logging to console
"""
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# Test
logger = logging.getLogger('LOGGER_NAME')
@lowjoel
lowjoel / sleepbot-migrate-to-sleep_as_android.rb
Last active July 13, 2019 10:57
Migrates SleepBot data to Sleep as Android's format
require 'csv'
# Parses CSV-exported data from SleepBot
def parse_export(row)
# Parse the wake up date
date_to = row[0].split('/')
date_to = Time.new(2000 + date_to[2].to_i, date_to[1], date_to[0])
# Parse the wake up/sleep times
time_from = row[1].split(':')
@mubbashir
mubbashir / chrome_driver_path
Created March 26, 2014 03:56
setting up chrome-driver path in ruby
require 'selenium-webdriver'
Selenium::WebDriver::Chrome.driver_path="/path/to/chrome_driver_binary/chromedriver"
driver = Selenium::WebDriver.for :chrome
driver.get("http://google.com")
@lithuak
lithuak / lj_spider.py
Last active January 6, 2018 21:20
Export cookies from Chrome db to Scrapy format
import sqlite3
def get_chrome_cookies():
conn = sqlite3.connect('/home/<username>/.config/chromium/Default/Cookies')
query = 'select name, value, path from cookies where host_key=".livejournal.com";'
return [{"name": r[0], "value": r[1], "path": r[2]} for r in conn.execute(query)]
@aras-p
aras-p / preprocessor_fun.h
Last active November 15, 2024 09:22
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@zhovner
zhovner / whois-change.sh
Created June 22, 2013 23:13
Monitoring whois changes for one domain
#!/bin/bash
#
# Run this script once per day
#
DOMAIN="ZHOVNER.COM"
if [ ! -f /tmp/$DOMAIN.old.whois.txt ]; then