Skip to content

Instantly share code, notes, and snippets.

@dmt
dmt / huawei.sh
Created November 19, 2019 10:29
Remove huawei installed apps
#!/bin/bash
remove() {
local item=$1
echo adb shell pm uninstall -k --user 0 $item
read
/Users/danieltemme/Library/Android/sdk/platform-tools/adb shell pm uninstall -k --user 0 $item
}
remove com.baidu.input_huawei
@dmt
dmt / tooltip_async_spec.js
Created April 4, 2012 16:20
jasmine clock example
describe("ToolTip async", function () {
beforeEach(function () {
setFixtures("<form action='#'><input name='foo' type='text' /></form>");
// putting the implementation here for brevity
$(':input').on("focus", function () {
setTimeout(function () {
$("<div class='tooltip'>Some Tooltip</div>").prependTo('form');
}, 200);
});
});
@dmt
dmt / gist:1096897
Created July 21, 2011 10:03
functions as map keys
(def testsToConst {
(fn list?) :list,
(fn vector?) :vector
;; etc...
})
;; filter keys in the map by evaluating them for a given col argument,
;; take the first result, use that to get the entry from the map.
(get testsToConst (first (filter (fn [fun] fun col) (keys testsToConst))))
;; this doesn't work reliably as vectors would be a special case and
;; I don't yet know how to escape that when applying. Whatever.
@dmt
dmt / collection-type-multi.clj
Created July 21, 2011 09:47
multi-method collection type
(defmulti col-type class)
(defmethod col-type clojure.lang.PersistentList [_] :list)
(defmethod col-type clojure.lang.PersistentArrayMap [_] :map)
(defmethod col-type clojure.lang.PersistentVector [_] :vector)
(defmethod col-type clojure.lang.PersistentHashSet [_] :set)
(defmethod col-type :default [col] (if (seq? col) :seq :oops))
(col-type [])
-> :vector
(col-type {})
@dmt
dmt / gist:1096869
Created July 21, 2011 09:43
cond collection type with tests
(defn collection-type [col]
(cond (set? col) :set
(map? col) :map
(list? col) :list
(vector? col) :vector
(seq? col) :seq))
(deftest collection-type-returns-correct-name
(is (= :list (collection-type '())))
(is (= :map (collection-type {})))
@dmt
dmt / jasmine pom profile
Created November 26, 2010 14:18
jasmine pom profile
<profile>
<id>jasmine</id>
<build>
<plugins>
<plugin>
<groupId>searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.0.1-TC-SNAPSHOT</version>
<!-- The following includes com.jquery:jquery in the generated
runner html page. This does require deploying jquery yourself, though -->