Skip to content

Instantly share code, notes, and snippets.

Antonio Nuno Monteiro anmonteiro

Block or report user

Report or block anmonteiro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dependencies.rs
use syn::{self, Item, ItemMod, ItemUse, UseGroup, UsePath, UseTree};
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::Read;
use std::process;
fn main() {
let mut args = env::args();
View esy.json
{
"resolutions": {
"@opam/conf-openssl": {
"source": "no-source:",
"override": {
"dependencies": {
"@opam/conf-pkg-config": "*",
"@esy-packages/esy-openssl": "*"
}
}
View Dockerfile
FROM ocaml/opam2:alpine-3.7-ocaml-4.06
RUN sudo apk --no-cache add ca-certificates
RUN sudo apk add --update m4 openssh-client
# Setup SSH.
RUN mkdir -p ~/.ssh
ARG SSH_PRIVATE_KEY
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN printf "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
@anmonteiro
anmonteiro / sse.re
Last active Aug 5, 2018
Server-sent events in http/af
View sse.re
let set_interval = (s, f, destroy) => {
let rec set_interval_loop = (s, f, n) => {
let timeout =
Lwt_timeout.create(s, () =>
if (n > 0) {
f();
set_interval_loop(s, f, n - 1);
} else {
destroy();
}
View code_splitting_guide.md

Code Splitting

NOTE: This gist uses the master branch of ClojureScript. Clone ClojureScript and from the checkout run ./script/bootstrap and ./script/uberjar. This will produce target/cljs.jar which you can use to follow this guide.

As client applications become larger it becomes desirable to load only the code actually required to run a particular logical screen. Previously ClojureScript :modules compiler option permitted such code splitting, but this feature only worked under :advanced compilation and users would still have to manage loading these splits. :modules also required manual

View mov2gif.sh
mov2gif(){
ffmpeg -i "$1" -vf scale=800:-1 -pix_fmt rgb24 -r 10 -f image2pipe -vcodec ppm - |\
convert -delay 10 -layers Optimize -loop 0 - "$2"
}
View README.md

Demo of the new "require outside NS" feature in ClojureScript

Given the following directory structure, where cljs.jar is a ClojureScript uberjar built from source (the feature is currently unreleased, follow these instructions and build the compiler with script/uberjar):

project
├─ src
│  └─ foo.cljs
└─ cljs.jar
View merge-sends.cljs
(defn custom-merge-sends [a b]
(let [a (cond->> a
(not (every? (set (keys a)) (keys b)))
(merge (zipmap (keys b) (repeat []))))]
(merge-with #(into %1 (mapcat identity) %2) a b)))
@anmonteiro
anmonteiro / om-next-bootstrap.sh
Last active Sep 9, 2017
Use Om Next from Planck.
View om-next-bootstrap.sh
#!/bin/bash
set -e
if [ ! -d "om" ]; then
git clone -b self-host --depth=1 https://github.com/anmonteiro/om.git
fi
if [ ! -e "om/react-dom-server.jar" ]; then
curl -s -L https://clojars.org/repo/cljsjs/react-dom-server/15.3.0-0/react-dom-server-15.3.0-0.jar -o om/react-dom-server.jar
View keybase.md

Keybase proof

I hereby claim:

  • I am anmonteiro on github.
  • I am anmonteiro (https://keybase.io/anmonteiro) on keybase.
  • I have a public key whose fingerprint is 6E21 4AFF 1F0F 7E8E 1F14 6E8B 3EF0 52D0 A849 4FE9

To claim this, I am signing this object:

You can’t perform that action at this time.