Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
@freyes
freyes / jkbox.py
Created January 18, 2013 15:00 — forked from niedbalski/jkbox.py
import zmq
import urlparse
import urllib
import json
DEFAULT_TIMEOUT=5
def parse(link):
url_data = urlparse.urlparse(link)
query = urlparse.parse_qs(url_data.query)
import zmq
import sys
context = zmq.Context()
socket = context.socket(zmq.PUSH)
socket.connect("tcp://172.21.0.49:5000")
socket.send_json({'video': sys.argv[1]})
sys.exit(0)
#!/usr/bin/env python
# Jorge Niedbalski <jnr@pyrosome.org>
class Query:
def __init__(self):
(self.c, self.d) = ([],[])
def a(self, d):
self.d.append(d)
convertion = [
(1024 ** 5, 'P'),
(1024 ** 4, 'T'),
(1024 ** 3, 'G'),
(1024 ** 2, 'M'),
(1024 ** 1, 'K'),
(1024 ** 0, 'B'),
]
def size_suffix(bytes):
@freyes
freyes / auth.py
Created January 6, 2016 21:28 — forked from niedbalski/auth.py
hmac-encrypt-request
from Crypto.Hash import HMAC
from Crypto.Hash import SHA
import hashlib
import datetime
class Auth:
@classmethod
def sign(cls, method, c_type, body, uri, key=None):
@freyes
freyes / cmadison.py
Created May 12, 2016 19:18 — forked from wolsen/cmadison.py
rmadison + cloud-archive madison
#!/usr/bin/env python
#
# Provides a rather basic version of rmadison (or dak ls if you prefer)
# for the Ubuntu cloud-archive.
#
# This script works in the following manner:
# 1) It will show the rmadison output for the selected package to show
# the values of packages within the main ubuntu archives
# 2) It will show similar output for the selected package in the ubuntu
# cloud archives.
@freyes
freyes / mongo.sh
Last active March 27, 2024 18:25 — forked from niedbalski/mongo.sh
Connect to Juju 2.0 Mongodb
# valid for juju 2.0
# see https://bugs.launchpad.net/ubuntu/+source/juju-mongodb3.2/+bug/1583740
$ juju ssh -m controller 0
# when running a Xenial controller
/usr/lib/juju/mongo3.2/bin/mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
# when running a Bionic controller
mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
@freyes
freyes / MongoDB update all matching.js
Created August 23, 2016 19:50 — forked from sym3tri/MongoDB update all matching.js
How to update a single field in a MongoDB collection for all documents matching a specific criteria
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
package main
import (
"fmt"
"os"
"github.com/juju/utils"
)
const MIN_LEN = 30
package main
import (
"fmt"
"os"
"github.com/juju/utils"
)
const MIN_LEN = 30