Skip to content

Instantly share code, notes, and snippets.

View zapu's full-sized avatar
:octocat:
hi

Michał Zochniak zapu

:octocat:
hi
View GitHub Profile
@zapu
zapu / gist:ccca352772969c656af2
Created February 13, 2015 13:47
Remove composer_dropdown in web telegram
// ==UserScript==
// @name Remove idiotic dropdown menu when typing in telegram
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match https://web.telegram.org/*
// @match https://web.telegram.org/*/*
// @grant none
// ==/UserScript==
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
module SocketPolicyServer
type TcpListener = System.Net.Sockets.TcpListener
type IPAddress = System.Net.IPAddress
type HttpListenerRequest = System.Net.HttpListenerRequest
open System.Threading.Tasks
open System.Threading
let StartPolicyServer (gamePort:int) (policyServerPort:int) =
module SocketPolicyServer
type HttpListener = System.Net.HttpListener
type HttpListenerRequest = System.Net.HttpListenerRequest
let StartPolicyServer (port:int) =
if not HttpListener.IsSupported then
failwith "HttpListener not supported"
else
@zapu
zapu / gist:11304746
Last active August 29, 2015 14:00
mocks
mockery = (func) ->
mocks = [{f: func}]
ret = () ->
mock = mocks[0]
unless mock
throw new Error('No mocks left')
unless mock.forever
mocks.splice(0, 1)
return mock.f.apply @, arguments
@zapu
zapu / gist:5758425
Created June 11, 2013 16:36
ANTLR4 grammar. parses and returns int expression e.g. "-2 * --(1+-1)"
grammar negationtest;
expression: ar_expression { System.out.println($ar_expression.ret); }
;
ar_expression returns [Integer ret]:
a = mult_expression { $ret = $a.ret; }
(
('+' b = mult_expression { $ret += $b.ret; } ) |
('-' c = mult_expression { $ret -= $c.ret; } )
/*
Copyright (C) 1996 John W. Eaton
This file is part of Octave.
Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
@zapu
zapu / gist:4091796
Created November 16, 2012 23:14
Embedding python in c++
#include <stdio.h>
#include <stdlib.h>
#include <Python.h>
static PyObject* rettest(PyObject *self, PyObject *args)
{
return Py_BuildValue("i", 123);
}
@zapu
zapu / gist:4059015
Created November 12, 2012 12:07
filtry filtry filtry
close all;
sampling_freq = 8000;
nyq_freq = sampling_freq / 2;
% Bandpass filter frequencies
freqs = [41 82 123];
for i=1:10
fsize = size(freqs, 2);
freqs = [freqs (freqs(fsize-1)*2)];
@zapu
zapu / gist:3849544
Created October 7, 2012 20:47
portaudio stuff
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <portaudio.h>
#include <assert.h>
#include <stdio.h>
#include <math.h>
#define NUM_CHANNELS 2