Skip to content

Instantly share code, notes, and snippets.

View masylum's full-sized avatar
💅
Being fantastic

Pau Ramon Revilla masylum

💅
Being fantastic
View GitHub Profile
@masylum
masylum / Gemfile
Last active August 29, 2015 13:59
Redbooth oauth example
source "https://rubygems.org"
gem "thin", "~> 1.6.1"
gem "sinatra", "~> 1.4.4"
gem "json", "~> 1.8.1"
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-redbooth'

Setup your iOS projects for testing

image

In other programming communities, like the Ruby one, developers are more aware of testing new components. Ensuring every component is tested is not common within the mobile appcommunity.

Fortunately, iOS developers have been working over the years to bring that culture to iOS too. The community is developing new libraries that use native ones allow you to write your tests with a fresh and more readable syntax. This has provided a big impulse and every day more and more developers ensure that expected behaviour in their apps is tested.

The Redbooth iOS Team we've been strongly influenced by the Ruby backend team and we decided to introduce testing into our development flow. Thanks to components like Cocoapods, Schemes and targets and some other tools, testing has become an essential part of development cycle.

/*
Add this as bookmark in your browser and tap on the bookmark when your are creating a new PR.
Example: http://cl.ly/image/0D1k0d1W1R0Y/Screen%20Shot%202015-01-26%20at%203.57.30%20PM.png
*/
javascript:(function() {
var e = document.getElementById('pull_request_body');
if (e) {e.value +='#### :tophat: What? Why?\n\n\n#### :dart: What should QA test?\n\n\n#### :pushpin: Related tasks?\n\n\n#### :family: Dependencies?\n\n\n#### :clipboard: Subtasks\n- [x]\n- [ ]\n\n\n#### :ghost: GIF\n![]()';}
})();
@masylum
masylum / node_mongo_groups.js
Created October 19, 2010 16:13
Async with For Loop
var login_counts = [],
j = 30,
// functions scope
add_count = function (index, query) {
collection.find({date: query},function (err, cursor) {
cursor.count(function (err, count) {
login_counts[index] = count;
});
});
};
@masylum
masylum / node_omngodb_groups.js
Created October 19, 2010 16:20
Async with For Loop 2
var login_counts = [],
j = 30;
for (;j > 0;j--) {
tday.setDate(tday.getDate()+1);
yday.setDate(tday.getDate()+1);
// scope
(function (index, query) {
collection.find({date: query},function (err, cursor) {

Rectify

Takes a grid and returns an optimal set of rectangles that fills that grid

For example, the following grid:

[[1,1,0,1,1],
 [1,1,1,1,1],
 [0,1,1,1,0]]
@masylum
masylum / s3upload.js
Created December 19, 2010 17:48
Upload files directly to s3
function upload (req, res) {
var Formidable = require('formidable'),
form = new Formidable.IncomingForm();
form.encoding = 'utf-8';
form.onPart = function (part) {
if (!part.filename) {
form.handlePart(part);
} else {
(function () {
@masylum
masylum / formidable_test.js
Created January 4, 2011 20:13
Formidable fails if the request is already emited. formidable.parse fails if an asynchronous event happens before.
var formidable = require('formidable'),
http = require('http'),
sys = require('sys');
server = http.createServer(function(req, res) {
req.pause();
req.on('data', function(buffer) {
console.log('data parsed');
});
var A = ['01001100', '01101000', '01010000', '01010011', '01001001', '01000011', '01101000', '01101001', '01110110', '01101001', '01110000', '01101100', '01100010', '01000111', '01101000', '01111010', '01100101', '01111001', '01101101', '01100001'],
B = ['10010001', '01011110', '01100101', '10011010', '10000010', '11110000', '11010000', '00101101', '11111000', '11010110', '11100000', '00011011', '01101110', '11110000', '01101100', '01101010', '11001010', '11001011', '01101110', '01110010'],
rotate = function (shift, str) {
return str.slice(1) + shift;
},
isRotated = function (a, b) {
return [].some.call(b, function (el) {
return b = rotate(el, b), a === b;
let divisors n = [x | x <- [1..n], n `rem` x == 0, x /= n]
let subsets xs = (map concat . sequence) [ [[],[x]] | x <- xs ]
let sumSubsets xs = [sum x | x <- subsets xs, x /= []]
let challenge = [x | x <- [1..553], sum(divisors x) > x, all (/=x) (sumSubsets $divisors x)]