Skip to content

Instantly share code, notes, and snippets.

View RadoRado's full-sized avatar

Radoslav Georgiev RadoRado

View GitHub Profile
@RadoRado
RadoRado / gist:947073
Created April 28, 2011 19:12
PHP 11 Course, Homework 5 helper
<?php
$fileName = $_POST["fileName"];
// here, search for the file recursively in all folders down from this level
// and print the file path if found
// otherwise, print OMG A BEAR! FILE NOT FOUND.
?>
<html>
<head>
<title>File Search</title>
@RadoRado
RadoRado / gist:957938
Created May 5, 2011 21:07
Homework #6 for the elective PHP course
<?php
/**
* Basic interface that represents a single view (HTML page)
*/
interface IView {
/**
* Renders and displays the HTML.
* For example - should work like $smarty->display("some.tpl")
@RadoRado
RadoRado / gist:957982
Created May 5, 2011 21:21
Use-case for the Homework #6 Gist
<?php
$v = new View(); // some class that implements the IView inteface
$v->setTitle("Use case for the homework");
$v->setJavascriptFolder("js");
$v->setCSSFolder("styles");
$v->addJavascriptFiles(array("jquery.js", "custom.js"));
$v->addCSSFiles(array("jquery.css", "custom.css"));
$v->assignTemplateVariable("message", "Hello!");
@RadoRado
RadoRado / gist:957994
Created May 5, 2011 21:25
Sample output for Homework #6 use-case
<html>
<head>
<title>Use case for the homework</title>
<link rel="stylesheet" href="styles/jquery.css" type="text/css" media="screen" />
<link rel="stylesheet" href="styles/custom.css" type="text/css" media="screen" />
<script src="js/jquery.js" type="text/javascript" language="javascript" charset="utf-8"></script>
<script src="js/custom.js" type="text/javascript" language="javascript" charset="utf-8"></script>
</head>
<body>
@RadoRado
RadoRado / trans.hs
Created August 27, 2012 10:53
Държавен изпит, задачата по функционално
import Data.List
-- Фунцкията проверява дали между двата списъка има поне 1 общ елемент
-- пример - между [1,2,3] и [4,5,6] няма да има общ елемент и няма да съвпада с условието на задачата
-- функцинята nub връща списък от уникални елементи
containsOneElement :: Eq a => [a] -> [a] -> Bool
containsOneElement a b = (length (a ++ b) /= length (nub (a ++ b)))
-- фунцията проверява дали check изпълнява условието с всеки един от подсписъците на [[a]]
checkEach :: Eq a => [a] -> [[a]] -> Bool
@RadoRado
RadoRado / index.html
Created May 15, 2013 19:24
TODO List example from the last lecture. index.html requires two files - jquery-2.0.0.js and underscore.js in order to run. You can get them from everywhere
<!DOCTYPE html>
<html>
<head>
<title>Simple TODO List</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div id="todoListContainer">
<ul id="todoListBody">
@RadoRado
RadoRado / name_autocomplete.php
Created August 18, 2013 16:22
Mock data for autocompleting
<?php
header('Content-Type: application/json; charset=utf-8');
$id = 1;
$allNames = array(
array("name" => "Ivan Ivanov", "id" => $id++),
array("name" => "Radoslav Georgiev", "id" => $id++),
array("name" => "Мартин Йорданов", "id" => $id++),
array("name" => "Мартин Анев", "id" => $id++),
array("name" => "Петър Събев", "id" => $id++),
array("name" => "Виктория Христова", "id" => $id++),
@RadoRado
RadoRado / program.json
Last active December 25, 2015 14:49
FMI's program in JSON format
{
"bachelor" : {
"label" : "Бакалавър",
"Informatics" : {
"label" : "Информатика",
"year1" : {
"label" : "1ви курс",
"flows" : [
{
"monday" : {
@RadoRado
RadoRado / compose.scm
Last active December 25, 2015 17:09
Difference between composing funcions and returning result and composing functions and returning new function
; в този вариант, функцията compose връща директно резултата
; като изпълниш (f (g x)) - ако x е число, накрая просто ще ти върне някакъв резултат
(define (compose-first f g x)
(g (f x)))
; например това извикване ще ти даде директно резултат 2
(compose-first (lambda (x) (+ x 1)) (lambda (x) (- x 1)) 2)
; този compose, не ти връща директно скаларен резултат
@RadoRado
RadoRado / router.js
Created October 11, 2014 21:18
Minimal NodeJS HTTP router, made for an example. Kudos to @asotirov
/* global module, console */
module.exports = function(http, port) {
'use strict';
var routes = {};
var exportMethods = {};
var middlewares = [];
['get', 'post', 'put', 'delete'].forEach(function(method) {
routes[method] = routes[method] || {};