Skip to content

Instantly share code, notes, and snippets.

@albulescu
albulescu / rip.rb
Last active August 29, 2015 14:00
Products ripper
require 'open-uri'
require 'nokogiri' #You need to install this gem
require 'net/http'
require 'pp'
require 'csv'
=begin
@autor Albulescu Cosmin <cosmin@albulescu.ro>
(function(){
})();
<?php
use Phalcon\Mvc\Micro,
Phalcon\Events\Manager as EventsManager,
Phalcon\Http\Response,
Phalcon\Http\Request;
//Create a events manager
$eventManager = new EventsManager();
@albulescu
albulescu / autoscroll.js
Last active August 29, 2015 14:11
Angular AutoScroll Directive
/*
$scope.autoScrollEnabled = true;
$scope.onSendMessage = function() {
// enable autoscrolling in case is disabled by user scroll up
$scope.$emit('$enableAutoScroll');
};
@albulescu
albulescu / gist:2c186e66b17212eb8ed7
Last active August 29, 2015 14:17
Manually run chef-solo on instance
echo "cookbook_path [\"/opt/aws/opsworks/current/site-cookbooks\"]" > solo.rb && opsworks-agent-cli get_json > attributes.json && sudo /opt/aws/opsworks/current/bin/chef-solo -c ./solo.rb -j ./attributes.json -o
----- html
<div ng-class="ChatController">
<chat>
<div chat-messages class="messages">
<div chat-message class="message-item">
</div>
</div>
<div class="footer">
@albulescu
albulescu / test.go
Created February 12, 2016 14:44
Nodes merge and sort
/*
There are sets of node ids which contain partly-contiguous ranges of node ids.
The rst part of the exercise is to (in a language of your choice) model the
ranges in a space ef cient manner.
An example set:
a/1, a/2, a/3, a/4, a/128, a/129, b/65, b/66, c/1, c/10, c/42
Secondly, given the model already developed, write an algorithm that
will add two sets, merging any overlapping ranges.
const flatten = arr => arr.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);
@albulescu
albulescu / gist:82ad75f9f478631734961a0d239b016a
Last active July 13, 2016 13:58
Ng 1.5 to 2 component standard
# Angular 1.5
class Button {
constructor( $http ) {
this.http = $http;
}
}
angular.module('x').component('xbutton', {
...,
controller: Button
});
@albulescu
albulescu / StyleChangeWatcher.js
Created July 15, 2016 13:18
Angular 2 style change watcher
const watcher = new StyleChangeWatcher();
watcher.watch(element, ["width"]);
watcher.observer.subscribe((event:StyleChangeEvent) => {
console.log('Element:', event.element);
console.log('Change:', event.change.property,':', event.change.previous, '=>', event.change.current);
});