Skip to content

Instantly share code, notes, and snippets.

View woduda's full-sized avatar
🏠
Working from home

Wojciech Duda woduda

🏠
Working from home
View GitHub Profile
@woduda
woduda / testreport.php
Last active August 1, 2022 13:51
Example for koolreport/pro 5.16.2 produces corrupted Excel data
<?php
require_once '../vendor/autoload.php';
use koolreport\KoolReport;
use koolreport\datasources\ArrayDataSource;
use koolreport\excel\ExcelExportable;
use koolreport\processes\ColumnMeta;
class TestReport extends KoolReport
@woduda
woduda / test.php
Created February 13, 2018 15:38
Test how passing object by reference works in PHP
<?php
class A
{
private $id = 0;
public function __construct($id)
{
$this->id = $id;
}
@woduda
woduda / student.rb
Last active January 23, 2016 13:07
Student with best grades (max 10 Students if created with factory)
class Student
MAX = 10
@@students = []
attr_accessor :name, :surname, :specialization, :grades
def self.factory(hash={})
return nil if @@students.length >= MAX
@woduda
woduda / orders_controller.rb
Created December 20, 2015 21:18
Simplest PDF output with Prawn
class OrdersController < ApplicationController
before_action :set_order, only: [:show, :edit, :update, :destroy, :print_pdf]
def print_pdf
order_pdf = Prawn::Document.new
order_pdf.text "Name: #{@order.name}"
order_pdf.text "Price: #{@order.price}"
order_pdf.text "Description: #{@order.description}"
@woduda
woduda / csv.php
Last active August 29, 2015 13:56
Simple JSON to CSV conversion
<?php
// echo $_SERVER['QUERY_STRING'];
$json = file_get_contents('http://api.fap.pl/dealers?'.$_SERVER['QUERY_STRING']);
$_json = json_decode($json, TRUE);
$out = '';
foreach($_json as $row)
{
$out .= substr(row($row)."\n", 1);