Skip to content

Instantly share code, notes, and snippets.

View mbrezu's full-sized avatar
🐢
Yes, but not right now.

Miron Brezuleanu mbrezu

🐢
Yes, but not right now.
View GitHub Profile
@mbrezu
mbrezu / serve.cmd
Created August 17, 2019 19:50
Docker based script to serve a folder over HTTP
rem first arg: path to serve
rem second arg: port to use
docker run -it --rm -p %2:80 -v %1:/usr/share/nginx/html jrelva/nginx-autoindex:latest
@mbrezu
mbrezu / main.cpp
Created November 27, 2014 21:41
List iterative filtering derived from list recursive filtering
#include <iostream>
#include <functional>
#include <vld.h>
using namespace std;
template <typename T>
struct Node {
@mbrezu
mbrezu / spdtest.py
Created November 30, 2012 20:36
A dumb microbenchmark
def breakNumber(n):
return [(n / 1000) % 10,
(n / 100) % 10,
(n / 10) % 10,
n % 10]
def allDifferent(bn):
def iter(num, idx):
if idx == 4: return False
@mbrezu
mbrezu / backup.py
Created February 12, 2012 12:30
Script pentru backup pe stick
#!/usr/bin/env python
# Script simplu pentru facut copii de rezerva
#
# argument 1: subdirectorul din /media unde facem backup
#
# restul argumentelor: subdirectoare de backup-uit
# Exemplu de desktop entry (cu numele backup.desktop, de plasat in
# ~/Desktop; presupune ca scriptul curent este in ~/bin si ca vrem sa
@mbrezu
mbrezu / .bashrc
Created January 25, 2012 09:41
.bashrc
alias xterm='xterm -fg black -bg lightyellow -fn 10x20 -fb 10x20'
;; for floats, sb-kernel:single-float-bits, sb-kernel:make-single-float
;; etc.
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun mkstr (&rest args)
(format nil "~{~a~}" args))
(defun mksymb (&rest args)
(intern (apply #'mkstr args))))
(defmacro signed-unsigned-convertors (size)
@mbrezu
mbrezu / parenscript trace
Created February 24, 2011 07:13
tefun.lisp
(defpsmacro tefun (name args &body body)
(let ((traced-name (gensym (symbol-name name))))
`(progn
(defun ,traced-name ,args
,@body)
(defun ,name ,args
(trace (+ "entering "
,(encode-js-identifier (symbol-name name))
"("
,@(mapcar #'(lambda (name val)
(let ((cache (make-hash-table :test 'equal)))
(defun encode-js-identifier (identifier)
"Given a string, produces to a valid JavaScript identifier by
following transformation heuristics case conversion. For example,
paren-script becomes parenScript, *some-global* becomes SOMEGLOBAL."
(setf identifier (string-downcase identifier))
(or (gethash identifier cache)
(setf (gethash identifier cache)
(let ((no-case-conversion nil)
(lowercase t)
@mbrezu
mbrezu / mergesrt.py
Created January 1, 2011 21:41
Combine timings from one srt with text from another.
import sys
import re
import math
import os.path
class SrtEntry(object):
def __init__(self, number, startTime, endTime, text):
self.number = number
self.startTime = startTime
self.endTime = endTime
@mbrezu
mbrezu / SRTfix.py
Created January 1, 2011 16:43
A small script to fix SRT times.
# Tries to fix a srt file to match the sub time with the actual dialog time.
# Inputs:
# - the srt file
# - a list of (srt time, spoken dialog time) pairs that will be used
# to infer the parameters for the srt time adjustment
# Outputs:
# - the corrected srt file to standard output
# - the correction parameters to standard error
import sys