Skip to content

Instantly share code, notes, and snippets.

View mfdeveloper's full-sized avatar
🕹️
Creating games and mobile apps, every day!

Felipe Michel mfdeveloper

🕹️
Creating games and mobile apps, every day!
View GitHub Profile
@mfdeveloper
mfdeveloper / my_model.rb
Last active August 29, 2015 14:15
Rails - Model with a findAll using multiple conditions
class MyModel < ActiveRecord::Base
attr_acessible :name, :value, :role_id
# Another strategy: multiple conditions with
# multiple ActiveRecord::Relation#where() method calls
def recipients(offset=0, limit=100, data = {})
result = self.order(:id).offset(offset).limit(limit).where('value IS ?', nil)
@mfdeveloper
mfdeveloper / README.md
Last active August 29, 2015 14:16
Ruby Structs and sintax for >= 2.0 features of language

Ruby Structs and Ruby 2.0+ features

In this snippets with code ruby, you will see the sintax of create Structs and some Ruby 2.0+ features. The features are showed:

Ruby 2.0+ features

  • **keyargs and labelled params

Structs

@mfdeveloper
mfdeveloper / README.md
Last active May 6, 2019 01:51
Ruby Modules

Ruby Modules

Here you will find examples of modules in ruby code. The structure is strong, very important and commonly used by ruby developers! Modules can be used like namespaces or mixins (adds new methods to a class).

Namespaces

In ruby code it's common see something like this:

MyModule::MyClass

The character :: is a namespace separator. A dot '.' can be used to, but it's not recommended.

@mfdeveloper
mfdeveloper / Gemfile
Last active August 29, 2015 14:22
Ruby Meta Programming
source 'https://rubygems.org'
gem 'rspec', require: false, group: :test
gem 'simplecov', require: false, group: :test
@mfdeveloper
mfdeveloper / INSTALLATION_GUIDE.md
Last active November 5, 2015 13:49
Monodevelop latest version installation guide and template files on Debian/Ubuntu

MonoDevelop 5.x - Installation Guide

Author: Michel Felipe

  1. Download and install latest mono runtime. Follow the instructions here: Install mono on Debian, Ubuntu, and derivatives

  2. Clone the latest version from MonoDevelop github repo.

git clone git@github.com:mono/monodevelop.git
@mfdeveloper
mfdeveloper / test.js
Created May 5, 2016 19:44
inquirer-npm-name unit test initial changes but doesn't works. Needs verify if is necessary use of "mocha" or "chai" npm packages
describe('npm validation logic (inquirer `when` function)', function () {
beforeEach(function () {
askName2 = proxyquire('../lib', {
'npm-name': function(name){
return Promise.resolve(name == 'yo');
}
});
it('ask question if npm name is taken', function (done) {
this.inquirer.prompt.returns(Promise.resolve({name:'yo'}));
@mfdeveloper
mfdeveloper / component-test.ts
Last active October 9, 2016 10:05
Ionic2-Boilerplate: Angular2 Unit test (still needs changes)
import { DebugElement, Type } from "@angular/core";
import { Predicate } from "@angular/core/src/facade/collection";
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { App, MenuController, NavController, Platform, Config, Keyboard, GestureController, Form, IonicModule } from 'ionic-angular';
import { mockNavController, mockPlatform } from 'ionic-angular/util/mock-providers';
import { ConfigMock, MenuControllerMock, KeyboardMock, GestureControllerMock, FormMock } from './mocks';
/**
* @ngdoc object
@mfdeveloper
mfdeveloper / dynamic-method.ts
Last active January 1, 2021 16:58
This is a example of a dynamic class method on Typescript. Until here, is not possible access class properties inside the overrided/new method
/**
* Typescript dynamic class method example
*
* REFERENCES:
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html
* @see https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Mixins.md
* @see http://blog.brillskills.com/2013/09/exploring-javascript-prototypes-via-typescripts-class-pattern
* @see https://github.com/Microsoft/TypeScript/wiki/%27this%27-in-TypeScript
*
* For this example, using IONIC 2/3 Toast component to override a method
@mfdeveloper
mfdeveloper / copyDepsToLibs.gradle
Last active August 1, 2019 09:41
Copy all dependencies declared in your .gradle file to "libs" folder.
/**
* Custom task to copy all dependencies declared in you .gradle file
* to "libs" folder. If their dependencies contains .jar files, this will be released
* on aar or .jar final file of your project.
*/
task copyLibs(type: Copy) {
from configurations.compile
into 'libs'
}
@mfdeveloper
mfdeveloper / instance-loader.ts
Created January 6, 2018 16:16
Creating TypeScript Classes Dynamically - Totally based on Steve Fenton solution
/**
* Creates a dynamic instance of a specific class/prototype.
* Minor changes from initial solution shared by **Steve Fenton**
*
* WARNING: This solution don't works on Angular applications,
* using JIT (because the webpack don't compiles classes into window object)
* or AOT (js minification for production build) compilation.
*
* @see https://www.stevefenton.co.uk/2014/07/creating-typescript-classes-dynamically/
*/