- For loop, set the comparison condition as variable outside the loop
- conventions
- ClassName
- methodName
- propertyName
- CONSTANT_NAME
- Constants should be
static
andfinal
. Ideally private too.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// instantiate GameOfLife and run it. | |
$gol = new GameOfLife(); | |
$gol->run(); | |
/** | |
* Class IOHelper | |
* Some misc utility functions for dealing with I/O on CLI | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TABLENAME=$1 | |
DISABLE_CHARSETCHECK=$2 | |
DRY_RUN=1 | |
PROGRESS=100 | |
RETRIES=3 | |
RUN_TIME='5m' # could be 45m | |
TRANSACTION_SIZE=1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$image1 = new imagick("image1.png"); | |
$image2 = new imagick("image2.png"); | |
$result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR); | |
$result[0]->setImageFormat("png"); | |
header("Content-Type: image/png"); | |
echo $result[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# My very first python script :) | |
""" Pre-res: | |
require python-sqlite | |
""" | |
""" Possible Improvments | |
Support for long arguments switches | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
verbose_mode=0 # Set this to 1 or 0 to enable/disable outputting all log messages. Enabling this causes some known issues with rsync output. keep it disabled. | |
ip_check_url='http://myip.dnsomatic.com/' #URL that would show our current ip. This url should only show IP and nothing else, no other content, no html tags, etc... | |
home_network_ip='1.1.1.1' #External IP that we should be on for the backup to trigger | |
curl_url='http://reportingserver.com/backup-report.php' #url that should get alerts for cron jobs | |
signatures='1234567890' #random string to verify requests on curl_url script | |
rsync_exclusive=1 #whether or not we should exit if there is already an rsync process running, values could be 1 or 0 | |
rsync_additional_opts='--verbose' # any additional switches that we may want to add, an example could be --verbose | |
backup_alert_period=10 #alert me if no backup has run after this many days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GoogleMapsGeocoder extends CApplicationComponent | |
{ | |
/** | |
* @var string | |
*/ | |
const ENDPOINT_URL = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s'; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Framework of choice: yii2. | |
Configure application log to log all exceptions. | |
Configure FileCache(just to have something to later replace, say, by Redis) | |
2 apps using same configs, same code: frontend, api. | |
Api application would have a module called v1. | |
Url pattern: http://app.com/ , http://api.app.com/v1/tradeMessages/consume | |
Trends: | |
- Most active user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# At the start of my DevOps career I used to mess up /etc permissions | |
# a lot so I ended up creating 2 set of scripts that would be generated | |
# on nightly bases using cron and then when required I'd just execute | |
# these scripts | |
find /etc -exec stat --format "chmod %a %n" {} \; > /root/restoreperms.sh | |
find /etc -exec stat --format 'chown %U:%G %n' {} \; > /root/restoreowners.sh |