Skip to content

Instantly share code, notes, and snippets.

View abelcallejo's full-sized avatar

Abel Callejo abelcallejo

View GitHub Profile
@abelcallejo
abelcallejo / README.md
Last active January 18, 2023 05:56
Creating a .pem file from scratch

Creating a .pem file from scratch

ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bill/.ssh/id_rsa):
@abelcallejo
abelcallejo / README.md
Last active January 31, 2020 06:17
Creating .pem key using id_rsa
@abelcallejo
abelcallejo / README.md
Last active September 8, 2021 05:18
Adding new user accounts with SSH access

Adding new user accounts with SSH access

  1. REMOTE MACHINE: Create a user and set the password
    sudo adduser joel
    sudo passwd joel
  2. REMOTE MACHINE: Switch login to the newly created user
    su - joel
@abelcallejo
abelcallejo / virtual_hosts.conf
Created December 11, 2019 08:36
Apache Virtual Host template
<VirtualHost *:80>
DocumentRoot "/var/www/html/site"
ServerName site.example.com
<Directory "/var/www/html/site">
AllowOverride All
</Directory>
</VirtualHost>
@abelcallejo
abelcallejo / README.md
Created December 1, 2019 20:48
The missing is_posts_page() function of WordPress

is_posts_page()

Returns boolean whether the current page is the posts page as set from the dashboard.

@abelcallejo
abelcallejo / README.md
Last active April 27, 2022 12:37
R crash course and cheatsheets

r

Crash course and cheatsheets

Data types

In most programming languages, there are the so called "Data types". However in R, they are often referred to as Objects.

Primitive data types

In most programming languages, there are the so called "Primitive data types". However in R, they are often referred to as Atomic objects or sometimes called as "Basic types".

  • logical
@abelcallejo
abelcallejo / README.md
Last active April 25, 2022 02:16
PostgreSQL query to CSV using Bash

PostgreSQL query to CSV using Bash

postgresql Shell

CSV generation

psql -h localhost -U user_name -w -d database_name -A -F"," -c 'SELECT * FROM table_name' > "/path/to/results.csv"

Getting rid of extra characters at the bottom of the CSV

@abelcallejo
abelcallejo / README.md
Last active August 22, 2019 06:01
Bootstrap break points

Bootstrap break points

bootstrap

Version 3

/** Extra small (xs) **/
@media (max-width: 767px){
}

/** Small (sm) **/
@abelcallejo
abelcallejo / README.md
Last active August 12, 2019 15:12
Implementing Google reCAPTCHA with PHP

Implementing Google reCAPTCHA with PHP

Implementation using v2

Step 1

Register a project by logging to google.com/recaptcha

Step 2

Load the javascript library

@abelcallejo
abelcallejo / README.md
Last active August 12, 2019 14:45
String Replace Cheatsheet

String Replace Cheatsheet

PHP

$replaced = str_replace( $search, $replace, $subject );

JavaScript

replaced = subject.replace( search, replace );