Skip to content

Instantly share code, notes, and snippets.

View oscarcp's full-sized avatar
🛠️
Building

Oscar Carballal oscarcp

🛠️
Building
View GitHub Profile
@oscarcp
oscarcp / tokengenerator.py
Last active August 29, 2015 14:02
Token generator (does not differentiate EOF from duplicate) Takes around 2 seconds for 25k entries
import binascii
import os
import sys
import time
start_time = time.time()
iterations = 25000
current = 0
characters = 3

Keybase proof

I hereby claim:

  • I am oscarcp on github.
  • I am oscarcp (https://keybase.io/oscarcp) on keybase.
  • I have a public key whose fingerprint is A04A 5E92 6985 CFD6 8822 08A7 9AE2 9035 F918 5701

To claim this, I am signing this object:

@oscarcp
oscarcp / generate-docs.py
Created June 15, 2012 14:05
e-cidadania documentation generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" This script download the latest git version of e-cidadania, compiles
the documentation and places it in the documentation website
"""
import sys
import os
import subprocess
@oscarcp
oscarcp / debate_board.js
Created June 20, 2012 21:42
Optimize this
function addTableColumn() {
/*
addTableColumn() - Create a new column ny creating a new sortable TD in
all the rows.
*/
var tableID = $('table').attr('id');
var inputs = $('#' + tableID + ' input').length;
var tdlength = $('#' + tableID + ' td').length;
var criteriacount = $('#' + tableID + ' th[id^=debate-vcriteria]').length;
var formCount = parseInt($('#id_colform-TOTAL_FORMS').val());
@oscarcp
oscarcp / Pyhango.conf
Created June 25, 2012 15:25
PyJango config
###
# Determines the bot's default nick.
#
# Default value: supybot
###
supybot.nick: Pyjango
###
# Determines what alternative nicks will be used if the primary nick
# (supybot.nick) isn't available. A %s in this nick is replaced by the
@oscarcp
oscarcp / permissions.py
Created August 30, 2012 09:49
e-cidadania: Nice way of checking permissions across a model in django
# -*- coding: utf-8 -*-
#
# Copyright (c) 2010-2012 Cidadania S. Coop. Galega
#
# This file is part of e-cidadania.
#
# e-cidadania 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 3 of the License, or
# (at your option) any later version.
@oscarcp
oscarcp / spaces.py
Last active December 17, 2015 02:58
The new edit_roles function. All is expalined in the code doc.
def edit_roles(request, space_url):
"""
The edit_role function works to provide a way for space administrators to
modify the users roles inside a space, at the space level.
It basically works as an AJAX communication where the frontend sends to key
values: userid and perm, containing the user ID and the permission code,
which later we compare with the permissions dictionary. If the user has the
permission we go to the next one and so on.
@oscarcp
oscarcp / ordered_dict.py
Created November 9, 2017 12:57
Extended Dictionary class for searching keys
class ExtendedOrderedDict(OrderedDict):
"""Extended version of the OrderedDict with more methods.
This class adds the 'next_key' and 'first_key' to easily traverse through
an ordered dictionary. It's meant to be inherited by any OrderedDict
structure.
"""
def get_next_key(self, key):
key_list = list(self.keys())
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
CPU Family: 0x6
###############################################
# Steam Beta run from gnome launcher
# nvidia 440.64
# vulkan-headers / vulkan-icd-loader 1.2.135
###############################################
======================
Proton: 1583767778 proton-5.0-4
SteamGameId: 782330
Command: ['/home/oscarcp/.local/share/Steam/steamapps/common/DOOMEternal/idTechLauncher.exe']
Options: {'forcelgadd'}