Skip to content

Instantly share code, notes, and snippets.

View cyppan's full-sized avatar

Cyprien Pannier cyppan

View GitHub Profile
@cyppan
cyppan / gist:3878866
Created October 12, 2012 11:52
Apache virtual host
<VirtualHost *:80>
ServerName jobeet2.lcl
DocumentRoot /var/www/jobeet2/web
<Directory /var/www/jobeet2/web>
Options -Indexes -MultiViews +FollowSymLinks
AllowOverride None
Order allow, deny
Allow from all
@cyppan
cyppan / ADTEnum.scala
Created February 3, 2015 12:52
Scala Enumeration alternative
import play.api.libs.json.{JsValue => PJsValue, JsString => PJsString, _}
import spray.json
import spray.json.{DeserializationException, JsString, JsValue, JsonFormat}
/**
* Enum alternative with Json marshallers for free (Play and Spray)
*
* credit: https://gist.github.com/atamborrino/1d992ebb942cd5518ca2
*
* Use:
@cyppan
cyppan / logger.py
Created May 27, 2015 17:38
python logging
import logging
import sys
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
@cyppan
cyppan / iab.clj
Created August 4, 2015 06:16
If you use AlchemyAPI and want to map its categories to IAB ones you may find this get-iabs function useful
(ns alchemyapi.iab)
(def iab-categories
{"IAB1" "Arts_Entertainment"
"IAB1-1" "Arts_Entertainment/Books & Literature"
"IAB1-2" "Arts_Entertainment/Celebrity Fan/Gossip"
"IAB1-3" "Arts_Entertainment/Fine Art"
"IAB1-4" "Arts_Entertainment/Humor"
"IAB1-5" "Arts_Entertainment/Movies"
"IAB1-6" "Arts_Entertainment/Music"
@cyppan
cyppan / cookie.clj
Created August 14, 2015 08:25
Clojure parse cookie string
@cyppan
cyppan / index.js
Created December 7, 2018 14:19
serve-sequelize
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const {
connect, syncDb, buildAndRegisterModel, setupAssociations, mapException, mapQueryParams
} = require('serve-sequelize');
const app = express();
const sequelize = connect({
@cyppan
cyppan / playground.clj
Created May 3, 2020 18:59
core.logic crops planification POC
(ns playground
(:refer-clojure :exclude [==])
(:use clojure.core.logic)
(:require [java-time :as jt]
[clojure.core.logic.fd :as fd]))
;; INITIAL DATA
(def nb-parcells 4)
(def days-to-plan 10)
(def crop-growth-days 3)
@cyppan
cyppan / unserializePhp.js
Last active November 19, 2020 12:39
Javascript (very incomplete) port of the "unserialize" PHP function
function unserialize(serialized) {
serialized = serialized.split("")
const res = []
const parseNumber = () => {
next = serialized.shift()
let digits = ""
while (!isNaN(parseInt(next))) {
digits += next
next = serialized.shift()
(ns dev.pathom-playground
(:require [com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.connect.operation :as pco]
[com.wsscode.pathom3.interface.eql :as p.eql]))
;; that one works fine
(pco/defresolver timezone-resolver [item]
{::pco/input [:timezone/id]
::pco/output [:timezone/label]}
{:timezone/label (str "label for id " (:timezone/id item))})
@cyppan
cyppan / day12.clj
Created December 12, 2021 21:29
Advent of Code 2021 - day 12: Passage Pathing
(ns aoc.day12
(:require [clojure.java.io :as io]
[clojure.string :as str]))
(defn parse-input [file-name]
(reduce (fn [graph [a b]]
(-> graph
(update a conj b)
(update b conj a)))
{}