Skip to content

Instantly share code, notes, and snippets.

View gajus's full-sized avatar

Gajus Kuizinas gajus

View GitHub Profile

http://jhusain.github.io/learnrx/

Like an Event, an Observable is a sequence of values that a data producer pushes to the consumer. However unlike an Event, an Observable can signal to a listener that it has completed, and will send no more data.

Querying Arrays only gives us a snapshot. By contrast, querying Observables allows us to create data sets that react and update as the system changes over time. This enables a very powerful type of programming known as reactive programming.

Disposing of a Subscription object unsubscribes from the event and prevents memory leaks. Disposing of a subscription is the asynchronous equivalent of stopping half-way through a counting for loop.

If we convert Events to Observable Objects, we can use powerful functions to transform them.

function() {
var videos = [
{
"id": 65432445,
"title": "The Chamber"
},
{
"id": 675465,
"title": "Fracture"
},
@gajus
gajus / gist:2f2d7cb9c674a8b8e86c
Created June 16, 2015 16:57
Erase the scrollback history.
/**
* Erase the scrollback history.
*/
function clearScrollback () {
if (php_sapi_name() !== 'cli') {
throw new Exception('Use of function in invalid interface context.');
}
$term_program = getenv('TERM_PROGRAM');
2015-05-13 08:46:07 ↺ GET https://api.wuaki.tv/movies?device=iphone&page=1&per_page=2&search%5Bmeta_sort%5D=title.asc
← 200 application/json 10.07kB 2.25MB/s
Request Response
Access-Control-Allow-Origin: *
Access-Control-Request-Method: *
Age: 0
Cache-Control: max-age=60, public
Content-Type: application/json; charset=utf-8
Date: Wed, 13 May 2015 07:46:34 GMT
ETag: "b4816887d1a5cbae4bd79ab1cf1cda57"
About four months ago I have bought an air humidifier (Dyson Humidifier). I have set it to maximum and left it next to my bed – I thought it will help my skin. It did. However, few weeks later a ringing started in my head (high-pitch) and then a more noticeable ringing in my right ear (low tone). ENT doctor have not found ear damage or change in my hearing. The cause is unknown.
Air humidifier was about the only change in my life around that time. I am not jumping to the conclusions. Quick Google search for tinnitus and air humidifier came back with nothing. Going to throw this out in case more people observe a similar happening and start to Google.
@gajus
gajus / gist:846dbab74af1d3b3ced7
Created December 19, 2014 17:22
SCSS for gist embed
//colors
$color_mine_shaft_approx: #333;
$color_guardsman_red_approx: #c00;
$black: #000;
$color_gallery_approx: #eee;
$color_tapa_approx: #777;
$color_mercury_approx: #e7e7e7;
$color_alto_approx: #ddd;
$white: #fff;
$color_celeste_approx: #ccc;
<!DOCTYPE html>
<html>
<head>
<script src="./angular.js"></script>
<script src="./todo.js"></script>
</head>
<body ng-app="foo">
</body>
</html>
// https://gist.github.com/gajus/34bad88fa34426380e64
{
"parser": "babel-eslint",
"rules": {
"no-console": 0,
"no-extra-parens": 2,
"no-reserved-keys": 2,
"no-eq-null": 2,
"no-extend-native": 2,
"no-process-env": 2,