Skip to content

Instantly share code, notes, and snippets.

View vafrederico's full-sized avatar

Vinícius Frederico vafrederico

View GitHub Profile
@vafrederico
vafrederico / check_bst.c
Last active October 6, 2018 19:59
check_bst
node* new_node(val) {
node* n = malloc(sizeof(node));
n->val = val;
n->left = NULL;
n->right = NULL;
return n;
}
void test(){
@vafrederico
vafrederico / htop-1.0.2-cpufreq.patch
Last active August 29, 2015 14:12
Adds a CPU Frequency meter to htop. After patching, run ./autogen.sh before configuring and compiling.
diff -rupN htop-1.0.2/CPUFreqMeter.c htop-1.0.2-new/CPUFreqMeter.c
--- htop-1.0.2/CPUFreqMeter.c 1969-12-31 21:00:00.000000000 -0300
+++ htop-1.0.2-new/CPUFreqMeter.c 2015-01-04 18:08:24.678220500 -0200
@@ -0,0 +1,115 @@
+/*
+htop - CPUFreqMeter.c
+(C) 2015 Vinicius Frederico
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
@vafrederico
vafrederico / untrusted-lvl6-solution.js
Created April 8, 2014 08:03
untrusted-lvl6-solution.js
/****************
* drones101.js *
****************
*
* Do you remember, my dear Professor, a certain introductory
* computational rationality class you taught long ago? Assignment
* #2, behavior functions of autonomous agents? I remember that one
* fondly - but attack drones are so much easier to reason about
* when they're not staring you in the face, I would imagine!
*/
/*
* robotMaze.js
*
* The blue key is inside a labyrinth, and extracting
* it will not be easy.
*
* It's a good thing that you're a AI expert, or
* we would have to leave empty-handed.
*/
/*****************
* cellBlockA.js *
*****************
*
* Good morning, Dr. Eval.
*
* It wasn't easy, but I've managed to get your computer down
* to you. This system might be unfamiliar, but the underlying
* code is still JavaScript. Just like we predicted.
*
/********************
* theLongWayOut.js *
********************
*
* Well, it looks like they're on to us. The path isn't as
* clear as I thought it'd be. But no matter - four clever
* characters should be enough to erase all their tricks.
*/
function startLevel(map) {
/************************
* validationEngaged.js *
************************
*
* They're really on to us now! The validateLevel function
* has been activated to enforce constraints on what you can
* do. In this case, you're not allowed to remove any blocks.
*
* They're doing all they can to keep you here. But you
* can still outsmart them.
/*******************
* multiplicity.js *
*******************
*
* Out of one cell and into another. They're not giving you
* very much to work with here, either. Ah, well.
*
* Level filenames can be hints, by the way. Have I
* mentioned that before?
*
/**************************
* exceptionalCrossing.js *
**************************
*
* Sorry, old friend, but I'm afraid I can't share
* co-authorship on this paper. You've done a very
* good job getting this Algorithm for me. The bit
* with the keys was especially clever! I wouldn't
* have thought of it myself. But then, of course,
* that's why you were here in the first place.
/*************
* lasers.js *
*************
*
* Time to unleash the killer lasers! Each laser will kill you
* unless you have the appropriate color. Too bad you can't
* see which color corresponds to which laser!
*/
function getRandomInt(min, max) {