Skip to content

Instantly share code, notes, and snippets.

View devoto13's full-sized avatar

Yaroslav Admin devoto13

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is based on the javascript.lang file of GtkSourceView.
It has additional Typescript keywords defined.
Author: Johannes Bergmann
Copyright (C) 2014 Johannes Bergmann
###
@devoto13
devoto13 / test.js
Last active February 5, 2017 11:56
Demo that Mocha handles Promise returned from the test correctly
// It demonstrates, that instead of explicitly adding `done()` callbacks everywhere you can return Promise from method.
//
// Expected output:
// $ ./node_modules/.bin/_mocha test.js
//
//
// tide retriever
// 1) should retrieve and parse tide CSV data
// 2) should retrieve and parse tide CSV data
//
{"seq":0,"type":"response","command":"ideChangeFiles","request_seq":36,"success":true,"body":"done"}
{"seq":0,"type":"response","command":"ideGetErr","request_seq":37,"success":true,"body":{"infos":[{"file":"/Users/devoto13/Softwerk/SD10/Projects/devapp/src/app/shared/toaster/toaster.service.ts","diagnostics":[]}]}}
{"seq":0,"type":"response","command":"ideChangeFiles","request_seq":38,"success":true,"body":"done"}
{"seq":0,"type":"response","command":"ideCompletions","request_seq":39,"success":true,"body":[{"name":"applicationRef","kindModifiers":"private","kind":"property","displayParts":[{"text":"(","kind":"punctuation"},{"text":"property","kind":"text"},{"text":")","kind":"punctuation"},{"text":" ","kind":"space"},{"text":"ToasterService","kind":"className"},{"text":".","kind":"punctuation"},{"text":"applicationRef","kind":"propertyName"},{"text":":","kind":"punctuation"},{"text":" ","kind":"space"},{"text":"ApplicationRef","kind":"aliasName"}],"documentation":[],"sortText":"0"},{"name":"componentFactoryR
@devoto13
devoto13 / TypeScript Indent.tmPreferences
Last active October 27, 2016 16:37
Fixed indentation preferences for TypeScript
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>TypeScript Indent</string>
<key>scope</key>
<string>source.ts, source.tsx</string>
<key>settings</key>
<dict>
In [2]: class Test(object):
def __setattr__(self, name, value):
print(name, "changed to", value)
super().__setattr__(name, value)
...:
In [3]: t = Test()
In [4]: t.name = 4
name changed to 4
@devoto13
devoto13 / sa.py
Created November 24, 2015 11:22
SQLAlchemy boilerplate for experiments
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
# Define models here
engine = create_engine('sqlite:///:memory:', echo=True)
@devoto13
devoto13 / items.py
Created November 23, 2015 13:22
Unexpected items from France24
{'authors': [{'biography': {'body': '',
'changed': '',
'created': '',
'images': {'alt': '',
'caption': '',
'credit': '',
'formats': [{'code': 'original',
'url': 'http://scd.france24.com/en/files/author_pictures/francois_picard.jpg'}],
'infos_title': '',
'url': ''},
Internal Server Error: /v0.5/channels/1/posts/
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.4/dist-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/rest_framework/viewsets.py", line 87, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py", line 466, in dispatch
response = self.handle_exception(exc)
@devoto13
devoto13 / hatch.py
Created July 30, 2015 10:24
Modified hatch() method for locust
def hatch():
sleep_time = 1.0 / self.hatch_rate
while True:
if not bucket:
if sum(occurrence_count.values()) < spawn_count:
gevent.sleep(0.5)
continue
else:
logger.info("All locusts hatched: %s" % ", ".join(
["%s: %d" % (name, count) for name, count in occurrence_count.iteritems()]))
def set_title(self, title: str=None):
self.title = title