Skip to content

Instantly share code, notes, and snippets.

View nicolashery's full-sized avatar

Nicolas Hery nicolashery

View GitHub Profile
@nicolashery
nicolashery / environment-variables-jekyll-templates.md
Last active January 22, 2023 15:56
Make environment variables available in Jekyll Liquid templates

Environment variables in Jekyll templates

This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml file (which is likely to be committed in your GitHub repository).

Copy the environment_variables.rb plugin to your _plugins folder, and add any environment variable you wish to have available on the site.config object.

In a Liquid template, that information will be available through the site object. For example, _layouts/default.html could contain:

@nicolashery
nicolashery / AsyncMonadBaseControlExample.hs
Created September 9, 2022 14:01
Haskell ReaderT LoggingT - MonadBaseControl vs. MonadUnliftIO
module AsyncMonadBaseControlExample where
import Blammo.Logging (LoggingT)
import Control.Concurrent.Async.Lifted.Safe (concurrently)
import Control.Monad.Base (MonadBase)
import Control.Monad.Reader (MonadIO, MonadReader, MonadTrans (lift), ReaderT)
import Control.Monad.Trans.Control (MonadBaseControl (liftBaseWith, restoreM), StM)
import Data.Text.Lazy qualified as TL
import Web.Scotty.Trans (ActionT, text)
@nicolashery
nicolashery / rxjs-react.js
Last active August 1, 2022 03:36
Fetching data asynchronously with RxJS and React
import React from 'react';
import _ from 'lodash';
import Rx from 'rx';
import superagent from 'superagent';
let api = {
host: 'http//localhost:3001',
getData(query, cb) {
superagent
@nicolashery
nicolashery / solarized-dark.css
Last active March 25, 2022 08:38 — forked from scotu/solarized.css
Solarized theme stylesheets for Jekyll and Pygments
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@nicolashery
nicolashery / pandas-heroku.md
Created September 8, 2012 22:35
Deploy Python app using Pandas on Heroku

Deploy Python app using Pandas on Heroku

2012-09-08

This document explains how to deploy a Python app that uses the Pandas library on Heroku.

Heroku builds Numpy (one of Pandas' requirements) fine. However, when trying to deploy an app with both numpy and pandas in its requirements.txt file (or even just pandas), for some reason it fails

@nicolashery
nicolashery / README.md
Created October 18, 2012 20:52
Python setup on Windows

Python setup on Windows

Last updated: Oct 2012

This document is a step-by-step walkthrough on how to set up Python and various tools on a Windows 7 environment.

The primary goal is to have a Python setup that can be used for data analysis, but some more general tools are also installed.

Console2

@nicolashery
nicolashery / README.md
Last active August 23, 2019 23:28
D3.js chart with panning and paging

Click, hold, and drag chart background to pan left & right. When you see the "More" button, click to load next page of data.

Problem

I put this together while trying to find a simple solution to the following problem and contraint:

  • Visualize a potentially large set of timeseries data (stored behind an API)
  • Render fast, stay lean, and don't take up too much browser memory or computation

The paging means that we're always working with the same amount of data in memory (in this example, 1 day of data), and that we're allowed to explore as far back/forward in time as we like. I found this solution simple and easy to work with, but we could imagine something fancier like automatically fetching and rendering the next chunk of data when we reach the edge.

@nicolashery
nicolashery / Makefile
Created March 21, 2014 11:17
Building UMD modules with dependencies with Browserify
dist:
browserify \
--external lodash \
--external moment \
--require ./index.js:robot \
> bundle.js
cat umd-head.js bundle.js umd-tail.js > robot.js
#!/usr/bin/env stack
{- stack
--resolver lts-13.4
--install-ghc
script
--ghc-options "-Wall"
--package aeson
--package aeson-pretty
--package aeson-typescript
--package base
@nicolashery
nicolashery / mongoose-paginate.js
Last active January 24, 2018 13:02 — forked from craftgear/mongoose_paginate.coffee
Mongoose Paginate plugin
/* Mongoose Paginate plugin
Forked from:
https://gist.github.com/craftgear/1525918
This snippet is inspired by edwardhotchkiss's mongoose-paginate
(https://github.com/edwardhotchkiss/mongoose-paginate)
and works with any methods like where, desc, populate, etc.
The `paginate` method must be called at the end of method chains.