Skip to content

Instantly share code, notes, and snippets.

View kyrcha's full-sized avatar

Kyriakos Chatzidimitriou kyrcha

View GitHub Profile
month_seq <- seq(as.Date("2000-01-01"), as.Date("2000-12-31"), "month")
months <- factor(months(month_seq), levels = months(month_seq))
months_abbr <- factor(months(month_seq, TRUE), levels = months(month_seq, TRUE))
wday_seq <- seq(as.Date("2000-01-02"), as.Date("2000-01-08"), "day")
wdays <- factor(weekdays(wday_seq), levels = weekdays(wday_seq))
wdays_abbr <- factor(weekdays(wday_seq, TRUE), levels = weekdays(wday_seq, TRUE))
second <- function(x) as.POSIXlt(x)$sec
minute <- function(x) as.POSIXlt(x)$min
@jkresner
jkresner / mock-passport-middleware.coffee
Created April 19, 2013 05:47
Mocking user / session with passportJS authentication. This gist helps you test code that requires a user that has been authenticated by passport JS
module.exports =
initialize: (sessionUserObject) ->
(req, res, next) ->
passport = @
passport._key = 'passport'
passport._userProperty = 'user'
passport.serializeUser = (user, done) -> done null, user
passport.deserializeUser = (user, done) -> done null, user
@balupton
balupton / README.md
Last active January 21, 2017 00:40
DocPad: Paging Solutions

DocPad: Paging Solutions

  • post.html.eco used for displaying prev and next page links on your current page (static site friendly)
  • posts.html.eco used for displaying a content listing, that is split up onto multiple pages (requires dynamic site)
  • paged plugin used for splitting a document into a different pages, very neat (static site friendly)
@bithoundio
bithoundio / .bithoundrc
Last active December 3, 2017 15:49
The default values for .bithoundrc that customizes bitHound project analysis. If you like the defaults and want to make additions, keep the contents of this file and add your values. Commit this file directly to your project's root and bitHound will pick it up on the next round of analysis.
{
"ignore": [
"**/deps/**",
"**/node_modules/**",
"**/thirdparty/**",
"**/third_party/**",
"**/vendor/**",
"**/**-min-**",
"**/**-min.**",
"**/**.min.**",
@balupton
balupton / README.md
Last active April 29, 2019 11:57
DocPad: Use DocPad, GitHub & Prose as a Wiki

Use DocPad, GitHub and Prose as a Wiki

This guide will walk you through how you can use a GitHub repository to house your wiki content, have DocPad render it, and automatically update on changes. It's also really nice as we get to benefit from the github project workflow for our wiki, that is issues, pull requests, etc.

We use this workflow heavily by linking the DocPad Website and the DocPad Documentation repositories allowing us to have users edit and submit pull requests for improvements to our documentation, and once merged, the website regenerates automatically.

1. Create a new repository for your Wiki Content

@flexzuu
flexzuu / transport-loggging.go
Created August 13, 2019 15:46
wrap a transport to log the body
import "github.com/motemen/go-loghttp"
httpClient.Transport = &loghttp.Transport{
Transport: httpClient.Transport,
LogRequest: func(req *http.Request) {
b, _ := httputil.DumpRequestOut(req, true)
log.Printf("out body: %s", string(b))
},
LogResponse: func(resp *http.Response) {
b, _ := httputil.DumpResponse(resp, true)
@kyrcha
kyrcha / sigmoid.R
Last active November 26, 2019 08:13
Fitting a sigmoind curve in R
# function needed for visualization purposes
sigmoid = function(params, x) {
params[1] / (1 + exp(-params[2] * (x - params[3])))
}
x = 1:53
y = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0.1,0.18,0.18,0.18,0.33,0.33,0.33,0.33,0.41,
0.41,0.41,0.41,0.41,0.41,0.5,0.5,0.5,0.5,0.68,0.58,0.58,0.68,0.83,0.83,0.83,
0.74,0.74,0.74,0.83,0.83,0.9,0.9,0.9,1,1,1,1,1,1,1)
@larsyencken
larsyencken / fetch_and_combine.py
Created November 15, 2012 03:09
Aggregating CloudFront logs
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# fetch_and_combine.py
#
"""
Scans CloudFront logs in an S3 bucket for any that are new. Combines log files
into a single local file per hour. If logs for multiple CloudFront
distributions are present, combines them all.
import React, { useState } from 'react';
import { withStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import axios from 'axios';
@fabrizioc1
fabrizioc1 / http-proxy.go
Last active October 27, 2020 12:32
Http proxy server in Go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
type HttpConnection struct {