Skip to content

Instantly share code, notes, and snippets.

(defn is-ascii-alpha-num [c]
(let [n (Character/getNumericValue (char c))]
(or (and (>= n (char-val \a)) (<= n (char-val \z)))
(and (>= n (char-val \A)) (<= n (char-val \Z)))
(and (>= n (char-val \0)) (<= n (char-val \9)))))
@luisgabriel
luisgabriel / Main.hs
Last active August 29, 2015 14:10
RTS+CCS crash
import System.Environment
import Text.Printf
main = do
[d] <- map read `fmap` getArgs
printf "%f\n" (mean [1..d])
mean :: [Double] -> Double
mean xs = {-# SCC "mean" #-} sum xs / fromIntegral (length xs)
@luisgabriel
luisgabriel / linux-rapl.c
Created May 19, 2015 20:42
PAPI RAPL code
/**
* @file linux-rapl.c
* @author Vince Weaver
*
* @ingroup papi_components
*
* @brief rapl component
*
* This component enables RAPL (Running Average Power Level)
* energy measurements on Intel SandyBridge/IvyBridge/Haswell
@luisgabriel
luisgabriel / out.txt
Last active August 29, 2015 14:23
overflow-test output
SAMPLE 0
Start package energy: 68014.492 J
End package energy: 117772.400 J
Aproximate duration: 336 s
SAMPLE 1
Start package energy: 52383.802 J
End package energy: 81000.144 J
Aproximate duration: 194 s
import Control.Concurrent
import Control.Monad
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Class
type Fork = MVar Int
newFork :: Int -> IO Fork
newFork i = newMVar i
@luisgabriel
luisgabriel / foo-test.js
Created February 18, 2013 12:22
buster.js bug
var buster = require("buster");
function include(path) {
var fs = require("fs");
var vm = require("vm");
var code = fs.readFileSync(path, "utf-8");
vm.runInThisContext(code, path);
}
include("js/utils/object.js");
(ns tsearch.core
(:require [clojure.java.io :as cjio])
(:require [tsearch.scanner :as scanner])
(:require [tsearch.lexer :as lexer])
(:gen-class))
(defn occurrences-of [file]
(with-open [rdr (cjio/reader file)]
(loop [lines (line-seq rdr) hmap (hash-map)]
(if (empty? lines)
(ns tsearch.lexer
(:require [clojure.string :as cjstr]))
(def a (Character/getNumericValue \a))
(def z (Character/getNumericValue \z))
(def A (Character/getNumericValue \A))
(def Z (Character/getNumericValue \Z))
(def zero (Character/getNumericValue \0))
(def nine (Character/getNumericValue \9))
import System.Directory ( getDirectoryContents, doesFileExist, doesDirectoryExist )
import System.Environment ( getArgs )
import System.FilePath
import Control.Monad ( forM_, filterM )
import Data.Char ( isAscii, isAlphaNum, toLower )
import qualified Data.Map as Map
getDirectoryEntries :: FilePath -> IO ([FilePath], [FilePath])
getDirectoryEntries path = do
entries <- getDirectoryContents path
@luisgabriel
luisgabriel / view.qml
Last active December 26, 2015 05:29 — forked from renatooliveira/app.py
import QtQuick 1.0
Rectangle {
id: root
width: 1024
height: 768
Image {
source: "images/mtsis_tela_balanca_1024.png"
fillMode: Image.PreserveAspectFit