Skip to content

Instantly share code, notes, and snippets.

View bor0's full-sized avatar

Boro Sitnikovski bor0

View GitHub Profile
@bor0
bor0 / class-based.php
Last active January 4, 2024 20:56
IO foldable
<?php
abstract class IO_Foldable {
public function __call( $method, $args ) {
if ( strpos( $method, 'foldable_' ) === 0 ) {
$file = array_shift( $args );
return $this->fold_io( $file, array( $this, substr( $method, 9 ) ), $args );
}
}
protected function fold_io( $file, $foldable, $args = [] ) {
@bor0
bor0 / test.php
Last active April 5, 2020 20:22
Test rlanvin/php-rrule events
<?php
use RRule\RRule;
use RRule\Proxy;
use RRule\Event;
use RRule\ProxyIterator;
require_once( 'vendor/autoload.php' );
$events = array(
[
Set 100
2012 = kd + 32, 0 <= 32 < d < 100
____
xyzx = 32d + k, 0 <= k < d < 100, y < x
Find X = x * 1000 + y * 100 + z * 10 + x
Haskell solution:
Prelude> let kds = [ (k, d) | k <- [1..100], d <- [1..100], 2012 == k * d + 32, 32 < d, d < 100, k < d ]
Prelude> kds
@bor0
bor0 / calevent.hs
Last active December 31, 2018 13:29
Cal Event calculations
import Data.Time
import Data.List
-- Algorithm is based on https://github.com/taterbase/calendar-puzzle
-- Meeting the two major constraints:
-- 1. Every colliding event must be the same width as every other event that it collides with.
-- 2. An event should use the maximum width possible while still adhering to the first constraint.
-- | Main interface for events.
class (Ord a) => CalEvent a where
import Data.Time
import Data.Maybe
type BookingId = Int
data Booking = Booking {
bookingId :: BookingId
, start :: UTCTime
, end :: UTCTime
, allDay :: Bool
@bor0
bor0 / Example.hs
Last active November 20, 2018 11:34
module Example where
import SimpleTheoremProver
import Text.Regex (subRegex, matchRegex, mkRegex)
import Data.List (isSuffixOf)
muRules :: [Rule String]
muRules = [
Rule "One" (\thm -> if (isSuffixOf "I" thm) then (thm ++ "U") else thm)
@bor0
bor0 / lc.scm
Created September 18, 2018 12:21
Lambda Calculus Interpreter
; Constructors
(define (lambda-expr? e)
(and (pair? e)
(equal? (car e) 'λ)
(equal? (caddr e) '→)))
(define (make-lambda argn argv) (list 'λ argn '→ argv))
(define (lambda-param e) (cadr e))
(define (lambda-body e) (cadddr e))
{-
На забава, секое момче ќе изеде 6 или 7 парчиња пица и секое од девојчињата ќе изеде 2 или 3 парчиња пица. Пицата има 12 парчиња.
1. Колку момчиња и девојчиња биле на забавата ако 4 пици биле премалку , а 5 премногу?
2. Што ако 4 пици биле доволно?
3. Што ако 5 пици биле доволно?
-}
{-
Prv slucaj: 48 < parcinja < 60
Vtor slucaj: parcinja = 48
boro@bor0:~/dev$ curl -H "Content-Type: application/json" -X PUT "http://localhost:8080/wordpress/wp-json/wc/v2/products/1080/?consumer_key=c4120d153ebc48b4e168d1bf0ab8ff223accc370921f1792f77c892bce2e2baf&consumer_secret=cs_6834deebd0234808cb205e8e17d0b0ccec7eea31&XDEBUG_SESSION_START=1" --data '{"name":"Testing"}'
{"id":1080,"name":"Testing","slug":"test-5","permalink":"http:\/\/localhost:8080\/wordpress\/product\/test-5\/","date_created":"2018-03-02T12:05:54","date_created_gmt":"2018-03-02T12:05:54","date_modified":"2018-03-02T12:10:56","date_modified_gmt":"2018-03-02T12:10:56","type":"variable","status":"publish","featured":false,"catalog_visibility":"visible","description":"test","short_description":"","sku":"","price":"","regular_price":"","sale_price":"","date_on_sale_from":null,"date_on_sale_from_gmt":null,"date_on_sale_to":null,"date_on_sale_to_gmt":null,"price_html":"","on_sale":false,"purchasable":false,"total_sales":0,"virtual":false,"downloadable":false,"downloads":[],"download_limit":-1,"download