Skip to content

Instantly share code, notes, and snippets.

Amhed Herrera amhed

  • San Francisco, CA
Block or report user

Report or block amhed

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
amhed / constructor.js
Created Jan 14, 2014
Ejemplo del constructor design pattern en javascript
View constructor.js
var ConstructorName = (function() {
'use strict';
var variablePrivada = 0;
function ConstructorName(args) {
// enforces new
if (!(this instanceof ConstructorName)) {
return new ConstructorName(args);
amhed / parcheesiTest.js
Created Nov 19, 2013
Example of TDD with NodeJS
View parcheesiTest.js
//This uses mocha + should.js for running the unit tests
it('should allow players to take out a Pawn when a five(5/x) is rolled', function() {
//Since the dice throws random numnbers, we either need to throw it many times until
//we get the value we want, or just overwrite it's functionality.
//Here we chose to overwrite using the sinonJS mocking framework
sinon.stub(game, 'throwDices').returns([5,4]);
sinon.stub(game, 'lastDiceThrow').returns([5,4]);
View probabilityTest.cs
public void FichasRepartidasAJugadoresDebenSerBarajadas()
var probabilidad = 1m/28m;
int cantidadCajitas = 0;
for (int i = 0; i < 100; i++)
var juego = new JuegoDomino();
if (juego.Jugadores[0].Fichas[0].Equals(new Ficha(0, 0)))
View chefOdd.cs
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ChefOdd{ class Program { static void Main(string[] args) { var qty = Convert.ToInt32(Console.ReadLine()); var testCases = new int[qty]; for (var i = 0; i < qty; i++) { var input = Convert.ToInt32(Console.ReadLine()); testCases[i] = input; } for (var i = 0; i < qty; i++) { GetBestPlace(testCases[i]); } Console.Read(); } private static void GetBestPlace(int testCase) { var initArray = Enumerable.Range(1, testCase).ToArray(); Console.WriteLine(DrawArray(initArray)); while (initArray.Length > 1) { var newArrSize = initArray.Length/2; var newArr = new int[newArrSize];
View jsonexample.js
   "@name": "WasteLands",
   "@tilesPerRow": "50",
   "@tilesPerColumn": "50",
   "@PixelsPerTile": "60",
   "tileType": [
         "@name": "gold",
         "@weight": "10"
amhed / NullOrEmpty.cs
Created Oct 1, 2013
IsNullOrEmpty decompiled source
View NullOrEmpty.cs
public static bool IsNullOrEmpty(string value) { if (value != null) return value.Length == 0; else return true; }
amhed / Attachments_Basecamp.rb
Created Sep 8, 2013
Ejemplo de como subir un attachment a Basecamp desde Ruby
View Attachments_Basecamp.rb
require 'rubygems'
require 'json'
require 'net/http'
require 'uri'
#HTTP Request Objects
uri = URI.parse('') #ruta de subir attachments en Basecamp
@https =,uri.port)
@https.use_ssl = true
amhed / HourManagement.cs
Created Jun 17, 2013
Ejemplo de manejo de horas para
View HourManagement.cs
using System;using System.Linq;namespace EjemploDevDo{ public class HourManagement { //Supongo que esta lista viene de una BD o de algún servicio private static readonly DateTime[] listaFeriados2013 = new[] { new DateTime(2013,1,1), new DateTime(2013,1,6), new DateTime(2013,1,26), new DateTime(2013,2,27), new DateTime(2013,3,29), new DateTime(2013,5,1), new DateTime(2013,5,30), new DateTime(2013,8,16), new DateTime(2013,9,24), new DateTime(2013,11,6), new DateTime(2013,12,25), }; public static DateTime CalcularFechaRespuesta(DateTime fechaInicio, int cantidadHoras) { var horaInicio = 8; var horaTermino = 17; var fechaRespuesta = fechaInicio; //Se aplica la operacion de
amhed / javascriptUrlParams
Created Jun 15, 2013
Getting url parameters with javascript (no plugins needed)
View javascriptUrlParams
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(;
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
//Taken from stackoverflow
You can’t perform that action at this time.