Skip to content

Instantly share code, notes, and snippets.

leandromoreira / gist:3671392
Created Sep 8, 2012
Use seq instead of empty?
View gist:3671392
(def pack [])
;try to avoid this
(if (not (empty? pack)) (print "something") (print "empty"))
;in favor of this
(if (seq pack) (print "something") (print "empty"))
leandromoreira /
Created Oct 22, 2012
Do something in all subdirectories Unix Shell Terminal Command
$ for dir in *; do echo $dir ; done;
View robot.js
var Robot = function(robot) {
var firstTime = true;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
var moveAhead = Math.floor(Math.random()*101);
View angular_factory.js
.factory('theirTwitterFactory', function($http){
var factory = {};
.success(function(data, status, headers, config) {
factory.tweets = data;
return {
tweets: function(){
leandromoreira /
Created Jul 16, 2013
cd / && sudo du -aH --max-depth=1
cd / && sudo du -aH --max-depth=1
leandromoreira / gist:6024640
Created Jul 17, 2013
framebuffer xvfb run tests headless (sweet reminder)
View gist:6024640
/usr/bin/Xvfb :99 -ac -screen 0 1024x768x16
View angular-timeout.html
<!doctype html>
<html ng-app="myApp">
<script src=""></script>
<div ng-controller="TodoCtrl">
<button ng-click="beQuickOrBeDead()">Fetch with 100ms timeout</button>
<button ng-click="neverEndingStory()">Fetch with default timeout</button>
View example.js
//my initial config
app.config(["$routeProvider", function($routeProvider){
.when('/list_streams', {
templateUrl: 'assets/angular/views/target_bitrates.html',
controller: 'TargetBitratesCtrl'
templateUrl: 'assets/angular/views/create_live_media.html',
View service.js
.factory('TargetBitrates', ["$http", "$timeout", "Config", function($http, $timeout, Config){
var data = {list: []};
var onSuccess = function(result){
data.list =;
$timeout(poller, Config.pollingTimeout);
var poller = function() {
$http.get('/streams.json', Config.httpOptions).then(onSuccess);
leandromoreira / songs.js
Created Aug 7, 2013
Example of testing angular (angularjs) factory using http.
View songs.js
.factory('Songs', function($http, $timeout, Config){
var response = {list: []};
var onSuccess = function(result){
response.list =;
$timeout(poller, Config.pollingTimeout);
var poller = function(){
$http.get('api/songs.json', Config.httpOptions).then(onSuccess);