Skip to content

Instantly share code, notes, and snippets.

View brospars's full-sized avatar

Benoit Rospars brospars

View GitHub Profile
@brospars
brospars / github-pages-setup
Created October 16, 2015 11:21
Github pages in subfolder "demo/"
// Create Github Page branch
git checkout -b gh-pages
git push origin gh-pages
// Update Github Page branch from master
git checkout gh-pages
git pull .master
git push origin gh-pages
git checkout master
@brospars
brospars / switch_monitor.md
Created March 21, 2018 08:09
Switch between monitor configurations

Make an alias in $HOME/.bash_aliases

# switch monitor mode
alias sm='function _switch_monitor(){ $HOME/switch_monitor.sh $1;};_switch_monitor'

Here is an example of xrandr settings for switching between the built-in screen and the dual screen config (built-in uses a new mode no present by default)

#!/bin/bash
@brospars
brospars / bye.md
Created March 21, 2018 08:12
Ubuntu : lock session and go to sleep

This alias lock the session (lightdm) and enter sleep mode

# Lock session and go to sleep
alias bye='function _bye(){ dm-tool lock; sleep 10; sudo pm-suspend;};_bye'
@brospars
brospars / regex_vtt.md
Last active December 12, 2022 12:27
Regular expression to match vtt subtitles

Regex : /^(\d{2}:\d{2}:\d{2}[.,]\d{3})\s-->\s(\d{2}:\d{2}:\d{2}[.,]\d{3})\n(.*(?:\r?\n(?!\r?\n).*)*)/gm
Demo : https://regex101.com/r/TH1JhU/1
Code example :

const regex = /^(\d{2}:\d{2}:\d{2}[.,]\d{3})\s-->\s(\d{2}:\d{2}:\d{2}[.,]\d{3})\n(.*(?:\r?\n(?!\r?\n).*)*)/gm;
const str = `WEBVTT

00:00:00.000 --> 00:00:04.469
Blah Bla bla 1
Multine
@brospars
brospars / environment.yml
Last active August 30, 2018 06:57
Jupyter conda environment with R and Scipy
name: mooc_rr
channels:
- conda-forge
- defaults
dependencies:
- alembic=0.9.9
- attrs=18.1.0
- automat=0.7.0
- backcall=0.1.0
- beautifulsoup4=4.6.0
@brospars
brospars / readme.md
Last active September 4, 2018 13:54
Fix gnome authentication failure
@brospars
brospars / readme.md
Created September 18, 2018 08:30
Bookmarlet to generate table of content of a MOOC from edx studio
  1. Create a bookmarlet with the code below
  2. Go to the homepage of your MOOC in studio (in our case : studio.fun-mooc.fr/course/[MOOC_ID])
  3. Run the bookmarklet
javascript:(function(){
	var base_url = window.location.href.replace('studio.fun-mooc.fr/course','fun-mooc.fr/courses')+'/jump_to_id/';
	var sections = $('.outline-section');
	var sectionList = $('<ul/>');
@brospars
brospars / step-by-step.js
Last active April 17, 2019 12:49
A step by step script with delay between each action, demo : https://brospars.github.io/snippets/step-by-step
function nextStep(cb, ...args) {
setTimeout(() => {
cb(...args)
}, 1000)
}
function step1(foo){
// some logic and pass result to next step
var bar = foo * 2
nextStep(step2, foo, bar)
@brospars
brospars / readme.md
Created September 3, 2019 12:33
Guide to setup Ionic with Vue project for Android

Guide to setup Ionic with Vue project

  1. Install Vue CLI npm install -g @vue/cli
  2. Create your App vue create my-vue-app
  3. Choose the recommended default setup (with router, store, etc)
  4. Add Ionic/Vue as a dependency of your project npm install @ionic/vue
  5. Add Ionic as a Vue plugin in your main.js
// [...]
@brospars
brospars / uid.js
Created June 17, 2020 08:04
One liner uid javascript
Math.random().toString(36).slice(-10);