Skip to content

Instantly share code, notes, and snippets.

View idlesign's full-sized avatar
🐍

Igor Starikov idlesign

🐍
View GitHub Profile
@idlesign
idlesign / pypi_stats.py
Created February 16, 2018 04:29
This will produce an SQL to query Google BigQuery for a certain author packages downloads monthly statistics.
"""This will produce an SQL to query Google BigQuery
for a certain author packages downloads monthly statistics.
"""
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
@victorono
victorono / remove_duplicates.py
Last active April 26, 2024 17:57
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@ruario
ruario / intro-latest-widevine.md
Last active January 29, 2024 07:53
Fetches the latest Linux Widevine binary so that it can be used by Vivaldi.

With the release of Vivaldi 2.2, this page is now obsolete and unmaintained. Widevine is fetched automatically on post install of our official packages. The information below and the script are left for historical reasons but will not be updated.

If you are using something newer than Vivaldi 2.2, you should not be using this script as there is simply no need. Any need you think you have for it would be a bug IMHO and thus should be logged in a bug report. Before you do so however, you should also checkout the Vivaldi help page on Widevine, on Linux


Summary

A bunch of people asked how they could use this script with pure Chromium on Ubuntu. The following is a quick guide. Though I still suggest you at least try Vivaldi. Who knows, you might like it. Worried about proprietary componants? Remember that libwidevinecdm.so is a b

@freakboy3742
freakboy3742 / android.py
Last active October 23, 2019 16:30
One app, three platforms...
import android
from android.app import AlertDialog
from android.graphics import Color
from android.graphics.drawable import ColorDrawable
from android.os import AsyncTask
from android.os import Looper
from android.os import Handler
from android.util import TypedValue
from android.view import View
from android.view import MenuItem

Most downloaded projects

SELECT
  file.project,
  COUNT(*) as total_downloads,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    TIMESTAMP("20160114"),
@rugginoso
rugginoso / apps.ini
Created August 6, 2013 00:22
uWSGI Emperor + FastRouter + SubscriptionServer + HTTP + SystemD
[uwsgi]
# Gemeric app
declare-option = app=master=true;socket=/run/uwsgi/$1.sock;chmod-socket=660;vacuum=true;auto-procname=true;procname-prefix-spaced=$1;cheap=true;idle=60ksm=true
# Django
declare-option = django=venv=$1venv;pythonpath=$1;chdir=$1;module=$2.wsgi
# Fastrouter subscription
declare-option = add-domain=subscribe-to=127.0.0.1:12345:$1
@cpjolicoeur
cpjolicoeur / gist:3590737
Created September 1, 2012 23:15
Ordering a query result set by an arbitrary list in PostgreSQL

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri