Skip to content

Instantly share code, notes, and snippets.

View AndreasHassing's full-sized avatar
🤓

Andreas Bjørn Hassing AndreasHassing

🤓
View GitHub Profile
@AndreasHassing
AndreasHassing / primes.c
Created October 16, 2013 06:22
\n between each prime in numbers.txt
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
int is_prime(unsigned long long p){
unsigned long long i; //For the loop
for (i = 2; i <= p-1; i++){ //Counts to the number before p
if (p % i == 0) { //If no remainder it divides and therefore a composite number
@AndreasHassing
AndreasHassing / gcd.rb
Created November 3, 2013 19:35
Find greatest common divisor - ruby class (Euclid algorithm)
# Finds greatest common divisor from 2 digits parsed from console
# Usage: ruby gcd.rb 5 2
# Finds the greatest common divisor from the digits 5 and 2
class GCD
$digits = Array.new
def initialize(args)
if args.length == 2
users = User.where('name IS NULL')
users.each do |user|
# Some api call which will retrive name of the user based on user email
name = API.getUserName user.email
if name.blank?
next
else
user.name = name
end
end
@AndreasHassing
AndreasHassing / BetterRandom.java
Created September 18, 2014 11:32
BetterRandom (better random numbers than java.util.Random;
package dk.itu.abhn.betterrandom;
/**
* BetterRandom is a better alternative to Javas'
* java.util.Random, as it generates a completely
* random number (that I picked).
* @author abhn@itu.dk
*/
public class BetterRandom {
@AndreasHassing
AndreasHassing / Room.java
Created September 21, 2014 16:53
setExits in Room.java
public void setExits(Room northExit, Room eastExit, Room southExit, Room westExit) {
this.northExit = northExit;
this.eastExit = eastExit;
this.southExit = southExit;
this.westExit = westExit;
}
// Spørgsmål:
/*
Beskriv nogle regneudtryk (af type int eller double, med
operatorer såsom * + - / % osv) og nogle logiske udtryk (af type
boolean, med operatorer såsom == != < > <= >= ! && ||), hvordan de
udregnes og hvor de bruges.
*/
// int og double (+ / -)
7 + 5 // = 12, to ints. Resultat er en int.
package dk.itu.abhn.sandbox;
public class PlayWithBetterExceptions {
int[] someArray;
public PlayWithBetterExceptions() {
someArray = new int[]{1, 2, 3, 4, 5}; // array that is 5 elements long!
}
@AndreasHassing
AndreasHassing / InstallingFsYaccFsLexOSX.md
Last active August 8, 2022 06:47
How to get FsYacc and FsLex (FsLexYacc) on OS X

Installing FsYacc and FsLex (FsLexYacc) on OS X

Step by step guide to getting FsYacc and FsLex for development on OS X.

Changes

  • 2017-01-09: Updated guide to reflect latest version of FsLexYacc (7.0.3)
  • 2016: Created

1. Install Mono

By doing one of these:

using System;
using System.IO;
using System.Text;
class Solution {
static void Main(String[] args) {
var t = Convert.ToInt32(Console.ReadLine());
for(var a0 = 0; a0 < t; a0++) {
var expression = Console.ReadLine();
@AndreasHassing
AndreasHassing / link_playground.sh
Last active January 16, 2017 20:59
Slap nu af Anders, vi har den [en super formel guide til Hard- og Symlinks]