Skip to content

Instantly share code, notes, and snippets.

@petersaints
petersaints / .babelrc
Created February 19, 2018 16:17
TypeScript + Babel configuration using Gulp and/or Webpack (deprecated in favor of a simpler configuration on YanuX Coordinator)
{
"presets": [
"es2015"
],
"plugins": [
"transform-runtime"
]
}
@petersaints
petersaints / DownloadEPostersEncontroCiencia2017.sh
Created July 13, 2017 14:51
Download E-Posters - Encontro Ciência 2017 by FCT (Lisbon, Portugal)
for number in {680..690}; do echo $number; done | xargs -P8 -i curl "http://www.eposters.pt/e-posters/2017CV/{}.pdf" -H 'Host: www.eposters.pt' -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Cookie: visid_incap_231245=F10rG9UARda75raCWFtmlbxVZ1kAAAAAQUIPAAAAAABZcFM26RmMaCFXDqt7Dqd2; incap_ses_471_231245=YUK9ZRI8RW0eN56ZdVSJBrxVZ1kAAAAAKqgk/npBThtOeI1V8WEMnw==' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -o poster-{}.pdf
@petersaints
petersaints / 10-fix-proc-acpi-wakeup.sh
Last active April 11, 2017 23:09 — forked from kepi/45fix-usb-wakup.sh
Disable resume when certain devices (e.g., USB) become active
#!/bin/bash
# (/usr)/lib/systemd/system-sleep/10-fix-proc-acpi-wakeup.sh
# Disable resume when certain devices (e.g., USB) become active.
# Based on: https://gist.github.com/kepi/9dea7aee8a59f3e7c10a
[[ "$1" = "pre" ]] || exit 0
function print_state {
cat /proc/acpi/wakeup | grep $1 | cut -f3 | cut -d' ' -f1 | tr -d '*'
@petersaints
petersaints / RotationSensorWrapper.java
Created April 28, 2016 15:09
[Android] Just a simple example on how to fuse the accelerometer and magnetometer to create new virtual/pesudo-sensor which you can use to replace the deprecated ORIENTATION sensor. I ended using a more direct conversion from the new ROTATION_VECTOR sensor which is simpler and cleaner. However, I'm creating this Gist for future reference if needed.
/*
* Copyright (c) 2016 Pedro Albuquerque Santos.
*
* This file is part of YanuX Scavenger.
* YanuX Scavenger is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* YanuX Scavenger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with YanuX Scavenger. If not, see <https://www.gnu.org/licenses/gpl.html>
*/
@petersaints
petersaints / content_scrolling.xml
Created April 26, 2016 14:36
Android Scrolling Activity Example (Content)
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="pt.unl.fct.di.novalincs.yanux.scavenger.ScrollingActivity"
tools:showIn="@layout/activity_scrolling">
@petersaints
petersaints / activity_scrolling.xml
Created April 26, 2016 14:36
Android Scrolling Activity Example
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="pt.unl.fct.di.novalincs.yanux.scavenger.ScrollingActivity">
<android.support.design.widget.AppBarLayout
@petersaints
petersaints / WifiResult.java
Created March 31, 2016 16:32
Convert a Wi-Fi's network center frequency to the corresponding channel number. Based on: http://stackoverflow.com/a/33276767/356977
public int getChannel() {
if (frequency == 2484) {
return 14;
} else if (frequency < 2484) {
return (frequency - 2407) / 5;
} else {
return frequency/5 - 1000;
}
}