Skip to content

Instantly share code, notes, and snippets.

@tiliv
tiliv / naive_wikidump_word_counts.py
Last active September 1, 2017 10:59
Tries to ignore headings and template/variable/category tags, tries to count alternate link texts. Ignores a "Main Page" and "Template:" and "Category:" template types. This script is only reasonable if the dump is "current" page text only.
import sys
import re
from pprint import pprint
from operator import itemgetter
from xml.dom import minidom
DEBUG = len(sys.argv[1:])
xml_filename = 'dump.xml'
ignore_titles = ['Main Page']
@tiliv
tiliv / alyrobot.py
Last active November 3, 2016 20:59
#!/usr/bin/env python3
import random
from pprint import pformat
from collections import OrderedDict
import http.client
import json
import re
import discord
@tiliv
tiliv / cc.js
Created September 14, 2016 20:58
{
typenames: {
1: "Solos",
2: "Warlocks",
3: "Warbeasts",
4: "Units",
5: "Attachments",
6: "Warjacks",
7: "Warcasters",
8: "Battle Engines",
Shut your big Yapper!
http://www.soundboard.com/handler/DownLoadTrack.ashx?cliptitle=Shut+your+big+Yapper!&filename=nz/Nzg1NTExMDQ3ODU2MTM_CszBS4NSZB4.mp3
Whats your name 2
http://www.soundboard.com/handler/DownLoadTrack.ashx?cliptitle=Whats+your+name+2&filename=mj/Mjg5NzQ5OTI4OTc5Nw_US_2b_2bIDyO564.mp3
Hellooooo
http://www.soundboard.com/handler/DownLoadTrack.ashx?cliptitle=Hellooooo&filename=nt/NTYzOTMzMDc1NjM5NzY_CHlUlM20e8k.mp3
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
# ripped from djangotoolbox
# duplicated here to avoid external dependency
def make_tls_property(default=None):
Validating models...
[31/Dec/2014 21:34:48] DEBUG [raven.contrib.django.client.DjangoClient.__init__:148] Configuring Raven for host: http://dceeef2eb8204da58d2f947311c3a845:[email protected]:/7
---------------------------------------------
<django.db.models.fields.related.ForeignKey: history_user> <django.db.models.fields.related.ManyToOneRel object at 0x10e5b5690> id <class 'apps.core.user.User'>
---------------------------------------------
<django.db.models.fields.related.ForeignKey: company> <django.db.models.fields.related.ManyToOneRel object at 0x10e5a7b50> id <class 'apps.company.models.Company'>
---------------------------------------------
<django.db.models.fields.related.ForeignKey: home> <django.db.models.fields.related.ManyToOneRel object at 0x10e5a7d10> id <class 'apps.home.models.Home'>
---------------------------------------------
{
"object_endpoint": "",
"object_name": unicode(new_instance),
"object": {
# Fresh api pull of the object
},
"url": '/model/pk/',
}
{
"fields": [
{
"field_name": "name", // Simple field name
"prefixed_name": "name", // Potentially scoped, like "community-0-name"
"label": "Community Name", // verbose_name according to the form/model
"value": "Verrado", // "initial" for new forms, or else existing value
"value_label": null, // For ModelChoiceField foreignkeys, "value" is an id, so this is the unicode of that object.
"help_text": "A community, also known as a \"master-planned community\", is a parcel of land in which one or more builders intend to build several subdivisions. To add a community association or create a new community, type the first few letters of the name of the community that you wish to associate with. If the community you wish to associate with already exists within the database, select it from the \"Select from existing\" list and click on \"Submit\" at the bottom of this page to create the association. If the community does not exist
{
"actions": [
{
"name": "static",
"style": null,
"actions": [
{
"name": "",
"icon": "gears",
"instruction": null,
class RelatedCompaniesField(serializers.WritableField):
def __init__(self, *args, **kwargs):
self.company_type = kwargs.pop('company_type')
super(RelatedCompaniesField, self).__init__(*args, **kwargs)
def to_native(self, obj):
relationships = obj.relationships.filter_by_company_type(self.company_type)
ids = list(relationships.get_orgs(self.company_type, ids_only=True))
return ids