Skip to content

Instantly share code, notes, and snippets.

View vemv's full-sized avatar
🧑‍💻
Sprinting

vemv vemv

🧑‍💻
Sprinting
View GitHub Profile
@mtnygard
mtnygard / query.clj
Created February 8, 2013 22:19
Use Datomic queries as a source for RxJava pipes.
(ns rxjava-datomic.query
(:require [datomic.api :as d])
(:use [clojure.repl :only [pst]])
(:import [rx Observable]
datomic.Peer))
(defn query [qry & inputs]
(Observable/toObservable
(Peer/q qry (object-array inputs))))
(require 'clojure.pprint 'clojure.set)
(def clojuresphere-top "http://www.clojuresphere.com/api/projects?limit=500&sort=dependents&output=clojure")
(defn exec
[& shell-tokens]
(.. Runtime getRuntime (exec (into-array String shell-tokens)) waitFor))
(defn namespace-usage
[git-path clone-path namespaces]
(get-in {:k :v} [:k]) ;; => :v
(update-in {:k :v} [:k] (constantly :x)) ;; => {:k :x}
(get-in {:k :v} []) ;; => {:k :v}
(update-in {:k :v} [] (constantly {:k :x})) ;; => {nil {:k :x}, :k :v}
anonymous
anonymous / array.length.md
Created January 3, 2013 22:43
Qué pasa con array,length en Javascript que me estoy volviendo loco

Sea:

var a = [];

Dice la especificación de Javascript que los Arrays son simplemente unos objetos un poco curiosos y más o menos simpáticos. Tienen una propiedad especial llamada length y si le intentamos añadir una propiedad con un nombre que sea un número válido (uint32) entonces lo consideran un "índice" y tratan ese valor como un elemento de un array/vector/llámaloX que mantiene internamente.

La propiedad length es especial porque se actualiza más allá de nuestro control cuando ocurren algunas cosas. En concreto lo que dice la especificación es son las siguientes 2 cosas: Cada vez que se añada al array un elemento, es decir, cito (énfasis mío): "una propiedad cuyo nombre es un índice válido de array, si es necesario, length se actualizará a ser 1 más que ese índice". Además, cuando se modifique length, para mantener la restricción, "cualquier propiedad cuyo nombre es un índice válido que no es menor que el nuevo length, se borra automáticamente".

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active April 29, 2025 08:29
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@stuartsierra
stuartsierra / lein2-issue.md
Created July 6, 2012 21:04
'file:' repositories in Leiningen 2.0.0-preview5 and later

Sample Project

Starting from:

lein new foo
cd foo

Say I have a random JAR file that is not available in any repository:

touch README.md

@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@steve9001
steve9001 / application.rb
Created December 7, 2011 16:18
Rails middleware to provide information about errors during requests
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end
@mm53bar
mm53bar / deploy.rb
Created October 7, 2011 21:05
My capistrano deployment
require File.join(File.dirname(__FILE__), 'deploy/nginx')
require File.join(File.dirname(__FILE__), 'deploy/log')
default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }
set :application, "appname"
set :repository, "git@giturl"
set :scm, :git