Skip to content

Instantly share code, notes, and snippets.

View kyriakos's full-sized avatar
🏠
Working from home

kyriakos

🏠
Working from home
View GitHub Profile
@kyriakos
kyriakos / clonecivariables.mjs
Created June 5, 2022 07:16
Clone Gitlab CI variables from one Gitlab Repository to another
// The following script will blindly clone all Gitlab CI variables from source repository to the target. Created this to move CI from my own repository to a client's own.
// Update the project_id/api_key (and url's if needed below), install the dependency "npm i node-fetch" and then run using node clonecivariables.mjs
import fetch from 'node-fetch'; // run in the same dir as the script: npm i node-fetch
const source_project_id = ''; // can be found on repository's home page under the repository name.
const source_api_key = '' // get one here https://gitlab.com/-/profile/personal_access_tokens (create a personal token with API scope)
const source_url = 'https://gitlab.com/'; // only need to change this if using self-hosted gitlab
const target_project_id = '';
@kyriakos
kyriakos / posix2seconds.php
Created September 2, 2016 09:45
Convert ps etime to seconds in PHP - [[dd-]hh:]mm:ss
/* coverts process durations output from the ps linux command in the [[dd-]hh:]mm:ss format to seconds
* useful when you need to find long running processes in PHP
*/
function posixTimeToSeconds($str) {
$parts = explode(':', $str);
$c = count($parts);
if ($c == 2) {
return (int)$parts[0] * 60 + (int)$parts[1];
} else if ($c == 3) {