Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
leandromoreira / gist:3671392
Created September 8, 2012 02:27
Use seq instead of empty?
(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
leandromoreira / do_something_all_subdirectoreis.sh
Created October 22, 2012 16:45
Do something in all subdirectories Unix Shell Terminal Command
$ for dir in *; do echo $dir ; done;
@leandromoreira
leandromoreira / robot.js
Created December 5, 2012 22:52
dreampeppers99
var Robot = function(robot) {
};
var firstTime = true;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
var moveAhead = Math.floor(Math.random()*101);
robot.ahead(moveAhead);
angular.module('twitter')
.factory('theirTwitterFactory', function($http){
var factory = {};
$http.get('/data/theirs.json')
.success(function(data, status, headers, config) {
factory.tweets = data;
});
return {
tweets: function(){
@leandromoreira
leandromoreira / disk_usage.sh
Created July 16, 2013 14:53
cd / && sudo du -aH --max-depth=1
cd / && sudo du -aH --max-depth=1
@leandromoreira
leandromoreira / gist:6024640
Created July 17, 2013 21:25
framebuffer xvfb run tests headless (sweet reminder)
/usr/bin/Xvfb :99 -ac -screen 0 1024x768x16
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
</head>
<body>
<div ng-controller="TodoCtrl">
<button ng-click="beQuickOrBeDead()">Fetch with 100ms timeout</button>
<button ng-click="neverEndingStory()">Fetch with default timeout</button>
//my initial config
app.config(["$routeProvider", function($routeProvider){
$routeProvider
.when('/list_streams', {
templateUrl: 'assets/angular/views/target_bitrates.html',
controller: 'TargetBitratesCtrl'
})
.when('/transmissions',{
templateUrl: 'assets/angular/views/create_live_media.html',
angular.module('Sauron')
.factory('TargetBitrates', ["$http", "$timeout", "Config", function($http, $timeout, Config){
var data = {list: []};
var onSuccess = function(result){
data.list = result.data.data;
$timeout(poller, Config.pollingTimeout);
};
var poller = function() {
$http.get('/streams.json', Config.httpOptions).then(onSuccess);
};
@leandromoreira
leandromoreira / songs.js
Created August 7, 2013 13:46
Example of testing angular (angularjs) factory using http.
angular.module('pearlJam')
.factory('Songs', function($http, $timeout, Config){
var response = {list: []};
var onSuccess = function(result){
response.list = result.data.data;
$timeout(poller, Config.pollingTimeout);
};
var poller = function(){
$http.get('api/songs.json', Config.httpOptions).then(onSuccess);