Skip to content

Instantly share code, notes, and snippets.

View rogierslag's full-sized avatar

Rogier Slag rogierslag

View GitHub Profile
@rogierslag
rogierslag / tweakers.net User CSS
Last active December 27, 2015 07:29
I was not that satisfied with how tweakers.net looked on my retina Macbook. Blurry logo (still after a year they did not manage to update it!). So I wanted to find out how I could improve this myself. I came across this forum thread [http://gathering.tweakers.net/forum/list_messages/1521568], which I used to make the site look better.When I was …
/**
Tweak voor tweakers.net
Safari User CSS
It enables a retina logo for the site
It removes the user icon for the currently loggedin user
It removes the annoying "collapse" buttons at every comment
It removes the blurry "hosted by true" ad (make it retina and it'll enable it!)
It removes a quite annoying promo text
It scales the comment scores down to a desktop friendly size (since the rating system is flawed anyway)
@rogierslag
rogierslag / reference.spt
Created November 8, 2013 16:07
MiniJava reference errors with resolving
module Reference
language MiniJava
start symbol Start
test backward variable parameter resolution [[
class Main {
public static void main(String[] args) {
System.out.println(1);
}
}
@rogierslag
rogierslag / findNs.php
Last active December 29, 2015 02:29
Finds the current PHP namespace and all `use` statements in a file
<?php
// Get all the files
$files = openAllFiles ( '/Users/Rogier/Desktop/Developer/nl.tudelft/FPtudelft/AWS/vendor', '' );
// For each file start the replace operations
foreach ( $files as $fileLocation ) {
// The current namespaces
$uses = array ();
$namespacePrefix = '';
@rogierslag
rogierslag / false.mjv
Created December 17, 2013 21:50
Voorbeeld testcase met MiniJava voor Lazy evaluation van een And()
/**
Produceert output
0
*/
class Rogier {
public static void main(String[] args) {
if( false && (new AA()).bool() ) {
System.out.println(4);
} else {
@rogierslag
rogierslag / Question 1.md
Last active January 4, 2016 13:59
Advanced Algorithms example questions on empirical evaluation

Give a description of the DPL algorithm for SAT as analysed by Hooker and Vinay.

The DPLL algorithms works with the following steps:

  1. Monotone variable fixing: This means that all variables which appear only in a positive form (no negated terms) are set to true and all variables which appear only in a negative form are set to false.
  2. Unit resolution: In this step all unit clauses (which are clauses with only one remaining literal) are set to true (hence the variable within may be true or false, depending on the negation). Consequently the value of the literal is propagated trough the formula. The formula can then be shortened (if L is true, remove the clause; if L is false, remove L from the clause). A contradiction may appear here if L appears once negated and once positive. This branch is then not satisfiable and terminates
  3. If the algorithms was not stopped in step 2 a check is made to verify is S is empty. If yes return "Satisfiable"; otherwise continue with step 4
  4. Pick a new literal L
@rogierslag
rogierslag / initscript
Created March 20, 2014 14:24
This is how you can create a daemon of a simple program on rPi
### BEGIN INIT INFO
# Provides: pi-radio
# Required-Start: autofs $all
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts and stops the Raspberry Radio
# Description: Starts and stops the Raspberry Radio
### END INIT INFO
public class SortedLinkedList<E extends Comparable<E>> extends LinkedList<E> {
public boolean add(E toAdd) {
int index = 0;
for( ; index<size() ; index++){
E alreadyIn = get(index);
if(toAdd.compareTo(alreadyIn) < 0){
break;
}
@rogierslag
rogierslag / example.php
Created May 1, 2014 09:57
Hack type safety
<?hh //strict
function newline() : void {
echo "\n";
}
function number() : int {
return 123;
}
@rogierslag
rogierslag / run 1 (100-10)
Last active August 29, 2015 14:02
Distributed Algorithms
Random val for 0 = 1
Server 0 ready
Random val for 1 = 0
Server 1 ready
Random val for 2 = 1
Server 2 ready
Random val for 3 = 1
Server 3 ready
Random val for 4 = 1
Server 4 ready
<?php
$db = new PDO('mysql:dbname=test;host=localhost','root','rogier');
$db->query('DROP TABLE test');
$db->query('CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`intval` int(11) NOT NULL,
`textval` text NOT NULL,
`varcharval` varchar(128) NOT NULL,