Skip to content

Instantly share code, notes, and snippets.

View victorloux's full-sized avatar

Victor victorloux

View GitHub Profile
@victorloux
victorloux / transition.scss
Created September 13, 2018 08:47
Transition on focus outline style
a[href],
area[href],
input:not([disabled]),
select:not([disabled]),
textarea:not([disabled]),
button:not([disabled]),
iframe,
[tabindex],
[contentEditable=true]
{
@victorloux
victorloux / aria-current.js
Created August 24, 2018 11:41
aria-current polyfill for Android
/**
* Polyfill to make aria-current work with Android
* This happens on page load, re-run if loading content dynamically.
* Ensure you have a class .sr-only in your CSS
*
* (wtfpl) github.com/victorloux
*/
// Test if the browser is an Android Chrome
if(/Android/.test(navigator.userAgent) && /Chrome\/[.0-9]*/.test(navigator.userAgent))
@victorloux
victorloux / cr.sh
Created April 29, 2017 12:43
cd into the most recently created directory
# this creates the command "cr" which will cd into the most recently created directory
# useful after using mkdir, git clone, unzip etc.
# no need to type "mkdir new-project && cd new-project"
# just "mkdir new-project" then "cr"!
# !! WORKS ON macOS only (Linux doesn't have creation times)
# but it can surely be adapted with some hack on the modified time
alias cr=cd (ls -tUd */ | head -n 1)
@victorloux
victorloux / post-merge.sh
Created February 17, 2017 11:58
Automatic Harp deployment on git push
#!/bin/sh
#
# Put in .git/hooks/post-merge on your remote (staging or production)
# and chmod +x on it.
# Combine with a GH webhook script that will `git pull`
# every time you push to a repo
# If you get errors with a webhook script, note you might
# have to change the owner of your repository (+ log file) to "www-data" or similar
@victorloux
victorloux / galileo-wifi.md
Created October 11, 2016 13:47
Connect a Galileo or Yún to wifi and to an Eduroam network

This is a short guide to set up an Intel Galileo (or alternatively a Yún, or other small embedded systems who can run Linux) to connect to a wi-fi network, and particularly an eduroam network. Note that if you're using a Raspberry Pi I've found that it's significantly easier to use NetworkManager to do that, but this might not work on Yocto Linux.

(These notes were written in 2014 so they may be outdated by easier processes.)

FIRST you need to have your Galileo set up with the full Linux image (on a microSD card) and a working access to the terminal (via USB or UART). (If you're on OSX or Linux you're probably better off using screen, worked better than CoolTerm which didn't support backspaces and vi). There's plenty of tutorials online to do this. All commands here have to be typed in the terminal of the Galileo.

References

I must thank Sergey Malinov's guide and [the wiki of Archlinux](https://wiki.archlinux.org/index.php/WPA_

@victorloux
victorloux / say-out-loud.pde
Created October 4, 2016 17:10
Use the Mac's text-to-speech (VoiceOver) from a Processing sketch
// Note: this is MacOS X only, keep that in mind if you want something portable
// but it's a very easy way to prototype a project using TTS
// Possible voices: "Agnes", "Albert", "Alex", "Bruce", "Fiona", "Fred", "Kathy",
// "Princess", "Ralph", "Vicki", "Victoria"
// Weird voices: "Bad News", "Bahh", "Bells", "Boing", "Bubbles", "Cellos", "Deranged",
// "Good News", "Hysterical", "Junior", "Pipe Organ", "Trinoids", "Whisper", "Zarvox"
//
// to see all installed voices, in a terminal type: `say -v ?`
/*
* Re-maps a number from one range to another, akin to map() in Processing and Arduino
*
* @param {Number} value The number to map
* @param {Number} inMin The lower bound of the value's current range
* @param {Number} inMax The upper bound of the value's current range
* @param {Number} outMin The lower bound of the value's target range
* @param {Number} outMax The upper bound of the value's target range
* @param {boolean} capped Set to true to cap to the min/max target range, even if the input was outwith the current range
*

Keybase proof

I hereby claim:

  • I am victorloux on github.
  • I am vloux (https://keybase.io/vloux) on keybase.
  • I have a public key whose fingerprint is 8C6F F63A 1546 296E BB61 D59A FC34 34E9 DCBD 68E1

To claim this, I am signing this object:

@victorloux
victorloux / AppServiceProviders.php
Last active October 12, 2020 10:52
@Dump directive for Blade in Laravel 5
// place the following in app/Providers/AppServiceProviders.php, in the boot() method
/**
* Blade directive to dump a variable/object inside a template.
* This is similar to dd(), except that it doesn't interrupt the
* execution of the app. It does NOT support multiple arguments
* however, you have to use one directive per variable.
*
* @example @dump($posts->comments)
*/
@victorloux
victorloux / templates.php
Last active August 29, 2015 14:05
Shorthand conditions for Laravel Blade
<?php
/**
* This is a sort of “inline”, more readable if-then-echo statement
* for Blade in Laravel, mainly used for dynamically adding classes
* or attributes to HTML elements.
*
* The syntax is
*
* (( [classname] if [condition] ))