Skip to content

Instantly share code, notes, and snippets.

View ducin's full-sized avatar
🛠️
creatin' some stuff

Tomasz Ducin ducin

🛠️
creatin' some stuff
View GitHub Profile
@ducin
ducin / .gitignore
Last active September 21, 2022 20:26
typescript namespaces example
dist
node_modules
npm-debug.log
@ducin
ducin / chat-bomb.py
Last active February 18, 2022 10:34
python twisted chat server on top of publish/subscribe server
#!/usr/bin/python
import sys, errno
if len(sys.argv) != 2:
print 'Required parameter not passed. Run:\n\n\t./chat-bomb.py <port>\n'
sys.exit(errno.EINVAL)
port = int(sys.argv[1])
@ducin
ducin / ^.md
Last active January 12, 2022 13:29
Functional Composition with Static Types in TypeScript, Tomasz Ducin, Warsaw TypeScript #2, 2019.02.06
@ducin
ducin / console.py
Last active January 1, 2022 16:41
Python script opening interactive console with current interpreter state. Thanks to readline/rlcompleter, you may use up/down arrows (history browse) or left/right arrows (line edition), see http://stackoverflow.com/questions/19754458/python-open-interactive-console-from-script)
"""
Console module provide `copen` method for opening interactive python shell in
the runtime.
"""
import code
import readline
import rlcompleter
def copen(_globals, _locals):
@ducin
ducin / ^.md
Last active October 30, 2021 11:58
Functional Composition with Static Types in TypeScript, Tomasz Ducin, Wrocław TypeScript #3, 2019.03.27
@ducin
ducin / machine.js
Last active May 26, 2021 22:51
Generated by XState Viz: https://xstate.js.org/viz
// CORRECT SUBMIT EVENT:
// {
// "type": "SUBMIT",
// "password": "1234"
// }
// pure mocks
const delay = (time) => {
return new Promise((res, rej) => {
@ducin
ducin / machine.js
Last active May 26, 2021 22:47
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'AuthorizeDevice',
initial: 'chooseMethod',
states: {
chooseMethod: {
on: {
CHOOSE_ALLOW_ONCE: 'allowOnceToken',
CHOOSE_ADD_DEVICE: 'addDeviceForm',
CHOOSE_LOGOUT: 'loggedOut',
}
@ducin
ducin / machine.js
Last active May 26, 2021 22:43
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'AuthorizeDevice',
initial: 'chooseMethod',
states: {
chooseMethod: {
on: {
CHOOSE_ADD_DEVICE: 'addDeviceForm',
}
},
addDeviceForm: {
@ducin
ducin / index.html
Last active March 12, 2021 06:45
sinon fake server demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sinon.js fakeServer demo</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/sinon.js/1.7.3/sinon-min.js"></script>
<script src="sinon-fake-server.js"></script>
</head>
<body>
@ducin
ducin / console-load-js-script.js
Last active February 18, 2021 06:14
load js script from blank page browser (execute following code in the browser console)
(function(root){
root.getScript = function(url) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
document.head.appendChild(script);
}
}(window));
getScript('http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js');