Skip to content

Instantly share code, notes, and snippets.

View iluxonchik's full-sized avatar
😉

Illya Gerasymchuk iluxonchik

😉
View GitHub Profile
function get_User($url){
/*****************************************************************
* Retrieves the user from a paste
* -> This function is a bit hacky and doesn't have the best design
******************************************************************/
$str = file_get_contents($url);
if(strlen($str) > 0){
preg_match('/\<div class="paste_box_line2"\>(.*)\<\/div\>/', $str, $user);
$pieces = explode(' ', $user[1]);
if ($pieces[2]!='guest'){
@iluxonchik
iluxonchik / binaryGCDiterative.php
Created April 23, 2014 20:14
Binary GCD algorithm php implementation. Iterative version.
function binary_gcd($a, $b){
/* computes and returns the greatest common divisor between a and b */
/*
* Binary GCD Algorithm, according to Wikipedia "binary GCD can be about 60%
* more efficient (in terms of the number of bit operations) on average than the Euclidean algorithm".
* More about the Binary GCD Algorithm: http://en.wikipedia.org/wiki/Binary_GCD_algorithm
* Java Implementation: http://introcs.cs.princeton.edu/java/23recursion/BinaryGCD.java.html
* C++ Implementation: https://gist.github.com/cslarsen/1635213
@iluxonchik
iluxonchik / binaryGCDrecursive.php
Created April 23, 2014 20:15
Binary GCD implementation in php. Recursive version.
function gcd_recursive($a, $b){
/* computes and returns the greatest common divisor between a and b */
/*
* Binary GCD Algorithm, according to Wikipedia "binary GCD can be about 60%
* more efficient (in terms of the number of bit operations) on average than the Euclidean algorithm".
* More about the Binary GCD Algorithm: http://en.wikipedia.org/wiki/Binary_GCD_algorithm
* Java Implementation: http://introcs.cs.princeton.edu/java/23recursion/BinaryGCD.java.html
* C++ Implementation: https://gist.github.com/cslarsen/1635213
@iluxonchik
iluxonchik / textToASCII.php
Created April 24, 2014 15:07
Convert text to ASCII (returns an integer).
function textToASCII($text){
/* recieves a chunk of text and returns the number resulting from converting all of the caharacters to ASCII */
$asciified = 0; // stores the "asciified" text
for ($i = 0; $i<strlen($text); $i++){
if (ord($text[$i]) < 10)
// if the character's ASCII code is less than 10, multiplay by 10, so that that integer can be "concatenated"
$asciified *= 10;
else if (ord($text[$i]) < 100)
// if the character's ASCII code is less than 100, multiplay by 100, so that that integer can be "concatenated"
$asciified *= 100;
@iluxonchik
iluxonchik / TODO.md
Created April 26, 2014 07:50
TODO list prolog-project.

##Clues To Implement

  • trioLeft(Peca, Linha, Coluna, Tabuleiro)
  • trioRight(Peca, Linha, Coluna, Tabuleiro)
  • cobra(Peca, Linha, Coluna, Tabuleiro)
  • tSimples(Peca, Linha, Coluna, Tabuleiro)
  • tLeft(Peca, Linha, Coluna, Tabuleiro)
  • tRight(Peca, Linha, Coluna, Tabuleiro)
  • tInvertido(Peca, Linha, Coluna, Tabuleiro)
  • cantoTopLeft(Peca, Linha, Coluna, Tabuleiro)
  • cantoTopRight(Peca, Linha, Coluna, Tabuleiro)
public AndGateTwo() { gateOne = gateTwo = false; }
public AndGateTwo(boolean bool) { gateOne = gateTwo = bool; }
public AndGateTwo(boolean gOneBool, boolean gTwoBool) { gateOne = gOneBool; gateTwo = gTwoBool; }
@iluxonchik
iluxonchik / Animal.cpp
Created October 5, 2014 11:18
Everything works fine here
#include "Animal.h"
#include <string>
#include<iostream>
Animal::Animal(int age, std::string name) : name(name), age(age) { }
Animal::~Animal() { }
void Animal::sleep(){ printf("Shhh! %s is sleeping...\n", this->name); }
// Works
std::ostream &operator<<(std::ostream &o, const Cat cat){
o << (Animal&)cat << " Weight: " << cat.weight();
return o;
}
//Doesn't work
std::ostream &operator<<(std::ostream &o, const Cat cat){
o << (Animal*)cat << " Weight: " << cat.weight();
return o;
#include "Animal.h"
#include <string>
#include<iostream>
Animal::Animal(int age, std::string name) : _name(name), _age(age) { }
Animal::~Animal() { }
void Animal::sleep(){ printf("Shhh! %s is sleeping...\n", this->name); }
@iluxonchik
iluxonchik / Animal.cpp
Created October 8, 2014 21:12
PO Practical Class 3 C++ Exercise
#include "Dog.h"
#include <iostream>
#include <string>
Dog::Dog(int age, std::string name, int weight) : Animal(age, name), _weight(weight) {}
Dog::~Dog() {};
void Dog::bark()
{ std::cout << ((Animal*)this)->name() + " says: \"ruff, ruff!\"" << std::endl; }