Skip to content

Instantly share code, notes, and snippets.

View theronic's full-sized avatar

Petrus Theron theronic

View GitHub Profile
@kierendavies
kierendavies / b.py
Created April 15, 2013 21:24
Google Code Jam 2013 Qualification Round Problem B
#!/usr/bin/python3
from itertools import product
T = int(input())
for t in range(T):
N, M = list(map(int, input().split()))
grid = [list(map(int, input().split())) for n in range(N)]
rowmax = list(map(max, grid))
@shaharz
shaharz / friend_oauth.clj
Created January 27, 2014 16:47
Twitter/OAuth workflow for Friend
(ns friend-oauth
(:require
[cemerick.friend :as friend]
[cemerick.friend.workflows :refer [make-auth]]
[clj-http.client :as client]
[oauth.client :as oauth]
[ring.util.request :as request]))
(defn- which-oauth-uri
[config request]
@raymcdermott
raymcdermott / core.async filtering by time
Last active June 6, 2018 14:12
core.async filtering by time
(ns green-eggs.core
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go chan buffer close! thread
alts! alts!! timeout onto-chan]]
[clj-time.core :as t]
[clj-time.coerce :refer [from-date]]))
;If you were to implement yourself, you could make a `go` that simply pulls from a channel, and adds to another as a
;`[timestamp item]` pair, then finally pushes into an unbounded `chan` that has a transducer that filters based on
enum Theme: String {
case light, dark
}
class UserSettings {
enum Message {
case didUpdateTheme(Theme)
}
@maxweber
maxweber / query_check.clj
Created May 13, 2016 16:41
Checks if a Datomic datalog query contains only allowed symbols / functions.
(require '[datomic.api :as d]
'[clojure.string :as str])
(defn normalize-query
"Turns a vector formatted Datomic datalog query into a map formatted
one."
[query]
(let [pairs (partition-by keyword? query)]
(assert (even? (count pairs)))
(into

LOL What?

Allows you to write methods that contain mixed HTML and C# in Razor Views (.cshtml) / Razor Components (.razor) files.

This is a primitive for composing Razor code that is very low overhead / low concept. Your code calls your code.

In Views (not components): Can be async, can use tag helpers. In Components (not views): Usage and semantics still need figuring out, but we want to build something like this.

Sample

@objc protocol AURenderCallbackDelegate {
func performRender(_ ioActionFlags: UnsafeMutablePointer<AudioUnitRenderActionFlags>,
inTimeStamp: UnsafePointer<AudioTimeStamp>,
inBusNumber: UInt32,
inNumberFrames: UInt32,
ioData: UnsafeMutablePointer<AudioBufferList>?) -> OSStatus
}
func renderCallback(_ inRefCon:UnsafeMutableRawPointer,
ioActionFlags:UnsafeMutablePointer<AudioUnitRenderActionFlags>,
@yokolet
yokolet / memo.md
Last active December 28, 2019 15:02
Datomic Pro with PostgreSQL setup
@lilactown
lilactown / cljs-serverless.md
Last active January 27, 2020 05:06
CLJS in AWS Lambda Quick Start
@mookerji
mookerji / rocksdb.clj
Last active March 5, 2020 10:12
Idiomatic Clojure bindings for the C++ RocksDB library, an embedded persistent key-value store for flash storage and server workloads based on LevelDB. This implementation is based partially on Factual's clj-leveldb and is up here for some early review. If I've shared it with you, please don't repost until merged into a public Github.
(ns org.flausenhaus.rocksdb
"Idiomatic Clojure bindings for the C++ RocksDB library, an embedded
persistent key-value store for flash storage and server workloads based on
LevelDB. More details about RocksDB are given at
https://github.com/facebook/rocksdb/wiki/Rocksdb-Architecture-Guide.
The implementation here borrows heavily from Factual's clj-leveldb.
This namespace provides a few things:
0. Protocols/type definitions: byte serialization (IByteSerializable),
closeable sequences (CloseableSeq), and mutable