Skip to content

Instantly share code, notes, and snippets.

View estshy's full-sized avatar

Mateusz Nowak estshy

  • Warsaw
View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
test: 'my-component'
});
@estshy
estshy / gist:f5e4e653f048baea31d0
Created June 9, 2015 19:11
One more Fizz Buzz
$r = array_reduce(range(1, 20), function($carry, $n) {
switch($n % 15) {
case 0:
return $carry . "Fizz buzz" . PHP_EOL;
case 3:
case 6:
case 9:
case 12:
return $carry . "Fizz" . PHP_EOL;
case 5:
@estshy
estshy / gist:bd556c55186eff9b3bdd
Created March 13, 2015 09:39
Token bucket algorithm in PHP
/**
* Implementation of the token bucket algorithm
*/
class TokenBucket {
/**
* Maximum number of tokens
*
* @var integer
*/
@estshy
estshy / gist:cee129d61a220932eeb7
Last active August 29, 2015 14:13
Ember array greater than, less than extenstion
var NativeArray = Ember.Mixin.create(Ember.NativeArray, {
filterByRange: function(property, from, to) {
return this.filter(function(object) {
return object.get(property) >= from && object.get(property) <= to;
});
},
gte: function(property, from) {
return this.filter(function(object) {
return object.get(property) >= from;
});
@estshy
estshy / gist:9df3265cb1fecf6907e8
Created November 26, 2014 22:14
Creates christmas tree in C using `*` symbol
#include <stdio.h>
int main() {
int rows, row, space, column;
printf("%s ", "Ile rzędów choinki?");
scanf("%d", &rows);
for (row = 0; row <= rows; ++row)
{
@estshy
estshy / gist:7252662
Created October 31, 2013 16:27
Program oblicza liczby a i b znając ich sumę oraz iloczyn
#include <iostream>
#include <cstdio>
#include <math.h>
/*
* @desc Program oblicza liczby a i b znając ich sumę oraz iloczyn
* @author Mateusz Nowak
*/
int main()
{
@estshy
estshy / gist:6628588
Created September 19, 2013 19:25
Oblicza całkę w podanym przedziale dla funkcji postaci f(x) = x*x + 2x
/**
* Oblicza całkę w podanym przedziale dla funkcji postaci f(x) = x*x + 2x
*
* @author Mateusz Nowak
* @example Integration integration = new Integration(0, 1, 1000);
* System.out.println(integration.execute());
*/
public class Integration {
double integral = 0;
/**
* Konwersja danych pomiędzy różnymi systemami ich zapisu (np. dec, bin, hex, oct)
*
* @author Mateusz Nowak
* @example Convert.factory("1010").from(2).to(16).execute();
*/
import static java.lang.Math.pow;
public class Convert {
@estshy
estshy / gist:6564858
Last active December 23, 2015 02:09
Oblicza pierwiastek z podanej liczby wg Metody Newtona Raphsona
/*
* Oblicza pierwiastek z podanej liczby wg Metody Newtona Rapshona
*
* @author estshy
*/
import java.util.*;
public class Sqrt {