Skip to content

Instantly share code, notes, and snippets.

View brunoamaral's full-sized avatar
😎

Bruno Amaral brunoamaral

😎
View GitHub Profile
@brunoamaral
brunoamaral / facebook.php
Created October 9, 2012 06:19
Facebook SDK example : saving user data to file
<?php
function facebooklog(){
require('/PATH_TO_FACEBOOK_PHP_SDK/src/facebook.php');
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
// Get User ID
$user = $facebook->getUser();

Keybase proof

I hereby claim:

  • I am brunoamaral on github.
  • I am brunoamaral (https://keybase.io/brunoamaral) on keybase.
  • I have a public key ASBZ1sWZZKDDtvfTrFyfb5P4wPeI8QduJScRUDSkGM_raAo

To claim this, I am signing this object:

@brunoamaral
brunoamaral / cleanup.sh
Last active June 1, 2021 23:32
A quick script to clean up your desktop and archive it's content by date
#!/bin/zsh
# Version 2.0
# Works pretty much the same as the initial version. If you have a folder in Documents/Archive/ with a project name,
# it can be used to organize your files.
# EXAMPLE
# Given the folder Desktop/Freelance client-X, and if you have a folder called Documents/Archive/Freelance, content will be moved to
# Documents/Archive/Freelance/client-X/2019-01-30/
# The first word of the folder in desktop must match the one in the Archive.
@brunoamaral
brunoamaral / webpack.config.js
Created April 27, 2018 13:40
current webpack.config.js
const webpack = require('webpack');
const path = require('path');
const config = {
entry: ['./src/index.js', './src/scss/main.scss'],
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'static')
},
watch: true,
@brunoamaral
brunoamaral / build-page-bundles-for-instagram.sh
Last active December 18, 2020 20:12
This script takes a folder with image files and converts them to page bundles to be used with gohugo.io
for file in *
do
date=`cut -d' ' -f 1 <<< "$file"`
dir=${file%".jpg"}
mkdir "$dir"
mv "$file" "$dir"
time=`cut -d' ' -f 2 <<< "$file" | sed -e 's/\./\:/g'`
datetime=$date'T'$time'+00:00'
printf '%s\n' '---' 'categories: ["instagram"]' "date: $datetime" 'description: ""' 'draft: false' 'resources:' " - src: '$file'" ' name: "header"' 'layout: instagram' 'slug:' 'stories:' 'subtitle:' 'title: Untitled' 'options:' ' unlisted: false' ' showHeader: true' '---' '' "<img src=\"$file\" />" | tee $dir/index.md $dir/index.pt.md
done
@brunoamaral
brunoamaral / basicAuth.sh
Last active December 18, 2020 20:11
a simple script to password protect a directory on nginx
#!/bin/bash
INCLUDE="/etc/nginx/incl/basicauth.conf"
SOURCEDIR="/home/Digital-Insanity/content/"
read -p "Website nginx directory without trailling slash [/var/web/brunoamaral.eu]:" publicDir
publicDir=${publicDir:-/var/web/brunoamaral.eu}
read -p "Which directory should we protect? (no trailling slash)" relUrl
htpasswd -c "$publicDir$relUrl/.htpasswd" nginx;
cp "$publicDir$relUrl/.htpasswd" "$SOURCEDIR$relUrl"
@brunoamaral
brunoamaral / example-nginx.conf
Created February 18, 2019 13:11
example nginx.conf for hugo websites
server {
server_name .DOMAIN-NAME;
listen 80;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
gzip on;
@DeLorean:~/Digital-Insanity$ hugo --cleanDestinationDir
Building sites … fatal error: runtime: out of memory
runtime stack:
runtime.throw(0x12202bd, 0x16)
/usr/local/go/src/runtime/panic.go:617 +0x72
runtime.sysMap(0xc04c000000, 0x4000000, 0x1eb5cd8)
/usr/local/go/src/runtime/mem_linux.go:170 +0xc7
runtime.(*mheap).sysAlloc(0x1e8ef80, 0x484000, 0x1e8ef90, 0x242)
/usr/local/go/src/runtime/malloc.go:633 +0x1cd
@brunoamaral
brunoamaral / _gallery.scss
Created May 8, 2019 20:53
scss for gallery
@brunoamaral
brunoamaral / copyright.html
Created May 31, 2020 09:24
Automatic Unsplash Copyright Shortcode for Hugo