Skip to content

Instantly share code, notes, and snippets.

View useless-stuff's full-sized avatar
🤓
Learning

1317 useless-stuff

🤓
Learning
View GitHub Profile
@useless-stuff
useless-stuff / docker_command.sh
Created July 7, 2020 09:45
Run a sequence of bash commands in a docker container
NAME="Diego"
docker run -i -w /service -v $PWD:/service orchestra/builder:latest bash -s <<EOF
cd /service
echo "HELLO ${NAME}" >> file.log
EOF
@useless-stuff
useless-stuff / .bash_profile
Created July 23, 2019 09:02
Bash profile for docker containers
#!/usr/bin/env bash
default='\033[0;m'
green='\033[0;32m'
magenta='\033[0;35m'
cyan='\033[0;36m'
yellow='\033[33m'
containerDetails(){
echo -e " ${yellow}${IMAGE_NAME}:${BUILD_VERSION}${default}"
}
export PS1="${cyan}\h ${magenta}\u ${green}\w\$(containerDetails)${default} \n\\$ \[$(tput sgr0)\]"
@useless-stuff
useless-stuff / serverless_deploy_test
Last active January 4, 2019 11:24
SERVERLESS - Deploy application script
#!/usr/bin/env bash
# Cleanup
rm -rf ./build
rm -rf ./dist/src
# Create directory structure
mkdir -p ./build
mkdir -p ./dist
# Set correct node version
@useless-stuff
useless-stuff / .bash_profile.sh
Last active January 4, 2019 11:25
BASH - Bash user profile
########################################################################
# BASH TOOLS
# _
# ./ | _________________
# / / / __________ //\_
# /' / | (__________) ||.' `-.________________________
# / / | __________ ||`._.-'~~~~~~~~~~~~~~~~~~~~~~~~`
# / \ \__(__________)__\\/
# | `\
# | | ___________________
@useless-stuff
useless-stuff / php_observer_pattern_spl.php
Last active May 20, 2023 23:54
PHP - Observer pattern with SPL
<?php
abstract class Event
{
public $name, $code;
public function __toString()
{
return $this->name . ' ' . $this->code;
}
@useless-stuff
useless-stuff / data.csv
Created March 10, 2016 07:07
PHP - SplFileObject
John Busha developer
Mark Boiler graphic designer
Mario Rossi developer
@useless-stuff
useless-stuff / php_simple_xml_iterator.php
Last active February 20, 2016 11:33
PHP - SimpleXMLIterator
<?php
$xml = <<<EOF
<results>
<user>
<name>Diego</name>
<surname>Anniballo</surname>
</user>
<user>
<name>Mari</name>
<surname>Monti</surname>
@useless-stuff
useless-stuff / php_recursive_directory_iterator.php
Last active February 20, 2016 09:09
PHP - RecursiveDirectoryIterator
<?php
$filePath = '/vagrant/data/anniballo.com';
/**
* Class FolderFilter
*/
class DotFilter extends RecursiveFilterIterator
{
/**
@useless-stuff
useless-stuff / php_directory_iterator.php
Created February 20, 2016 08:09
PHP - DirectoryIterator
<?php
$filePath = '/vagrant/data/anniballo.com';
/**
* Class FolderFilter
*/
class FolderFilter extends FilterIterator
{
/**
@useless-stuff
useless-stuff / php_recursive_regex_iterator.php
Last active February 19, 2016 16:17
PHP - RecursiveRegexIterator
<?php
// RecursiveRegexIterator
$data = array(
array(
'EC2-CHOPIN01',
'EC2-CHOPIN02',
'EC2-CHOPIN03',
),
array(
'EC2-CHOPIN04',