Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
lucaspiller / auto-save-remote-images.php
Created February 19, 2014 15:19
Auto Save Remote Images WP Plugin
<?php
/*
Plugin Name: Auto Save Remote Image
Plugin URI: http://www.devsaab.com/wordpress/
Description: This plugin automatically downloads the first remote image from a post and sets it as the featured image.
Version: 1.3
Author: Prebhdev Singh
Disclaimer: No warranty or guarantee of any kind! Use this in your own risk.
*/
add_action('publish_post', 'fetch_images');
@lucaspiller
lucaspiller / never_gonna.ws
Created June 1, 2012 14:04
Never Gonna Give You Up (Whitespace)
@lucaspiller
lucaspiller / .gitlab-ci.yml
Last active April 14, 2022 09:07
Rails 5.2 + Docker + Gitlab Continuous Deployment
image: ruby:2.6
services:
- postgres:11-alpine
variables:
POSTGRES_DB: myorg_test
CONTAINER_IMAGE: registry.gitlab.com/myorg/myapp
stages:
@lucaspiller
lucaspiller / generate.sh
Created September 15, 2021 16:07
OpenSSL Client Certificates
# Extra: Generate self-signed server certificate
openssl req -nodes -new -x509 -keyout server.key -out server.crt -days 3650
# Generate CA for client certificates
openssl req -nodes -new -x509 -keyout client-ca.key -out client-ca.crt -days 3650 -subj "/CN=Client CA/O=My Company Name LTD./C=US"
# Set client name which will be used as CN
export CLIENT=bob
# Generate CSR for client certificate
@lucaspiller
lucaspiller / _fields.html.slim
Last active June 26, 2021 23:03
Reform 2.2 nested form (with support for cocoon gem)
= f.simple_fields_for :inputs do |input|
= render 'input_fields', f: input
.links
= link_to_add_association f, :inputs, partial: 'input_fields', force_non_association_create: true do
Add
@lucaspiller
lucaspiller / gist:3377737
Created August 17, 2012 10:16
Tmux Primer

I use this function to setup / resume my tmux sessions. If a session exists with the given name it resumes it, otherwise it creates it:

tm() {
  [[ -z "$1" ]] && { echo "usage: tm <session>" >&2; return 1; }
  tmux has -t $1 && tmux attach -d -t $1 || tmux new -s $1
}

(N.b. If you use something similar already check you have the -d flag. This will kill old clients (e.g. ssh connections that died, quitting your terminal before disconnecting) and ensure the window resizes correctly.)

Disk encryption benchmarks:
$ cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 352344 iterations per second
PBKDF2-sha256 196215 iterations per second
PBKDF2-sha512 156784 iterations per second
PBKDF2-ripemd160 237449 iterations per second
PBKDF2-whirlpool 73470 iterations per second
# Algorithm | Key | Encryption | Decryption
@lucaspiller
lucaspiller / gist:7371780
Created November 8, 2013 14:29
GitHub.app git and Homebrew git conflict
$ brew install git
zsh: correct 'git' to '.git' [nyae]? n
Warning: A newer Command Line Tools release is available
Update them from Software Update in the App Store.
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-1.8.4.2.mavericks.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/git-1.8.4.2.mavericks.bottle.tar.gz
==> Pouring git-1.8.4.2.mavericks.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain
@lucaspiller
lucaspiller / Building Blink on OS X.md
Last active August 24, 2017 06:25
Building Blink on OS X
diff --git a/Gemfile b/Gemfile
index bfc2a1de..8de952c3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,9 +2,9 @@ source 'https://rubygems.org'
ruby '2.4.1'
-gem 'rails', '5.0.2'
+gem 'rails', '5.1.0'