Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dyba's full-sized avatar

M. Daniel Dyba dyba

View GitHub Profile
@dyba
dyba / HelloWorld.sol
Created July 31, 2018 16:29
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.24;
contract HelloWorld {
}
@dyba
dyba / cis-194-spring-2017-err1.txt
Created June 26, 2018 16:02
cis-194-spring-2017 Error when running tests
stack build && stack runghc test/Homework/Week01Spec.hs -v
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
2018-06-26 08:59:58.695588: [debug] Checking for project config at: /Users/ddyba/Code/haskell-cis-194-spring-2017/stack.yaml
@(src/Stack/Config.hs:850:9)
2018-06-26 08:59:58.696816: [debug] Loading project config file stack.yaml
@(src/Stack/Config.hs:876:13)
2018-06-26 08:59:58.699047: [debug] Decoding build plan from: /Users/ddyba/.stack/build-plan/lts-5.3.yaml
@(src/Stack/Snapshot.hs:164:5)
2018-06-26 08:59:58.699139: [debug] Trying to decode /Users/ddyba/.stack/build-plan-cache/lts-5.3.cache
@(src/Stack/Snapshot.hs:156:32)
@dyba
dyba / boot.clj
Created September 25, 2015 23:03
(set-env!
:source-paths #{"javasrc"}
:resource-paths #{"src/pnmacmodel" "src/movr2"}
:repositories [["releases" {:url "http://es-ubu-archiva-d-2.pnmac.com:8080/repository/internal"
:creds :gpg}]
["snapshots" {:url "http://es-ubu-archiva-d-2.pnmac.com:8080/repository/snapshots"
:creds :gpg}]
["clojars" {:url "https://clojars.org"}]]
:dependencies '[[org.clojure/clojure "1.7.0"]
[com.taoensso/nippy "2.5.2"]
;; WIP...
(defn quote-units
[units]
(let [syms (filter symbol? units)
vals (filter number? units)]
(interleave (map (fn [u] `'~u) syms) vals)))
(defmacro defunits
[quantity base-unit & units]
@dyba
dyba / lol.clj
Last active August 29, 2015 14:17
LOL
;; We can go further and use automatic gensyms provided
;; by Clojure when use a hashtag after the symbol we
;; want gensymed
(defmacro nif
[expr pos zero neg]
`(let [e# ~expr]
(cond
(pos? e#) ~pos
(zero? e#) ~zero
@dyba
dyba / core.clj
Last active August 29, 2015 14:14
Excel's DAYS360 in Clojure
(ns days360.core
(:require [clj-time.core :as t]
[clj-time.format :as f]
[clj-time.predicates :as p]
[clj-time.periodic :as per]))
;; It works! Now to prettify it...
(defn days360
"Calculates the number of days between a start-date and end-date according to
a 360-day year."
@dyba
dyba / xcode_shortcuts.txt
Last active December 22, 2015 00:39
A list of Xcode shortcuts
# Movement
OPT + CMD + ] => Move a line up
OPT + CMD + [ => Move a line down
CMD + SHIFT + ] => Move one tab to the right
CMD + SHIFT + [ => Move one tab to the left
CMD + -> / CTRL + E => Move to the end of the line
CMD + <- / CTRL + A => Move to the start of the line
OPT + -> => Move forward one word
OPT + <- => Move backward one word
CTRL + -> => Move forward one word (can move by words inside of camelcased words)
@dyba
dyba / 03FA7FC4-9EC4-4213-BE67-E3CF372599E6.codesnippet
Created August 29, 2013 23:12
Kiwi Spec Starter Code Snippet plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>kspec</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
@dyba
dyba / 1.7-improving-sqrt.scm
Last active December 9, 2015 23:59
SICP 1.7 Solution
(define (good-enough? guess next-guess)
(< (/ (abs (- guess next-guess)) guess) 0.001))
(define (average x y)
(/ (+ x y) 2))
(define (improve guess x)
(average guess (/ x guess)))
(define (sqrt-iter guess x)
@dyba
dyba / gist:4197857
Created December 3, 2012 20:42 — forked from halgari/gist:4195378
Atom refactoring
(defn update-my-atom [a name]
(let [new-state (assoc-in @a [:foo :bar] (merge {:name name}))]
(swap! a (fn [old] new-state))))
;; refactored into:
(defn get-new-state [state name]
(assoc-in state [:foo :bar] (merge {:name name})))