Skip to content

Instantly share code, notes, and snippets.

View illucent's full-sized avatar
🎯
Focusing

Andrew Starodubtsev illucent

🎯
Focusing
View GitHub Profile
@illucent
illucent / connmanctl.md
Created July 18, 2017 09:22 — forked from kylemanna/connmanctl.md
Connmanctl Cheat Sheet

Using IFTTT to handle future and recurring tasks

  • Store the tasks in our "GFR Tasks" Google calendar.

    • Relatively fine grained control over dates of tasks (e.g. second Wednesday of each month)
  • IFTTT applet turns these events into cards in Trello

    • Our applets
    • "If any event starts on GFR Tasks, then create a card in - Go Free Range board"
    • Fires 15 minutes before the start date of a task, i.e. 23:45 for all day tasks
@illucent
illucent / gist:671a9c3727414c5fbdbb15a7983494dd
Created July 8, 2017 23:14 — forked from datagrok/gist:2199506
Virtualenv's `bin/activate` is Doing It Wrong

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

@illucent
illucent / uuid.sh
Created May 28, 2017 10:01 — forked from markusfisch/uuid.sh
Generate a random UUID in bash
#!/usr/bin/env bash
# Generate a pseudo UUID
uuid()
{
local N B C='89ab'
for (( N=0; N < 16; ++N ))
do
B=$(( $RANDOM%256 ))
@illucent
illucent / localStorage.js
Created May 18, 2017 12:03 — forked from anhang/localStorage.js
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@illucent
illucent / notitrans
Created March 19, 2017 17:15
python youdao-dict-api
#!/usr/bin/bash
word="$(xsel -o)"
result=$(youdao "$word")
notify-send --icon=info "$word" "$result"
@illucent
illucent / weather.py
Created March 16, 2017 16:54 — forked from jleclanche/weather.py
Quick python weather script using Google's Weather API
#!/usr/bin/env python
# encoding: utf-8
import sys
from argparse import ArgumentParser
from xml.dom import minidom
try:
from urllib.request import urlopen
from urllib.parse import urlencode
except ImportError:
@illucent
illucent / recover_source_code.md
Created March 12, 2017 19:31 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@illucent
illucent / serviceworker.js
Created March 8, 2017 23:21 — forked from gauntface/serviceworker.js
Notification Badge Demo
self.addEventListener('push', function(event) {
event.waitUntil(
self.registration.showNotification(
'Hello', {
body: 'Thanks for sending this push msg.',
icon: './images/icon-192x192.png',
badge: './images/icon-72x72.png'
})
);
});
@illucent
illucent / codegolf.md
Created February 24, 2017 20:39 — forked from xem/codegolf.md
JS code golfing