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 May 15, 2026 06:40
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';
@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
@ianmurrays
ianmurrays / deploy.rb
Created July 21, 2011 17:26
Runs test locally before deploying on capistrano.
set :test_log, "logs/capistrano.test.log"
namespace :deploy do
before 'deploy:update_code' do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong."
exit
else
puts "--> Tests passed"