Skip to content

Instantly share code, notes, and snippets.

View bl4de's full-sized avatar
🇺🇦
#StandWithUkraine

Rafal Janicki bl4de

🇺🇦
#StandWithUkraine
View GitHub Profile
@bl4de
bl4de / gist:5403060
Created April 17, 2013 09:41
Some kind of AMDs JavaScript template
define([], function() {
"use strict";
// Your code goes here
});
@bl4de
bl4de / gist:5416388
Last active December 16, 2015 09:58
For Forebone library I'm currently working on something like simple wrapper for XMLHttpRequest object. This is first skeleton of this object:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Client-server polygon</title>
</head>
<body>
<div id="response"></div>
@bl4de
bl4de / gist:5481070
Created April 29, 2013 11:31
In one of currently released project there was an issue to display values like 12345 as '12,345' (comma before last 3 digits). That's what I've created:
function formatNumber(_value) {
var _return_value = _value.toLocaleString().replace(/\s/gi, ',');
return _return_value;
}
@bl4de
bl4de / gist:5501104
Last active December 16, 2015 21:39
Inspired by Paul Irish's some short introduction into Performance Memory and Timing API in Google Chrome - http://www.youtube.com/watch?feature=player_profilepage&v=MllBwuHbWMY - ( Performance Timing is also available in Firefox) I created a simple object Forebone.Performance in Forebone.js library. First of all, I will create methods to wrap al…
// for now supports both only in Chrome
if (typeof performance.memory == "object" &&
typeof performance.timing == "object") {
/**
* Forebone.Performance - wrapper for performance.timing
* and performance.memory
*/
Forebone.Performance = {
@bl4de
bl4de / sieveoferatostenes.cpp
Created May 6, 2013 22:55
Sieve of Eratosthenes - 1st implementation in C++ @todo: implement properly - current not work
#include <iostream>
#define SCOPE 1000
using namespace std;
int main() {
int tab[SCOPE];
int i = 0;
@bl4de
bl4de / siege.html
Last active December 17, 2015 08:19
Siege of Eratostenes - JavaScript algorithm (working :P )
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="siege"></div>
<script>
@bl4de
bl4de / github_repos.js
Created May 20, 2013 13:45
A little work with Node.js and GitHub API - I'd like to implement some of similar functionality in my new SimpleVirtualAssistant project. Script checks repos of username, passed by url query string param 'username': http://127.0.0.1:2323/?username=bl4de
var http = require("http");
var https = require("https");
var url = require("url");
var port = "2323";
var host = "127.0.0.1";
var server = http.createServer( function(request,response) {
var _url = url.parse(request.url, true);
@bl4de
bl4de / getusermedia.js
Created May 25, 2013 22:29
Using getUserMedia() is quite simple. Little PoC (Proof-of-Concept) available here: https://github.com/bl4de/getUserMedia-PoC
//
// Rafal 'bl4de' Janicki <bloorq@gmail.com>
//
// getUserMedia WebKit demo - main script
//
(function () {
"use strict";
var video = document.querySelector('video');
@bl4de
bl4de / tooltip.js
Created May 27, 2013 21:00
While I work on my new project, VirtualAssistant, I created simple code, which allows to add tooltip to any DOM element on page. Of course, I should pass as second argument some kind of callback, which draws tooltip baloon with text, because for now, it's simple 'title' HTML attribute added 'on the fly' :)
var VAEngine = VAEngine || ( function() {
function addTooltip(_element, _tooltipText) {
var _elem = document.querySelector(_element);
console.log("_elem: ", _elem);
_elem.addEventListener('mouseover', function() {
_elem.title = _tooltipText;
});
}
@bl4de
bl4de / menu.css
Last active December 17, 2015 19:49
Some nice effect with CSS3 transitions
* {
font-family: Verdana, Arial;
font-size: 12px;
font-weight: normal;
padding: 0;
margin: 0;
}
body {
width: 960px;