Skip to content

Instantly share code, notes, and snippets.

View ataias's full-sized avatar

Ataias Pereira Reis ataias

View GitHub Profile
@ataias
ataias / View+Extensions+Hidden.swift
Created February 13, 2021 11:38
SwiftUI Modifier: Conditionally hide a view
import SwiftUI
struct ConditionalHide: ViewModifier {
var hidden: Bool
@ViewBuilder
func body(content: Content) -> some View {
if hidden {
content.hidden()
} else {
@ataias
ataias / app_icons_from_svg
Last active April 25, 2021 11:12
Generate png app icons in multiple formats from an SVG image
#!/usr/bin/env bash
# For this to work, you need imagemagick installed,
# which is the tool that provides "convert"
sizes='16 20 29 32 40 60 64 58 76 80 87 120 128 152 167 180 256 512 1024'
file=$1
for size in $sizes
do
@ataias
ataias / .zshrc
Last active April 10, 2020 21:42
Basic Zsh Configuration (oh-my-zsh base + goodies)
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/vagrant/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@ataias
ataias / conversion-aliases.zsh
Created April 10, 2020 20:43
Aliases to help converting files
#!/usr/bin/env zsh
# You need to have pandoc and ffmpeg installed in your system
markdown2org () {
fullFilename=$1
filename="${fullFilename%.*}"
pandoc -f markdown -t org -o "$filename".org "$fullFilename"
}
@ataias
ataias / ramp.py
Created June 25, 2016 16:06
Create ramp input
import numpy
import matplotlib.pyplot as plt
n = 400
Ts = 0.1
t = numpy.linspace(0,n,n+1)*Ts
out_max = 0.3
y_ref = numpy.ones(n+1)*out_max
zero_time = 2.0
start = int(zero_time/Ts)
@ataias
ataias / multiply.py
Created June 18, 2016 16:37
multiply
import numpy
import time
A = numpy.random.rand(6,6)
B = numpy.random.rand(6,6)
start = time.clock()
D = numpy.random.rand(6,6)
for i in range(0,10):
C = A*B
D = D + C
@ataias
ataias / 1036.cpp
Last active March 13, 2016 16:47
Bhaskara formula
#include <cstdio>
#include <cmath>
bool is_nan(double x) { return x != x; }
using namespace std;
int main() {
double A, B, C;
scanf("%lf", &A);
@ataias
ataias / centos-install-syntax-highlighting-in-less.sh
Created March 6, 2016 18:52 — forked from textarcana/centos-install-syntax-highlighting-in-less.sh
How to enable syntax-highlighting in less. Use `less -N` (or type -N while in less) to enable line numbers. Based on the procedure described in http://superuser.com/questions/71588
# Enable syntax-highlighting in less.
# Last tested on CentOS 6.3.
#
# First, add these two lines to ~/.bashrc
# export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
# export LESS=" -R "
sudo yum -y install boost boost-devel ctags
wget http://springdale.math.ias.edu/data/puias/unsupported/6/x86_64/source-highlight-3.1.6-3.puias6.x86_64.rpm
@ataias
ataias / config.json
Created February 22, 2016 12:11 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@ataias
ataias / NSTimer+Closure.swift
Created February 10, 2016 15:23 — forked from natecook1000/NSTimer+Closure.swift
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/