Skip to content

Instantly share code, notes, and snippets.

View ptoche's full-sized avatar
💭
fooling around

Patrick Toche ptoche

💭
fooling around
  • strange indentations
  • I live in Hong Kong in the U.S. time zone, but my heart is still in Europe.
View GitHub Profile
@ptoche
ptoche / BibSecretaryProblem.bib
Last active April 16, 2022 21:27
A bibliography on the Secretary Problem in bibtex / bibtopic format (by nature incomplete)
% Bibliography on the Secretary Problem and Related Games (Dynkin's game, Poisson search games, etc.)
@Article{Abdelaziz:Krichen:2005,
author = {Ben Abdelaziz, F. and Krichen, S.},
title = {An Interactive Method for the Optimal Selection Problem with Two Decision Makers},
journal = {European Journal of Operational Research},
volume = {162},
number = {3},
year = {2005},
//
// FlycutOperator.m
// Flycut
//
// Flycut by Gennadiy Potapov and contributors. Based on Jumpcut by Steve Cook.
// Copyright 2011 General Arcade. All rights reserved.
//
// This code is open-source software subject to the MIT License; see the homepage
// at <https://github.com/TermiT/Flycut> for details.
//
@ptoche
ptoche / spyder-hacks
Last active May 28, 2020 11:28
Spyder hacks: backup and edit config files for each environment (Upcoming release Spyder 5 will hopefully offer something better than this soon)
"""
Spyder hacks: backup and edit config files for each environment.
Upcoming release Spyder 5 will hopefully offer something better than this soon.
Created 28 May 2020
@author: Patrick Toche
"""
# import common packages here, otherwise import inside each function (helps me understand which packages are needed where and how much they are needed)
import os
# benchmark computing time differences
n = 1e6
set.seed(1)
Date = sort(replicate(n, paste0(Sys.Date(), " ",
sample(0:23, 1), ":", sample(0:59, 1), ":", sample(0:59, 1))))
Date <- as.POSIXct(Date, format="%Y-%m-%d %H:%M:%S", tz = "Europe/Paris")
diff_seq_along <- function(x) {
x[seq_along(x)+1]-x[seq_along(x)]
@ptoche
ptoche / server.R
Created January 16, 2014 19:10
Demo on why observe() and isolate() can be preferable to reactive()
# server.R
shinyServer(
function(input, output, session){
# This approach triggers a delay when the box is filled before the actionButton is actioned
# busyReactive <- reactive({
# delay <- as.integer(input$delay)
# if(input$trigger > 0) {Sys.sleep(delay)}
# return(input$trigger)
%\documentclass[border=12pt]{standalone}
\documentclass{article}
\usepackage[active,tightpage]{preview}
\usepackage{tikz}
\usetikzlibrary{calc}
\PreviewEnvironment{tikzpicture}
\usepackage{pgfplots}
\usepackage{fourier}
@ptoche
ptoche / convert.rb
Last active June 7, 2016 07:09 — forked from jdudek/convert.rb
Convert Opera's .adr address book to CSV
#!/usr/bin/env ruby
require "csv"
File.open("contacts.adr", "r") do |f|
contacts = []
f.read.split("#CONTACT").each do |entry|
unless entry.empty?
contact = {}
entry.each_line do |line|
@ptoche
ptoche / server.R
Created January 13, 2014 18:14
Demo on debug panel, may be useful for large projects, something like this should be made into a convenience function and a basic part of shiny
# server.R
library("shiny")
shinyServer(
function(input, output, session) {
# Debug Area
output$Console <- renderUI({
@ptoche
ptoche / server.R
Created January 28, 2014 22:03
Demo in Progress (very buggy) on sliderInput with numericInput for min/max
# server.R
library("shiny")
shinyServer(
function(input, output, session) {
# Reactive slider
v <- reactiveValues(min = -5, max = +5, status = 0)
@ptoche
ptoche / server.R
Created January 28, 2014 18:08
Demo on dynamic number of sliders
# server.R
shinyServer(function(input, output, session) {
output$sliders <- renderUI({
if (is.null(input$n) || is.na(input$n)) {
n <- 1
} else {
n <- round(input$n,0)
}
lapply(1:n, function(i) {