Skip to content

Instantly share code, notes, and snippets.

View bor0's full-sized avatar

Boro Sitnikovski bor0

View GitHub Profile
@bor0
bor0 / gist:3772433
Created September 23, 2012 17:36
Matz
def add(a,b):
return a + b
def subtract(a,b):
return a - b
def divide(a,b):
return a / b
@bor0
bor0 / CountLinesOfCode.hs
Last active August 29, 2015 14:02
CountLinesOfCode
import System.Directory
import Control.Monad (filterM, mapM, liftM)
import System.FilePath ((</>))
getDirsRec :: FilePath -> IO [FilePath]
getDirsRec d = do
dirContents <- getDirectoryContents d
let dirContents' = [ d </> x | x <- dirContents, x /= ".", x /= ".." ]
dirs' <- mapM dirRec dirContents'
return (concat dirs' ++ [d])
#include <stdio.h>
#include <stdlib.h>
#define INTSIZE(x) (sizeof(x)/sizeof(int))
int bs_test[] = { 1, 5, 9, 11, 15, 19, 21, 22, 27, 31, 55, 59 };
int itera = 0;
int find_bs(int n) {
; The hint is that the state transformation (a) should leave the product b^n a unchanged throughout the states
(define (fast-expt-iter b n a)
(cond ((= n 0) a)
((even? n) (fast-expt-iter (square b) (/ n 2) a)) ; Uses (b^2)^(n/2) = (b^(n/2))^2
(else (fast-expt-iter b (- n 1) (* a b))))) ; b^n a = b^(n - 1) a b
(define (* a b)
(cond ((= a 1) b)
((even? a) (* (halve a) (double b)))
(else (+ a (* a (- b 1)))))
)
; Design c such that the product a * b remains unchanged from state to state
(define (iter-mult a b c)
(cond ((= b 0) c)
((even? a) (iter-mult (halve a) (double b) c))
(else (iter-mult a (- b 1) (+ c a)))))
curl -X POST http://localhost:8080/wordpress3/wp-json/wc/v1/products \
-u key:secret \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Test",
"short_description": "Test",
"downloadable": true,
@bor0
bor0 / plupload-demo.php
Created March 17, 2017 19:43
PLUpload Demo
<?php
/*
Plugin Name: PLUpload Demo
Plugin URI: http://wordpress.org/
Description: This is a demo that uses core PLUpload.
Author: Boro Sitnikovski
Version: 1.0
Author URI: http://bor0.wordpress.com/
*/
@bor0
bor0 / wat
Created February 1, 2018 20:11
Def 1: |A| = n iff there is a bijection from A to {1,2,3,...,n}.
Lemma 1: if f is a bijection, then f^(-1) is a bijection
Lemma 2: Show that if f : A -> B and g : B -> C are bijections, then g ◦ f is a bijection.
Prove: Given f : A -> B is a bijection, prove that |A| = |B|.
Proof.
For |A| = n, we have that there exists a bijection g : { 1, 2, ..., n } -> A
For |B| = m, we have that there exists a bijection h : {1, 2, ..., m } -> B
Let |f| = F.
// based off of https://github.com/bor0/misc/blob/master/2017/tree.js
// example: https://github.com/bor0/misc/blob/master/2017/tree_test.js
var tree = {
v: 1,
l: {
v: 2,
l: {
v: 3,
l: { v: 4 },