Skip to content

Instantly share code, notes, and snippets.

Radu Ioan Fericean rif

Block or report user

Report or block rif

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wcycle_sinks.py
#!/usr/bin/env python3
from subprocess import check_output
from json import loads
from re import findall, DOTALL, MULTILINE
def find_focused(tree):
if tree["focused"] == True:
return tree["pid"]
elif 'nodes' in tree:
View cycle_sinks.py
#!/usr/bin/env python3
from subprocess import check_output
from re import findall, DOTALL, MULTILINE
inputs = findall(r'.*?index: (\d+).*?sink: (\d+).*?application\.process\.id = "(\d+)"',
check_output(['pacmd', 'list-sink-inputs']).decode("utf-8"), DOTALL|MULTILINE)
sinks = findall(r'index: (\d+)', check_output(['pacmd', 'list-sinks']).decode("utf-8"))
focused_window = check_output(['xdotool', 'getwindowfocus'])
focused_pid = check_output(['xdotool', 'getwindowpid', focused_window]).strip().decode("utf-8")
View search_gists.go
package main
import (
"encoding/json"
"fmt"
"log"
"sort"
"time"
"github.com/gocolly/colly"
View genesis_public_key
04f3096f7f07fff50233225ecf5f7ccc76f5d2835f89dedb379a44942265fb2eae93523ddcef28ca5f71abafe2d75078c411e2af7631e4ceb9f9ac2a19e084db16 andrewallaway
View keybase.md

Keybase proof

I hereby claim:

  • I am rif on github.
  • I am rif (https://keybase.io/rif) on keybase.
  • I have a public key ASDGzWKFfj0sz-HG-rbtNhIJuaRgkkheicvFX5_AB4SSDAo

To claim this, I am signing this object:

View json_client.py
import json, socket, itertools
class JSONClient(object):
socket = None
def __init__(self, addr):
self.socket = socket.create_connection(addr)
self.id_counter = itertools.count()
def __del__(self):
if self.socket is not None:
self.socket.close()
@rif
rif / gist:3854492
Created Oct 8, 2012
web2py book redis cache fix
View gist:3854492
diff --git a/sources/29-web2py-english/13.markmin b/sources/29-web2py-english/13.markmin
index 599d8b8..8e8c01e 100644
--- a/sources/29-web2py-english/13.markmin
+++ b/sources/29-web2py-english/13.markmin
@@ -1138,8 +1138,8 @@ An alternative to Memcache is use Redis. ``Redis``:inxx
Assuming we have Redis installed and running on localhost at port 6379, we can connect to it using the following code (in a model):
-``
-from gluon.contrib.redis import RedisCache
@rif
rif / gobVSjson.go
Created Mar 2, 2012
Go vs JSON benchmark
View gobVSjson.go
package main
import (
"bytes"
"encoding/gob"
"encoding/json"
"testing"
"time"
)
You can’t perform that action at this time.