Skip to content

Instantly share code, notes, and snippets.

View abelcallejo's full-sized avatar

Abel Callejo abelcallejo

View GitHub Profile
@abelcallejo
abelcallejo / proper-case.php
Last active July 18, 2019 22:42
PHP proper case function
<?php
function propername( $name, $language="es-ph" )
{
$language = str_replace("-","_",$language);
$exceptions = array(
"es_ph" => array(
"de",
"del",
@abelcallejo
abelcallejo / README.md
Last active July 18, 2019 22:41
Executing commands on a remote server by using a local script

Executing commands on a remote server by using a local script

Shell

Sometimes you will need to execute commands on a remote server routinely but you don't want them to be scheduled. This material will guide you in doing it.

Prepared script

prepared_bash_script.sh - a sample bash/shell script that is in the local machine.

The jsonld_encode() function on PHP

php

Encodes an object or an array into JSON-LD format

Problem

JSON-LD uses the at '@' character as part of the JSON key naming convention.

Algorithm

@abelcallejo
abelcallejo / README.md
Last active June 19, 2025 15:56
Creating bootable Linux USB using Mac

Creating bootable Linux USB using Mac

mac

CentOS, Ubuntu, Slackware, etc. Whatever Linux-based OS it is, you can create a bootable USB for it by using a Mac.

1. Prepare the .iso file

Download it, copy it, whatever it takes to prepare that Linux-based OS .iso file

2. Convert the .iso file into a .img.dmg

@abelcallejo
abelcallejo / README.md
Last active October 26, 2020 04:44
Creating triggers on PostgreSQL

Creating triggers on PostgreSQL

postgresql

Step 1. Create the function

CREATE FUNCTION custom_function() RETURNS trigger AS $$
  /**
  Do your magic here
  **/
$$
@abelcallejo
abelcallejo / README.md
Last active July 18, 2019 22:40
Using the Screen tool

Using the Screen tool

Shell

Starting a screen

screen

Detaching a screen

  1. Press control + a then immidiately follow it with
@abelcallejo
abelcallejo / README.md
Last active August 16, 2023 08:25
PHP date manipulation techniques

PHP date manipulation techniques

php

ISO string date to PHP date object

<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
@abelcallejo
abelcallejo / README.md
Last active July 18, 2019 22:40
Executing a PostgreSQL script using a local file

Executing a PostgreSQL script using a local file

postgresql

Execute the prepared script

psql --quiet -h hostname -U user_name -w -d postgres -f "/path/to/prepared_script.sql"
@abelcallejo
abelcallejo / README.md
Last active July 18, 2019 22:39
Selecting all the column names of a particular table in PostgreSQL

Selecting all the column names of a particular table

postgresql

Query statement

SELECT
  column_name
FROM
  information_schema.columns
WHERE
@abelcallejo
abelcallejo / README.md
Last active July 15, 2019 06:02
Generating SSH keys

Generating SSH keys

Shell

Generating private and public keys

ssh-keygen -t rsa -b 4096 -q -f "/home/bill/.ssh/id_rsa" -N ""

Generating PEM file