Skip to content

Instantly share code, notes, and snippets.

@virzen
virzen / sample-comments.cpp
Last active September 27, 2015 15:00
Example of proper way of writing comments in C++ (and few other languages).
/*
* Comment's content.
*
* Another parapgraph.
* It's still the same paragraph.
*
* Last paragraph and line of this comment.
*/
@virzen
virzen / _view.scss
Last active January 7, 2016 16:11
HTML/CSS-only single-page routing
// HTML/CSS-only single-page routing
// From article on Smashing Magazine
// https://www.smashingmagazine.com/2015/12/reimagining-single-page-applications-progressive-enhancement/
/*
* HTML structure
<main>
<section class="view" id="some-view">
<h2>Something</h2>
</section>
@virzen
virzen / templatify.js
Last active March 14, 2016 17:44
Simple object-based templating function
/**
* Converts given given string to regexp checking globally for that string
* with given stops (limiters).
*
* Example: toTagRegExp('{{ }}', ' ', 'name') === /{{name}}/g
*
* @param [String] stops Start and end markers. E. g. '{{ }}', '% %' etc.
* @param [String] delimiter Splits left and right side of marker. E. g. ' '
* @param [String] tagName
* @return [RegExp]
// ==UserScript==
// @name Obstawiator
// @namespace Domin & Wiktor
// @description Skrypt zarabiający góry pieniędzy w ruletce na csgohill.com
// @include https://www.csgohill.com/
// @version 1
// @grant none
// ==/UserScript==
//zezwalajnawklejanie
console.log('Obstawiator.js super by Domin & Viktor 2016 - polecam');
import { compose } from 'ramda';
const mapDispatchToProps = dispatch => ({
performAction: compose(dispatch, createAction);
});
// is the same (but better, because it's in pointer-free style) as
const mapDispatchToProps2 = dispatch => ({
performAction: data => dispatch(createAction(data)),
import React, { Component } from 'react';
import Box from 'grommet/components/Box';
import Table from 'grommet/components/Table';
import TableHeader from 'grommet/components/TableHeader';
import TableRow from 'grommet/components/TableRow';
import Heading from 'grommet/components/Heading';
import Spinning from 'grommet/components/icons/Spinning';
@virzen
virzen / Mc8r-1.py
Created October 14, 2017 10:24
null created by virzen - https://repl.it/Mc8r/1
def u1(n):
return 5
def u2(k, T, Tp, n):
if n == 0:
return 0
return (1 - Tp/T) * u2(k, T, Tp, n - 1) + k * Tp / T * u1(n)
for i in range(10):
@virzen
virzen / Mc8r-3.py
Created October 14, 2017 10:37
null created by virzen - https://repl.it/Mc8r/3
from terminaltables import AsciiTable # learn more: https://python.org/pypi/terminaltables
def u1(n):
return 5
def u2(k, T, Tp, n):
if n == 0:
return 0
@virzen
virzen / machine.js
Created July 17, 2019 14:33
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// Machine (machine factory function)
// assign (action)
// XState (all XState exports)
const selectAgent = (_context, event) => event.agent
const highlightAgent = (_context, event) => event.agent
const saveAgentInAgentsList = (_context, event) => [event.agent]
const saveListings = (_context, event) => event.listings
@virzen
virzen / machine.js
Created July 17, 2019 14:34
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions