Skip to content

Instantly share code, notes, and snippets.

View mpereira's full-sized avatar

Murilo Pereira mpereira

View GitHub Profile
@mpereira
mpereira / gist:9574586
Last active August 29, 2015 13:57
Determine if a point is within a triangle
(defn point-in-triangle? [[px py] [[p0x p0y] [p1x p1y] [p2x p2y]]]
(let [n (* 0.5
(+ (* (- p1y) p2x)
(* p0y (+ (- p1x) p2x))
(* p0x (- p1y p2y))
(* p1x p2y)))
sign (if (neg? n) -1 1)
s (* sign
(+ (* p0y p2x)
(- (* p0x p2y))
@mpereira
mpereira / nested_map_value_path.clj
Created February 27, 2014 02:10
Finding the path of a node in a tree.
(defn map-zip [m]
(clojure.zip/zipper #(or (map? %) (map? (nth % 1)))
#(seq (if (map? %) % (nth % 1)))
(fn [x children]
(if (map? x)
(into {} children)
(assoc x 1 (into {} children))))
m))
(defn path [m value]
(ns om-laboratory.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.string :as string]))
(enable-console-print!)
(defn index-of [coll val]
(first (keep-indexed #(if (= %2 val) %1) coll)))
/** @jsx React.DOM */
'use strict';
var TodoApplication = React.createClass({
taskStatuses: {
all: 'all',
todo: 'todo',
done: 'done'
},
@mpereira
mpereira / amazon_wish_list.js
Last active December 25, 2015 03:39
Show the total cost of an Amazon Wish List.
//
// This script shows the total cost of an Amazon Wish List.
//
// Usage:
//
// 1. Open an Amazon Wish List
// 2. Select the "Compact" option in the "View" drop-down
// 3. Click the "GO" button
// 4. Copy and paste the code below in the browser console
// 5. Press Enter
$ ls $ECLIPSE_HOME/plugins | sort
com.ibm.icu_4.4.2.v20110823.jar
com.jcraft.jsch_0.1.44.v201101211721.jar
com.sun.syndication_0.9.0.v200803061811.jar
java_cup.runtime_0.10.0.v201005080400.jar
javax.activation_1.1.0.v201105071233.jar
javax.jws_2.0.0.v201005080400.jar
javax.mail_1.4.0.v201005080615.jar
javax.persistence_2.0.3.v201010191057.jar
javax.servlet.jsp_2.0.0.v201101211617.jar
2013-09-07 10:01:47,341 DEBUG [main] - ScalaPlugin - added compilation unit __eclim_temp_person.scala
2013-09-07 10:01:47,342 INFO [main] - ScalaPresentationCompiler - shutting down presentation compiler on project: scala
2013-09-07 10:01:47,342 INFO [main] - ScalaProject - Scheduling for reconcile: ArrayBuffer()
2013-09-07 10:01:47,360 DEBUG [main] - ScalaProject - Added output folder: F/scala/src: F/scala/bin
2013-09-07 10:01:47,367 DEBUG [main] - ScalaProject - javabootclasspath: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-common/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-common/jre/lib/ext/pulse-java.jar:/usr/lib/jvm/java-7-openjdk-common/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-common/
java -d64 -Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256m -Xms40m -Xmx512m -jar /home/murilo/.eclipse/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar -debug -clean -refresh -application org.eclim.application_headless
Install location:
file:/home/murilo/.eclipse/
Configuration file:
file:/home/murilo/.eclipse/configuration/config.ini loaded
Configuration location:
file:/home/murilo/.eclipse/configuration/
Framework located:
file:/home/murilo/.eclipse/plugins/org.eclipse.osgi_3.7.2.v20120110-1415.jar
Loading extension: reference:file:javax.transaction_1.1.1.v201105210645.jar
Processor Information:
Vendor: GenuineIntel
Speed: 2401 Mhz
4 logical processors
2 physical processors
HyperThreading: Supported
FCMOV: Supported
SSE2: Supported
SSE3: Supported
SSSE3: Supported
unbindall
bind "0" "+dota_control_group 10"
bind "1" "+dota_camera_follow"
bind "2" "+dota_control_group 2"
bind "3" "+dota_control_group 3"
bind "4" "+dota_control_group 4"
bind "5" "+dota_control_group 5"
bind "6" "+dota_control_group 6"
bind "7" "+dota_control_group 7"
bind "8" "+dota_control_group 8"