Skip to content

Instantly share code, notes, and snippets.

View dnadales's full-sized avatar

Damian Nadales dnadales

View GitHub Profile
@tomfa
tomfa / JSON-intArray-converter.js
Created May 10, 2015 11:22
JSON to 8-bit-integer parsing (and visa versa)
// JSON to Uint8Array parsing and visa versa
// (Intended Bluetooth communication on Cordova)
var JsonToArray = function(json)
{
var str = JSON.stringify(json, null, 0);
var ret = new Uint8Array(str.length);
for (var i = 0; i < str.length; i++) {
ret[i] = str.charCodeAt(i);
}
@killercup
killercup / pandoc.css
Created July 3, 2013 11:31
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@mitchwongho
mitchwongho / Docker
Last active November 29, 2023 06:36
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@Gabriella439
Gabriella439 / trans.md
Last active November 28, 2023 06:30
I'm trans

I'm writing this post to publicly come out as trans (specifically: I wish to transition to become a woman).

This post won't be as polished or edited as my usual posts, because that's kind of the point: I'm tired of having to edit myself to make myself acceptable to others.

I'm a bit scared to let people know that I'm trans, especially because I'm not yet in a position where I can transition (for reasons I don't want to share, at least not in public) and it's really shameful. However, I'm getting really

Take-home functional programming interview

This document is licensed CC0.

These are some questions to give a sense of what you know about FP. This is more of a gauge of what you know, it's not necessarily expected that a single person will breeze through all questions. For each question, give your answer if you know it, say how long it took you, and say whether it was 'trivial', 'easy', 'medium', 'hard', or 'I don't know'. Give your answers in Haskell for the questions that involve code.

Please be honest, as the interviewer may do some spot checking with similar questions. It's not going to look good if you report a question as being 'trivial' but a similar question completely stumps you.

Here's a bit more guidance on how to use these labels:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
@freckletonj
freckletonj / oauth.hs
Created April 27, 2017 21:06
Haskell Servant OAuth2.0 for GitHub
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
module Sand where
import Data.Aeson
@pmorie
pmorie / gist:8027518
Created December 18, 2013 18:41
bash -eu, explained
# Source: http://fvue.nl/wiki/Bash:_Error_handling
#
#!/bin/bash -eu
# -e: Exit immediately if a command exits with a non-zero status.
# -u: Treat unset variables as an error when substituting.
(false) # Caveat 1: If an error occurs in a subshell, it isn't detected
(false) || false # Solution: If you want to exit, you have to detect the error yourself
(false; true) || false # Caveat 2: The return status of the ';' separated list is `true'
(false && true) || false # Solution: If you want to control the last command executed, use `&&'
@tonydieu
tonydieu / Browsersync.js
Created March 20, 2015 08:53
How-to: Enable CORS in Browsersync
// https://hondo.wtf/2015/02/15/enable-cors-in-browsersync
gulp.task('browser-sync', function () {
browserSync({
notify: false,
port: 6543,
server: {
baseDir: config.dest,
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
@edsko
edsko / Sketch_QSM_LTL.hs
Created February 15, 2019 14:58
Using LTL formulae to check system states in quickcheck-state-machine
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StandaloneDeriving #-}
module Main where
import Data.IORef
import Data.TreeDiff