Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Javier Neira jneira

:octocat:
View GitHub Profile
@rxaviers
rxaviers / gist:7360908
Last active Aug 11, 2022
Complete list of github markdown emoji markup
View gist:7360908

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 Jun 17, 2013
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.
View externs_for_cljs.clj
(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)))))))
View discrete_non_uniform.hs
-- 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 Jan 24, 2013
Just learning how to instance Comonad on Non-Empty List
View Nel.hs
module Nel where
import Control.Comonad
infixr 5 :|
data Nel a = a :| [a]
toList :: Nel a -> [a]
toList (a :| as) = a : as
View LazyGenerator.groovy
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 Jan 29, 2012
Workaround for lack of "tail call optimization" in JS
View example.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
View gist:1266912
-- 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.
View phineas.js
/* 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 Aug 11, 2011
Clojure sequentials & maps into JavaScript arrays and objects
View gist:1141054
(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 Jul 21, 2011
Same jsonp call as before but with gclosure instead of jQuery
View helloclosure.cljs
(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