Skip to content

Instantly share code, notes, and snippets.

@p2004a
p2004a / utf8.cpp
Last active December 19, 2015 13:40
/*
Copyright 2013 Marek "p2004a" Rusinowski
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
typedef unsigned short int uchar;
@p2004a
p2004a / Site chnges monitor
Created January 30, 2014 15:22
Gets url as argument and notify user when the website content changes
#!/usr/bin/python
import sys, time, re, urllib2, hashlib, pynotify
def get_site_hash(url):
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36')]
u = opener.open(url)
data = u.read()
return hashlib.sha256(data).hexdigest()
@p2004a
p2004a / replacer.min.js
Last active August 29, 2015 14:05
wazniak.mimuw.edu.pl pretty equations
(function(a,b){Array.prototype.slice.call(document.getElementsByClassName('tex'), 0).forEach(function(e){e.parentNode.replaceChild(document.createTextNode('$'+e.alt.replace(/\\aligned/g,'\\begin{aligned}').replace(/\\endaligned/g,'\\end{aligned}').replace(/&&/g,'\\\\')+'$'), e); });b=document.createElement('script');b.type='text/x-mathjax-config';b.appendChild(document.createTextNode("MathJax.Hub.Config({tex2jax:{inlineMath: [['$','$']]}});"));document.head.appendChild(b);a=document.createElement('script');a.src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';document.head.appendChild(a);}());
@p2004a
p2004a / index.html
Created November 19, 2014 22:05
Simple iframe js runner
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>iframe runner</title>
<script src="http://ajaxorg.github.io/ace-builds/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajaxorg.github.io/ace-builds/src-min-noconflict/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
<script src="main.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
@p2004a
p2004a / Python part 1.ipynb
Last active August 29, 2015 14:17
Python tutorial for programmers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@p2004a
p2004a / README.md
Last active January 20, 2016 21:13
Simplex random test

Simplex test

Change values in lines 77-81 to change distribution of randomized variables.

The test uses GNU Linear Programming Kit to validate solutions. You have to install this library in your system to use it. Under debian/ubuntu install package libglpk-dev.

You have to provide implementation of simplex in function with signature:

@p2004a
p2004a / defer.cpp
Last active May 24, 2024 01:29
Simple defer macro for c++
// SPDX-FileCopyrightText: 2015 Marek Rusinowski
// SPDX-License-Identifier: MIT
#include <memory>
#include <cstdio>
template<typename F>
class defer_finalizer {
F f;
bool moved;
public:

Keybase proof

I hereby claim:

  • I am p2004a on github.
  • I am p2004a (https://keybase.io/p2004a) on keybase.
  • I have a public key ASCkyH7WPkmOGWrmCUJdU2R1uSBCQRRrm9p9QcXlBuMS4Qo

To claim this, I am signing this object:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Plots</title>
</head>
<body>
<div>
<svg height="504pt" version="1.1" viewBox="0 0 864 504" width="864pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">