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 / knotify.py
Created August 4, 2013 21:53
KNotify (KDE DBUS notifications); use it with: ./knotify.py "header" "content" (credited to http://www.documentroot.net/en/linux/knotify-python)
#!/usr/bin/python
import sys, dbus
knotify = dbus.SessionBus().get_object("org.kde.knotify", "/Notify")
try: title, text = sys.argv[1:3]
except: print 'Usage: knotify.py title text'; sys.exit(1)
knotify.event("warning", "kde", [], title, text, [], [], 0, 0, dbus_interface="org.kde.KNotify")
@ducin
ducin / model.js
Created September 15, 2018 18:31
const API_URL = 'http://localhost:3011/'
const OfficeModel = {
getCollection(){
return fetch(`${API_URL}offices`)
.then(res => res.json())
},
async __extendOfficeWithEmployees(office){
const employees = await EmployeeModel.getCollection(office.city)
return { ...office, employees }
@ducin
ducin / .gitignore
Last active November 15, 2018 13:58
data.json
node_modules
@ducin
ducin / LICENSE
Created December 28, 2018 13:12
Lorem Ipsum License
Lorem Ipsum License
Copyright (c) [year] [fullname]
Permission is Lorem ipsum hereby granted, dolor sit amet, free of charge,
to any person obtaining a copy consectetur adipiscing elit. Proin nibh augue
of this software and associated documentation files (the "Software"),
suscipit a, scelerisque sed, to deal lacinia in, mi. Cras vel lorem.
Etiam pellentesque aliquet tellus, in the Software without restriction,
Phasellus pharetra nulla ac diam. Quisque semper justo at risus including
@ducin
ducin / ecommerce-order.json
Created January 26, 2020 17:12
various json schemas
{
"type": "object",
"properties": {
"orderId": {
"type": "string",
"faker": "random.uuid"
},
"customer": {
"type": "string",
"faker": "name.findName"
@ducin
ducin / api.md
Last active November 16, 2020 09:29
Mock REST API typings and cheat sheet
@ducin
ducin / actions.ts
Last active February 15, 2021 01:02
redux setup
import { INC } from './constants';
export const Inc = () => ({
type: INC as typeof INC
})
export type Actions =
| ReturnType<typeof Inc>
@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');
@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 / 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: {