Skip to content

Instantly share code, notes, and snippets.

Juan María Hernández jmhdez

Block or report user

Report or block jmhdez

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
@jmhdez
jmhdez / Id.cs
Created Apr 14, 2013
Id implementation using phantom types
View Id.cs
public struct Id<T>
{
public readonly int Value;
public Id(int value)
{
this.value = value;
}
public static implicit operator Id<T>(int value)
@jmhdez
jmhdez / ko-chart.js
Last active Feb 11, 2019
Custom bindings to use Chart.js with Knockout.js
View ko-chart.js
/*global ko, Chart */
(function(ko, Chart) {
ko.bindingHandlers.chartType = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
if (!allBindings.has('chartData')) {
throw Error('chartType must be used in conjunction with chartData and (optionally) chartOptions');
}
},
@jmhdez
jmhdez / marvel-api.clj
Last active Feb 23, 2018
Using the Marvel API from clojure
View marvel-api.clj
;; required deps [clj-http "0.9.2"]
(ns marvel-clj.core
(:require [clj-http.client :as http]
[clj-http.util :as util]
[clojure.string :as str])
(:gen-class))
(def public-key "YOUR_PUBLIC_KEY_HERE")
(def private-key "YOUR_PRIVATE_KEY_HERE")
@jmhdez
jmhdez / GetTweets.cs
Created Jun 13, 2012
Get twitter's home timeline
View GetTweets.cs
// Related code: https://gist.github.com/2905028
public IEnumerable<string> GetTimeline(int count)
{
// Application tokens
const string CONSUMER_KEY = "YOUR_CONSUMER_KEY";
const string CONSUMER_SECRET = "YOUR_CONSUMER_SECRET";
// Access tokens
const string ACCESS_TOKEN = "YOUR_ACCESS_TOKEN";
const string ACCESS_TOKEN_SECRET = "YOUR_ACCESS_TOKEN_SECRET";
@jmhdez
jmhdez / console.js
Last active Dec 14, 2016
Javascript console replacement
View console.js
(function(window, document) {
// Create the DOM structure to hold the console messages
var div = document.createElement("div");
div.style.cssText = "position: absolute; " +
"top: 5px; left: 5px; right: 5px; bottom: 5px; " +
"padding: 10px; " +
"overflow-y: auto; " +
"display: none; " +
View core.clj
(ns rpg-kata-clj.core
(:require [clojure.set :refer [intersection]]))
(defrecord Entity [health level attack factions type])
(defn new-character []
(->Entity 1000 1 :melee #{} :character))
(defn new-prop [health]
(->Entity health 1 :melee #{} :property))
@jmhdez
jmhdez / DuckType.cs
Created Dec 8, 2012
Duck Typing con C#
View DuckType.cs
// Required libs
// - NUnit
// - Castle.DynamicProxy
using System;
using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;
using NUnit.Framework;
@jmhdez
jmhdez / zebra-puzzle-loco.clj
Last active May 23, 2016
Solving the zebra puzzle with loco
View zebra-puzzle-loco.clj
(ns loco-playground.core
(:require [loco.core :refer :all]
[clojure.pprint :refer :all]
[loco.constraints :refer :all]))
;; http://bypacoman.blogspot.com.es/2013/08/desestructurando-el-puzzle-de-einstein.html
;; ---- Datos de referencia
(def domain
View Post_tweet.cs
public void UpdateStatus(string message)
{
// Application tokens
const string CONSUMER_KEY = "YOUR_CONSUMER_KEY";
const string CONSUMER_SECRET = "YOUR_CONSUMER_SECRET";
// Access tokens
const string ACCESS_TOKEN = "YOUR_ACCESS_TOKEN";
const string ACCESS_TOKEN_SECRET = "YOUR_ACCESS_TOKEN_SECRET";
// Common parameters
View 8queens-loco.clj
;; depends on [loco "0.3.1"]
(ns loco-playground.core
(:require [loco.core :refer :all]
[loco.constraints :refer :all]))
(def queens-model
(conj
;; Variables [:x i] [:y i] para la posición de la reina i-ésima
(mapcat #(vector ($in [:x %] 0 7) ($in [:y %] 0 7)) (range 8))
;; Todas las filas deben ser distintas
You can’t perform that action at this time.