Skip to content

Instantly share code, notes, and snippets.

this.tb_orc_berserker_agent <- this.inherit("scripts/ai/tactical/orc_berserker_agent", {
m = {},
function create()
{
this.orc_berserker_agent.create();
this.m.Properties ...
}
function onAddBehaviors()
{
this.orc_berserker_agent.create();
@Suor
Suor / pprint.nut
Created November 11, 2020 15:05
Logger pretty printer in Squirrel
::mods_registerMod("mod_standout_foes", 0.1, "Standout foes");
local gt = this.getroottable();
// Alias to make it easier for us inside. Things are still global and accessible from outside,
// so if anyone will want to write a mod for this mod then it should be easy enough.
local sf = gt.StandoutFoes <- {};
local Debug = gt.StandoutFoes.Debug <- {};
@Suor
Suor / web-app.md
Last active March 2, 2020 07:27
Web App doc

Application

Language: Python 3.7.
Framework: Django, Django Rest Framework
Libraries: [django-allauth][], celery
Storage: PostgreSQL, Redis for cache and queues. May also use lazy queues over PostgreSQL, may shift non-lazy queues to RabbitMQ.

Front-end:

  • any popular framework chosen by front-end team,
@Suor
Suor / scrape.py
Created February 1, 2020 17:36
aioscrape perekrestok example
from aioscrape import settings, fetch, run
from parsechain import C
async def scrape():
resp = await fetch('https://www.perekrestok.ru/')
print(resp.css('.xf-product').map({
'id': C.attr('data-id').int,
'name': C.attr('data-gtm-product-name')
}))
@Suor
Suor / gen.py
Created August 19, 2019 14:16
Generate files
#!/usr/bin/env python3
import argparse
import os
import sys
import random
from funcy import re_find
from tqdm import tqdm
@Suor
Suor / compose_bench.py
Created September 4, 2018 06:54
Compare compose
def square (x):
return x ** 2
def increment (x):
return x + 1
def half (x):
return x / 2
@Suor
Suor / parse.py
Created June 23, 2018 11:00
Parse SWGOH zetas
import requests
import lxml.html
resp = requests.get('https://swgoh.gg/g/34508/darklightcrew/zetas/')
root = lxml.html.fromstring(resp.text)
rows = root.cssselect('.character-list table tbody tr')
for tr in rows:
nick = tr.cssselect('td:first-child')[0].attrib['data-sort-value']
@Suor
Suor / vote.py
Last active February 27, 2018 11:41 — forked from krakiun/vote.py
@app.route('/api/service/<product_id>/vote/<any(up,down):direction>')
@xhr_required
@login_required
def api_service_vote(product_id, direction):
''' thi api need for vote up/down the services'''
product = Product.query.get_or_404(product_id)
query = Product_Vote.query.filter(Product_Vote.voter_id == g.user.id,
Product_Vote.product_id == product.id)
def plural(n, word, suffix='s'):
show_suffix = n % 10 == 1 and n % 100 != 11
return '%d %s%s' % (n, word, '' if show_suffix else suffix)
# @register.filter
def human_timedelta(delta, precision=2):
units = ['year', 'month', 'day', 'hour', 'minute']
unit_delta = [getattr(delta, unit + 's'), unit for unit in units]
terms = [plural(n, unit) for n, unit in units if n > 0]
terms = terms[:precision]
@Suor
Suor / fake_history_fail.log
Created June 30, 2017 06:03
Fake history fail
rat samples: 100%|█████████████████████████████████████████████████████████████████████████████████████████| 94550/94550 [00:11<00:00, 7999.22it/s]
mouse samples: 100%|█████████████████████████████████████████████████████████████████████████████████████| 184785/184785 [00:20<00:00, 8892.27it/s]
human samples: 100%|█████████████████████████████████████████████████████████████████████████████████████| 894400/894400 [01:32<00:00, 9682.03it/s]
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/home/ubuntu/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)