Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am meqif on github.
  • I am meqif (https://keybase.io/meqif) on keybase.
  • I have a public key ASCDp4tdUW_88XdVYhD-VaPIQewOlmuxCD_85cN2-Fc6XAo

To claim this, I am signing this object:

@meqif
meqif / main.rs
Last active October 3, 2017 11:46
use std::thread;
use std::sync::{Arc, RwLock};
// Represents a reference to a node.
// This makes the code less repetitive to write and easier to read.
type NodeRef<T> = Arc<RwLock<_Node<T>>>;
// The private representation of a node.
struct _Node<T> {
inner_value: T,
#!/usr/bin/env ruby
#
# Downloads the entire 'Worm' story and builds an ebook out of it in HTML form,
# ready to be processed by Calibre into whatever format you need.
#
require 'nokogiri'
require 'open-uri'
INDEX_URL = "http://parahumans.wordpress.com/table-of-contents/"
@meqif
meqif / pi.c
Last active December 14, 2015 05:59
Multithreaded π calculation/estimation
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <math.h>
#include <omp.h>
/* Estimate pi using the Monte Carlo algorithm */
double pi_thread(int n) {
int n1 = 0;
double x, y;
@meqif
meqif / curbstomp.py
Created September 11, 2012 21:25
Twitter account spam/ham classifier
#!/usr/bin/env python
"""
Simple Naive Bayes tweet classifier.
It analyses a number of tweets of a given user and determines if that user is
a spammer.
"""
from __future__ import division
@meqif
meqif / chrome.css
Created May 18, 2012 11:40
Travis-CI maximized main column
body#home { background: none; }
div#left { display: none; width: 0px; }
div#main { padding-left: 100px !important; }
@meqif
meqif / du_sort.py
Created June 7, 2011 20:17
Short script for sorting 'du' output correctly. I did it in both Ruby and Python as practice.
#!/usr/bin/env python
"""
du_sort
Copyright (c) 2011 Ricardo Martins
Licensed under the MIT License.
http://www.opensource.org/licenses/mit-license.php
@meqif
meqif / 0001-Reduced-repeated-gsubs.-Style-fixes.patch
Created September 7, 2010 23:32
Patch for kernel's jekyll fork. Apply with 'git am 0001-Reduced-repeated-gsubs.-Style-fixes.patch'
From 745ffd39eb7a9661e512761c5861376dae7583b8 Mon Sep 17 00:00:00 2001
From: Ricardo Martins <ricardo@scarybox.net>
Date: Wed, 8 Sep 2010 00:08:32 +0100
Subject: [PATCH] Reduced repeated gsubs. Style fixes.
---
lib/jekyll/toc_helper.rb | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/jekyll/toc_helper.rb b/lib/jekyll/toc_helper.rb
-- removes duplicate adjacent elements
uniq_adj :: (Eq a) => [a] -> [a]
uniq_adj [] = []
uniq_adj [x] = [x]
uniq_adj (x:y:z) =
if (x == y) then uniq_adj (y:z)
else x : uniq_adj (y : z)
prop_uniq_adj xs = length (uniq_adj xs) <= length xs
#!/bin/sh
# enable reading stdin
exec < /dev/tty
cd TrabPratico && rake
if [[ $? -ne 0 ]]; then
echo "Errors found while testing. Continue anyway? [y/N]"