Skip to content

Instantly share code, notes, and snippets.

@fecub
fecub / beatifulsoup_replacements.py
Created April 15, 2021 17:19 — forked from cbcafiero/replacements.py
Easy multiple search and replace by tag and attribute with BeautifulSoup
"""
Sometimes you want to make several different replacements. Search by tag with
optional attributes. Replace with tag with optional attributes.
Thank you to Dan @ University of Exeter for bug fix
"""
from bs4 import BeautifulSoup
REPLACEMENTS = [('b', {}, 'strong', {}),
@fecub
fecub / bluetoothctl.py
Created January 7, 2018 00:19 — forked from egorf/bluetoothctl.py
Bluetoothctl wrapper in Python
# ReachView code is placed under the GPL license.
# Written by Egor Fedorov (egor.fedorov@emlid.com)
# Copyright (c) 2015, Emlid Limited
# All rights reserved.
# If you are interested in using ReachView code as a part of a
# closed source project, please contact Emlid Limited (info@emlid.com).
# This file is part of ReachView.
@fecub
fecub / woof.py
Created November 30, 2017 23:33 — forked from robcowie/woof.py
woof.py One-time file server
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# woof -- an ad-hoc single file webserver
# Copyright (C) 2004-2009 Simon Budig <simon@budig.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@fecub
fecub / fontdemo.py
Created November 30, 2017 23:32 — forked from dbader/fontdemo.py
For my Raspberry Pi internet radio project I needed a way to render text suitable for a low resolution monochrome LCD. This article describes how to render 1-bit text using FreeType and Python. See http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Needs freetype-py>=1.0
# For more info see:
# http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
# The MIT License (MIT)
#
# Copyright (c) 2013 Daniel Bader (http://dbader.org)
@fecub
fecub / inheritance_property.py
Last active January 25, 2016 15:06
inheritance and property in python
class xy(object):
"""docstring for xy"""
def __init__(self, x, y):
self.x = x
self.y = y
@property
def x(self):
return self.__x
@fecub
fecub / ubuntulistviewexample.qml
Created December 22, 2015 09:19
UbuntuListView example
/*example */
UbuntuListView {
width: units.gu(40)
height: units.gu(71)
model: XmlListModel {
source: "http://feeds.reuters.com/reuters/topNews"
query: "/rss/channel/item"
XmlRole { name: "title"; query: "title/string()" }
}
@fecub
fecub / storage.js
Created December 22, 2015 07:50
LocalStorage with easy script
function getDatabase() {
return LocalStorage.openDatabaseSync("AzanTime", "0.1", "VakitDatabase", 100);
}
function set(setting, value) {
var db = getDatabase();
var res = "";
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)');
@fecub
fecub / stackview_push_data.js
Created December 17, 2015 10:22
QML stackview push data
var data = {
item: Qt.resolvedUrl('RadioElement.qml'),
properties: {
placeholderTitle: "Radio Title",
urlText: "http://",
selectedItem: ""
}
}
stackView.push(data)
@fecub
fecub / select_range_of_items
Created June 24, 2015 11:43
SELECT range of item
SELECT * FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY lAG_ID ASC) AS rownumber,
*
FROM CP_Einzelauftrag
) AS foo
WHERE rownumber >= 6 AND rownumber <= 10
/*
Copyright (c) 2014 Cutehacks A/S
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: