View find_duplicates.py
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: |
View main.kt
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 |
View artisan-queue.conf
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 |
View postgres.sh
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 |
View capitalize.sql
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 ; |
View collection-peekMap.php
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; | |
}); | |
}); |
View MySQL_InnoDB_Engine_Status.sql
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; |
View bash_exit_last_code.sh
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 $? |
View 1-add-macros.php
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 |
View allEmpty.js
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