Skip to content

Instantly share code, notes, and snippets.

@dam1r89
dam1r89 / deploy-laravel.sh
Last active September 2, 2016 07:34
Steps for deploying Laravel app
#!/bin/sh
cd /project/path
php artisan down
git pull
composer install
php artisan migrate
php artisan optimize
<?php
use Workerman\Lib\Timer;
use Workerman\Worker;
require __DIR__ . '/bootstrap/autoload.php';
Timer::add(0.1, function () {
echo "First timer\n";
function dq($query){
$sql = $query->toSql();
foreach($query->getBindings() as $key => $binding){
$sql = preg_replace('/\?/', "'$binding'", $sql, 1);
}
dd($sql);
}
#!/usr/local/bin/php -q
<?php
error_reporting(E_ALL);
session_start();
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
/* Turn on implicit output flushing so we see what we're getting
<script>
(function(o) {
var switchTo5x=true;
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');
r.onload = function(){
stLight.options({publisher: "<some_hash>", doNotHash: false, doNotCopy: false, hashAddressBar: false});
};
r.async=1;
r.src='http://w.sharethis.com/button/buttons.js';
# Redirecting
# From www to without www
RewriteCond %{HTTP_HOST} ^www\.domain.rs$
RewriteRule (.*) http://domain.rs/$1 [R=301,L]
@dam1r89
dam1r89 / flexbox-left-sidebar-layout.html
Created March 14, 2017 13:19
Flexbox boilerplate layout with fixed left sidebar for web application
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body, html{
padding: 0;
margin: 0;
height: 100%;
@dam1r89
dam1r89 / human-readable-alphanumeric-code.php
Created March 21, 2017 10:33
Human readable alphanumeric code, only lower case (for easier usage)
<?php
// Repeating characters possible
echo substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstvwxyz', 5)), 0, 5);
// No repeating characters
echo substr(str_shuffle('0123456789abcdefghijklmnopqrstvwxyz'), 0, 5);
<script id="sweetMessages" type="application/json">{!! json_encode(array_only(session()->all(), ['success', 'error', 'warning'])) !!}</script>
<script>
var sweetMessages = JSON.parse($('#sweetMessages').html());
setTimeout(function () {
Object.keys(sweetMessages).forEach(function (key) {
return swal(sweetMessages[key], '', key);
});
}, 0);
</script>
<?php
namespace app\Chart;
use app\Chart\Http\SomeMiddleware;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
class ChartServiceProvider extends ServiceProvider
{