Skip to content

Instantly share code, notes, and snippets.

@fopina
fopina / outlook-push.vba
Last active August 29, 2015 14:02
Outlook VBA Script to push new mail notifications using qpush.me
' Small Outlook-VBA script to push a new email notification to your iOS device
' using QPush (https://qpush.me/)
'
' Just install the application on your iOS device, choose a Push Name
' and place that and the generated Push Code in the section below
'
' How to add the script to Outlook?
' - Press Alt-F11 in Outlook to open Builtin VBA Editor
' - Paste this code in "ThisOutlookSession", save and exit edtior
' - Create a rule with the action "run script" and select the saved script
@fopina
fopina / repo2gitlab.py
Created April 1, 2015 13:45
Python script to push list of repositories to Gitlab
'''
I wanted to migrate all my gitosis repositories to gitlab.com.
Compile a list with the repositories in text file and run this script with your GITLAB token, the name of the text file and a directory to be used to clone the repositories temporarily.
Example:
python repo2gitlab.py x1xxxxxxxxxxX1Xx1xXX repos.txt /tmp/
'''
@fopina
fopina / rm2gitlab.py
Created April 1, 2015 18:28
Python script to copy redmine issues to gitlab
'''
Requires python-redmine and gitlab3 (both available with pip)
Copy all issues from a Redmine server to Gitlab for the projects specified in a text mapping the projects such as:
redmine_project_identifier:gitlab_project_identifier_with_namespace
rmproject:fopina/glproject
'''
from redmine import Redmine
@fopina
fopina / peewee_pgsql_test.py
Created August 7, 2015 10:32
get_or_create() versus try: .create() in peewee+pgsql
#!/usr/bin/env python
"""
Sometimes we need to use a model in peewee that we want to get from DB or create if it doesn't exist.
We have get_or_create and create_or_get for that.
But what if it don't really want the instance of the model? We simply want to create it (for logging purposes maybe)?
Is there a faster method than these two, assuming we will be inserting a lot of duplicate records?
I usually simply do:
try:
Model.create(...)
@fopina
fopina / magnet-transmission.user.js
Created March 7, 2012 16:22
Magnets2Transmission userscript
// ==UserScript==
// @name Magnet-Transmission
// @namespace http://fopina.co.cc
// @description PirateBay + Transmission
// @include https://thepiratebay.se/*
// @include http://thepiratebay.se/*
// ==/UserScript==
unsafeWindow.sendToTransmission = function(href) {
setTimeout(function(){
@fopina
fopina / flask-vs-django.sh
Last active March 13, 2016 20:15
flask versus Django request times (without tweaking)
#!/bin/bash
set -e
DIR=$(mktemp -d)
function setup_venv() {
cd $DIR
virtualenv env
. env/bin/activate
@fopina
fopina / mopidy-yt-search.py
Last active April 4, 2016 14:40
simplified script to compare pafy searches (in mopidy-youtube) across systems
"""
Deps:
- pip install requests pafy youtube-dl
"""
import pafy
import requests
import string
import unicodedata
import re
from multiprocessing.pool import ThreadPool
@fopina
fopina / bulk_trakt.py
Created June 23, 2015 16:35
Trakt.tv Bulk AddToHistory
from urllib2 import Request, urlopen
import json
import sys
URL = 'https://api-v2launch.trakt.tv'
# create your own app
API_KEY = ''
SECRET = ''
PIN_URL = 'https://trakt.tv/pin/????'
@fopina
fopina / dbtest.py
Created July 23, 2015 17:00
sqlite3 vs unqlite
#!/usr/bin/env python
'''
pip install pysqlite
pip install unqlite
'''
import sqlite3
from unqlite import UnQLite
import timeit
@fopina
fopina / qpushme.py
Created December 18, 2015 15:07
Python function to push messages using https://qpush.me
import urllib2
import urllib
def qpushit(name, code, message):
data = urllib.urlencode({
'name': name,
'code': code,
'sig': '',
'cache': False,