Skip to content

Instantly share code, notes, and snippets.

@spion
spion / primes.c
Last active December 10, 2015 20:28
const int HOWMANY = 1000000;
int main() {
int arr[HOWMANY + 1], k = 2, primec = 0;
while (primec < HOWMANY) {
int isprime = 1, p;
for (p = 0; p < primec; ++p) {
int pr = arr[p];
if (k % pr == 0) {
isprime = 0;
break;
// ==UserScript==
// @name blog.spodeli.org colorizer
// @namespace http://spion.github.io
// @version 0.3.4
// @description Change the spodeli.org color
// @match http://b10g.spodeli.org/*
// @copyright public domain
// @grant metadata
// ==/UserScript==
#include <OneWire.h>
#include <LiquidCrystal.h>
#include <avr/delay.h>
#define CHANGERATE 5 // in which limits will the temperature change since the last reading, in degrees
#define INPUTPIN 5
// For every sensor found it outputs to serial:
// SensorID,CurrentTemp,Readout time,Current time
// Info at: http://wiki.spodeli.org/Хаклаб/Температура
@spion
spion / primes-fibers.js
Created February 3, 2013 12:37
node.js - fibers-based almost-non-blocking computations - benchmark.
var fibrous = require('fibrous');
/**
* High-performance fibers context switcher
*/
fibrous.switcher = function(dc, dt) {
dc = dc || 1;
dt = dt || 1;
var c = 0,
s = Date.now();
@spion
spion / sorts.cpp
Last active December 12, 2015 02:59
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
int vrednostNaBukva(char bukva) { return bukva - 'A' + 1; }
@spion
spion / autocompile.sh
Last active December 12, 2015 05:29
Use resig's micro-templates in browserify
browserify --debug --watch -p ./tmpl.js example.js -o bundle.js
@spion
spion / gist:4748141
Last active December 12, 2015 08:59
Sensible fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>~/.fonts</dir>
<!-- The sensible defaults for most fonts. -->
<!-- Use antialiasing, but no hinting. If -->
<!-- you do use hinting, hint fully. -->
<match target="font">
<edit mode="assign" name="hinting">
@spion
spion / arecord-vu.js
Created February 10, 2013 18:30
node vu metter based on arecord
var cp = require('child_process'),
EE = require('events').EventEmitter;
module.exports = function() {
var self = new EE();
var audio = cp.spawn('arecord', ['-t', 'raw', '-f', 'U8', '-q']);
audio.stderr.pipe(process.stdout);
audio.stdout.on('data', function(d) {
var a = 0;
for (var k = 0; k < d.length; ++k) {
@spion
spion / ffmpeg-stream.js
Created February 11, 2013 01:46
node ffmpeg-stream
var duplex = require('duplexer'), // npm install duplexer
request = require('request'), // npm install request
spawn = require('child_process').spawn;
fs = require('fs');
function ffmpegEncoder(opt, moreopt) {
var args = ['-i','pipe:']
for (var key in opt)
args.push('-'+key, opt[key]);
args.push('pipe:');
@spion
spion / node-async-bfs.js
Created February 11, 2013 19:11
node async generic breadth first search
var async = require('async');
exports.bfs = function bfs(start, moves, goal, done) {
goal(start, function(err, res) {
if (res) done(null, [start]);
else explore([start], 1);
});
var depth = 0;
var foundGoal = null;
var visited = {};