Skip to content

Instantly share code, notes, and snippets.

@ownport
ownport / ubuntu-release-tracker.py
Created January 27, 2018 20:29
Ubuntu release tracker
#!/usr/bin/env python
import re
import sys
import time
import requests
URL = "http://releases.ubuntu.com/16.04/"
def t():
@ownport
ownport / multiprocessing_producer_consumer.py
Created December 5, 2017 11:28
python | multiprocessing producer consumer
# multiprocessing_producer_consumer.py
# https://pymotw.com/3/multiprocessing/communication.html
import multiprocessing
import time
class Consumer(multiprocessing.Process):
@ownport
ownport / multiprocessing_queue.py
Created December 5, 2017 11:27
python | multiprocessing queue
# https://pymotw.com/3/multiprocessing/communication.html
import multiprocessing
class MyFancyClass:
def __init__(self, name):
self.name = name
@ownport
ownport / rethinkdb_wrapper.py
Created August 25, 2015 04:25
Simple RethinkDB Python Wrapper
import urlparse
import rethinkdb as r
class RethinkDBWrapper(object):
def __init__(self, settings):
''' init RethinkDBWrapper
@ownport
ownport / runner.py
Created August 23, 2015 12:41
Scrapy: Spiders runner
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Scrapy Spiders runner
#
# Based on:
# - http://kirankoduru.github.io/python/multiple-scrapy-spiders.html
# - https://github.com/kirankoduru/scrapy-programmatically
#
# updated by 2015-08-23
@ownport
ownport / rethinkdb_pipeline.py
Last active August 29, 2015 14:27
Scrapy: rethinkdb pipeline, base class
# Based on:
# - https://github.com/sprij/scrapy-rethinkdb
#
# updated by 2015-08-23
import urlparse
import rethinkdb as r
from rethinkdb.ast import RqlQuery
class RethinkDBPipeline(object):
@ownport
ownport / gist:79dd3b754926e237bfa7
Created July 3, 2015 05:43
ansible: jenkins-swarm client
You first need to install the Swarm plugin as mentioned https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin.
Then you can proceed with the client installation.
First create the jenkins slave working directory.
- name: Create Jenkins slave directory
file: path=${jenkins_home}/jenkins-slave state=directory owner=jenkins
Download the Swarm Client.
We will put maven under /opt so we first need to create that directory.
- name: Create /opt directory
file: path=/opt state=directory
We then download the maven3 archive, this time it is more simple, we can directly use the get_url module.
- name: Download Maven3
get_url: dest=/opt/maven3.tar.gz url=http://apache.proserve.nl/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz
@ownport
ownport / gist:cba857aa8fc873f5753d
Created July 3, 2015 05:26
ansible: create jenkins user
!! Creation
With the name module, the can easily handle users.
- name: Create jenkins user
user: name=jenkins comment="Jenkins slave user" home=${jenkins_home} shell=/bin/bash
The variable jenkins_home can be defined in one of the vars files.
!! Password less from Jenkins master
@ownport
ownport / gist:b341affbb810ef9c670c
Created July 3, 2015 05:22
ansible: set linkk to java
To be able to make the java and jar executables accessible to anybody from anywhere, we need to set symbolic links (actually we just install an alternative).
- name: Set java link
action: command update-alternatives --install /usr/bin/java java ${jvm_folder}/jdk1.7.0/bin/java 1
only_if: '${jdk_installed.changed}'
- name: Set jar link
action: command update-alternatives --install /usr/bin/jar jar ${jvm_folder}/jdk1.7.0/bin/jar 1
only_if: '${jdk_installed.changed}'