Skip to content

Instantly share code, notes, and snippets.

View jneira's full-sized avatar
:octocat:

Javier Neira jneira

:octocat:
View GitHub Profile
@rxaviers
rxaviers / gist:7360908
Last active May 4, 2024 00:48
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@Chouser
Chouser / externs_for_cljs.clj
Created June 17, 2013 13:44
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(ns n01se.externs-for-cljs
(:require [clojure.java.io :as io]
[cljs.compiler :as comp]
[cljs.analyzer :as ana]))
(defn read-file [file]
(let [eof (Object.)]
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
(vec (take-while #(not= % eof)
(repeatedly #(read stream false eof)))))))
@joseanpg
joseanpg / discrete_non_uniform.hs
Last active December 18, 2015 07:49
[Pendiente]
-- Basado en
-- https://twitter.com/joseanpg/status/343757288089190401
-- https://twitter.com/joseanpg/status/343758742455738368
-- https://twitter.com/joseanpg/status/343759216424652802
-- Version ultramejorable: http://t.co/da8tx1LK6r
-- Versión Clojure by @jneira: https://gist.github.com/jneira/5745669
-- con probabilidad inversamente proporcional a las prioridades
import Random
@techtangents
techtangents / Nel.hs
Created January 24, 2013 12:21
Just learning how to instance Comonad on Non-Empty List
module Nel where
import Control.Comonad
infixr 5 :|
data Nel a = a :| [a]
toList :: Nel a -> [a]
toList (a :| as) = a : as
@timyates
timyates / LazyGenerator.groovy
Created April 20, 2012 14:04
LazyGenerator
LazyGenerator.from 1..10 where { it < 3 } transform { it * idx++ } using idx:0 each {
println "Transformed Range $it"
}
LazyGenerator.from x:1..5, y:2..5 where { ( x + y ) % ( x + 2 ) == 0 } eachWithIndex { match, idx ->
println "$idx) $match"
}
LazyGenerator.from 1..10 each {
println "Range: $it"
@Gozala
Gozala / example.js
Created January 29, 2012 03:46
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
-- A simple definition without using any fancy functions.
haskell>let ifMaybe pred value = if pred value then Just value else Nothing
haskell>:t ifMaybe
ifMaybe :: (a -> Bool) -> a -> Maybe a
haskell>ifMaybe (const True) 2
Just 2
haskell>ifMaybe (const False) 2
Nothing
-- Using functions from standard library.
/* Son objetivos fundamentales:
* - Minimizar las funciones ECMAScript utilizadas
* - Optimizar en espacio, evitando la creación de arrays transitorios
*
* Suponemos que no se utilizará esta función con arrays creados
* en frames externos, con lo cual instanceof Array es seguro
*/
function aplaneitor(soa,acu) {
if (soa instanceof Array) {
@lynaghk
lynaghk / gist:1141054
Created August 11, 2011 23:21
Clojure sequentials & maps into JavaScript arrays and objects
(defn jsArr
"Recursively converts a sequential object into a JavaScript array"
[seq]
(.array (vec (map #(if (sequential? %) (jsArr %) %)
seq))))
(defn jsObj
"Convert a clojure map into a JavaScript object"
[obj]
(.strobj (into {} (map (fn [[k v]]
@mjg123
mjg123 / helloclosure.cljs
Created July 21, 2011 23:48
Same jsonp call as before but with gclosure instead of jQuery
(ns helloclosure
(:require [goog.net.Jsonp :as jsonp]))
(defn show [msg]
(let [data-as-json ((js* "JSON.stringify") msg nil 4)]
((js* "alert") data-as-json)))
(defn doajax []
(.send (goog.net.Jsonp. (goog.Uri. "http://api.stackoverflow.com/1.1/users/268619") "jsonp")
nil