Skip to content

Instantly share code, notes, and snippets.

@mmalecki
mmalecki / coolfaq.htm
Created April 10, 2011 10:42
Cool FAQ page (needs some CSS tweaks to look even cooler)
<!doctype html>
<html>
<head>
<title>FAQ</title>
<meta charset="utf-8" />
<style type="text/css">
.column {
float: left;
}
@mmalecki
mmalecki / 4ctd.php
Created April 23, 2011 10:40
4chan thread's images downloader (downloads each image from given thread, invocation like: php 4ctd.php thread_url dir_to_save_images)
<?php
$url = $argv[1];
$prefix = (isset($argv[2])) ? $argv[2] : '';
$fprefix = (isset($argv[3])) ? $argv[3] : '';
$f = file_get_contents($url) or die('URL invalid');
if (!is_dir($prefix))
mkdir($prefix);
$img = array();
@mmalecki
mmalecki / protocols.py
Created May 13, 2011 20:56
tornado-based async POP3 client
class CommandFailedException(Exception):
def __init__(self, result=None):
Exception.__init__(self)
self.result = result
if result:
self.message = "Mail command failed: \"%s\"" % result
class AsyncMailClient(object):
def __init__(self, host, port, use_ssl=True, timeout=4):
self.host = host
@mmalecki
mmalecki / ren.py
Created July 10, 2011 12:15
Simple Python script to remove leading numbers from file names (useful when renaming music files)
#!/usr/bin/python
import re
import os
import os.path
pattern = re.compile("^[0-9]+ ?- ?")
def directory(d):
for f in d[2]:
if pattern.match(f):
https = require('https')
setInterval(function(){console.log("still alive...")}, 1000)
https.get({ headers: {},
path: '/barista/-/barista-0.0.3.tgz',
host: 'registry.npmjs.org',
port: 443,
secure: true,
agent : false, // remove THIS
}, function(res) {
var fs = require('fs');
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/pdf'});
fs.readFile('pdf.pdf', function (err, data) {
if (err) {
res.end('oh shit');
return;
}
# relief1
Relief1 is a project for disaster preparedness, relief and recovery.
In case of emergency, it collects information about missing people, available
resources and volunteers.
It is supposed to overcome problem with media hype, which gets created by
uncontrolled flow of data.
## Internals
Project is build upon node.js to provide maximum responsiveness. It'll use Riak
@mmalecki
mmalecki / memset.c
Created August 23, 2011 16:57
memset
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void* memset1(void* mem, int value, size_t num) {
char* m = mem;
char v = value;
while (num-- != 0)
*(m + num) = v;
return mem;
module.exports = {
setUpGroup: function (callback) {
console.log('0');
callback();
}
setUp: function (callback) {
this.foo = 'bar';
console.log('1');
callback();
},
In file included from test.cpp:1:
In file included from /usr/include/c++/4.6.0/string:41:
In file included from /usr/include/c++/4.6.0/bits/char_traits.h:40:
/usr/include/c++/4.6.0/bits/stl_algobase.h:378:43: error: unexpected type name '_ValueTypeI': expected expression
const bool __simple = (__is_trivial(_ValueTypeI)
^
/usr/include/c++/4.6.0/bits/stl_algobase.h:383:40: error: non-type template argument of type 'bool const' is not an integral constant expression
return std::__copy_move<_IsMove, __simple,
^~~~~~~~
/usr/include/c++/4.6.0/bits/stl_algobase.h:573:43: error: unexpected type name '_ValueType1': expected expression