Skip to content

Instantly share code, notes, and snippets.

View marti1125's full-sized avatar
🐍

Willy Aguirre marti1125

🐍
View GitHub Profile
@marti1125
marti1125 / gist:5859861
Created June 25, 2013 16:17
Backgrid events examples
grid.collection.on("backgrid:editing", function(e){
alert('editando..');
});
grid.collection.on("backgrid:selected", function (model, selected) {
alert('hola');
});
@marti1125
marti1125 / gist:5477234
Created April 28, 2013 15:34
splat ruby
def describe_favorites(*games)
games.each{|game| puts "Favorite Game: #{game}"}
end
describe_favorites('Mario', 'Contra', 'Metroid')
@marti1125
marti1125 / main.go
Created April 13, 2019 21:41
adjacentElementsProduct
func adjacentElementsProduct(inputArray []int) int {
h := 0
for i := 0; i < len(inputArray); i ++ {
if (i + 1) < len(inputArray) {
if h <= (inputArray[i] * inputArray[i+1]) {
h = inputArray[i] * inputArray[i+1]
}
@marti1125
marti1125 / main.go
Created April 13, 2019 20:18
checkPalindrome
import "strings"
func checkPalindrome(inputString string) bool {
var p []string
for i := len(inputString)-1; i >= 0; i-- {
p = append(p, string(inputString[i]))
}
@marti1125
marti1125 / main.go
Created April 13, 2019 19:43
centuryFromYear
func centuryFromYear(year int) int {
r := 1
s := strconv.Itoa(year)
if len(s) == 4 {
a := string(s[0:2])
b := string(s[2:4])
c, _ := strconv.Atoi(a)
@marti1125
marti1125 / imperative.dart
Created January 21, 2019 03:30
imperative
String scream(int length) => "A${'a' * length}h!";
main() {
final values = [1, 2, 3, 5, 10, 50];
values.map(scream).forEach(print);
values.skip(1).take(3).map(scream).forEach(print);
}
@marti1125
marti1125 / Shape.dart
Created January 21, 2019 03:17
Shape
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@marti1125
marti1125 / Rectangle.dart
Created January 21, 2019 03:11
Rectangle
import 'dart:math';
class Rectangle {
int width;
int height;
Point origin;
Rectangle({this.origin = const Point(0, 0), this.width = 0, this.height = 0});
@override
@marti1125
marti1125 / bicy.dart
Created January 21, 2019 03:03
bicycle.dart
class Bicycle {
int cadence;
int _speed = 0;
int get speed => _speed;
@marti1125
marti1125 / gist:7405008
Created November 10, 2013 22:51
get first day and last day of month using jodatime
DateTimeFormatter formatterFecha = DateTimeFormat.forPattern("dd/MM/yyyy");
DateTime primerDiaDelMes = new DateTime().dayOfMonth().withMinimumValue();
String desde = new LocalDate(primerDiaDelMes).toString(formatterFecha);
DateTime ultimoDiaDelMes = new DateTime().dayOfMonth().withMaximumValue();
String hasta = new LocalDate(ultimoDiaDelMes).toString(formatterFecha);