Skip to content

Instantly share code, notes, and snippets.

View houshuang's full-sized avatar

Stian Håklev houshuang

View GitHub Profile
'use strict';
const theGlobal = typeof window === 'object' ? window : global;
const realPromiseConstructor = theGlobal.Promise;
const wrappedPromiseConstructor = function (resolve, reject, progress) {
const originalPromiseInstance = new realPromiseConstructor(resolve, reject, progress);
// Who called us? Let's store it.
@henrik
henrik / regex_case.exs
Last active September 21, 2022 03:06
Proof-of-concept of an Elixir construct like `case` but that matches strings against regexps. #elixirlang
defmodule RegexCase do
defmacro regex_case(string, do: lines) do
new_lines = Enum.map lines, fn ({:->, context, [[regex], result]}) ->
condition = quote do: String.match?(unquote(string), unquote(regex))
{:->, context, [[condition], result]}
end
# Base case if nothing matches; "cond" complains otherwise.
base_case = quote do: (true -> nil)
new_lines = new_lines ++ base_case
@clarkdave
clarkdave / pygments.css
Created March 8, 2013 16:51
pygments styles for clarkdave.net
code { background: #f8f8f8; }
code .hll { background-color: #ffffcc }
code .c { color: #8f5902; font-style: italic } /* Comment */
code .err { color: #a40000; border: 1px solid #ef2929 } /* Error */
code .g { color: #000000 } /* Generic */
code .k { color: #204a87; font-weight: bold } /* Keyword */
code .l { color: #000000 } /* Literal */
code .n { color: #000000 } /* Name */
code .o { color: #ce5c00; font-weight: bold } /* Operator */
code .x { color: #000000 } /* Other */
#Laste inn datasett
attach(arkingdata)
#Endre 0 til NA(manglende verdi)
erfaringbygg[erfaringbygg$x51==0, "x51"] <-- NA
erfaringbygg[erfaringbygg$x52==0, "x52"] <-- NA
erfaringbygg[erfaringbygg$x53==0, "x53"] <-- NA
erfaringbygg[erfaringbygg$x54==0, "x54"] <-- NA
erfaringdel[erfaringdel$x71==0, "x71"] <-- NA
@actsasgeek
actsasgeek / osx.clj
Created May 17, 2012 17:10
A thin Clojure wrapper for com.apple.eawt.Application(Listener)
(ns osx
(:use seesaw.core)
(:import
[com.apple.eawt Application ApplicationListener]
[java.awt.image BufferedImage]))
;; mostly for use with Seesaw
;; https://github.com/daveray/seesaw
(defn event-not-handled [e] (.setHandled e false))