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
def find_duplicates(nums): | |
sorted_nums = sorted(nums) | |
last = None | |
dups = [] | |
for n in sorted_nums: | |
if last and n == last: | |
try: | |
last_dup = dups[-1] | |
except IndexError: |
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
fun parseInt(s: String): Int { | |
var num = 0 | |
var j = 1 | |
var i = s.length - 1 | |
while (i >= 0) { | |
val c = s[i].toInt() | |
if (c < 48 || c > 58) { | |
i -= 1 |
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
# Place in: /etc/supervisor/conf.d/artisan-queue.conf | |
[program:artisan-queue] | |
commmand=php /var/www/html/artisan queue:work | |
autostart=true | |
autorestart=true | |
# Can add this if you want a non-laravel log file | |
# stderr_logfile=/var/www/html/storage/logs/queue_err.log | |
# stdout_logfile=/var/www/html/storage/logs/queue_out.log |
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
sudo apt-get install wget ca-certificates | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
# Add repository | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' | |
# Install | |
sudo apt-get update | |
sudo apt-get install postgresql postgresql-contrib |
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
DELIMITER $$ | |
-- Capitalizes a word | |
-- @param str VARCHAR String to capitalize | |
-- @return VARCHAR Capitalized string | |
CREATE FUNCTION CAPITALIZE(str VARCHAR(255)) RETURNS VARCHAR(255) | |
BEGIN | |
RETURN CONCAT(UPPER(SUBSTRING(str, 1, 1)), SUBSTRING(str, 2)); | |
END$$ | |
DELIMITER ; |
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
Collection::macro('peekMap', function (callable $callback) { | |
$lastValue = null; | |
return $this->map(function ($value, $key) use ($callback, $lastValue) { | |
$newValue = $callback($value, $key, $lastValue); | |
$lastValue = $newValue; | |
return $newValue; | |
}); | |
}); |
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
SHOW ENGINE INNODB STATUS; |
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/env bash | |
# | |
# ... commands ... | |
# | |
exit $? |
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 | |
namespace App\Providers; | |
use Illuminate\Http\Request; | |
use Illuminate\Routing\Route; | |
use Illuminate\Support\ServiceProvider; | |
use App\Http\Middleware\CaptureRequestExtension; | |
class AppServiceProvider extends ServiceProvider |
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
export default (...fields) => [...fields].reduce((sum, { length }) => sum + length, 0) === 0; |
NewerOlder