Skip to content

Instantly share code, notes, and snippets.

const express = require("express");
const querystring = require("querystring");
const session = require("express-session");
const app = express();
const port = 8080;
const url = `http://localhost:${port}`;
const oauthServer = "https://app.startinfinity.com";
const appId = "<paste-app-id>";
@dam1r89
dam1r89 / inith.sh
Created April 20, 2020 09:52
Run Laravel scheduler in docker container every minute
#!/bin/bash
# Start at :30 seconds
WAIT_FOR_MIDDLE_OF_MINUTE=$(( ( 90 - $(date +%S) ) % 60 ))
sleep $WAIT_FOR_MIDDLE_OF_MINUTE
START=$(date +%s%N)
INTERVAL_SECONDS=60
INTERVAL_NANOSECONDS=$(( $INTERVAL_SECONDS * 1000000000 ))
i=1
@dam1r89
dam1r89 / stack.js
Created July 30, 2019 09:49
When manually trying find application bottleneck this snippet will pull stack trace ignoring node_modules and filtering only my application code.
try { throw Error() } catch (e) {
var stack = e.stack.split('\n').map(l => l.match(/\((.*).+\)/)).filter(Boolean)
.map(l => l[1])
.filter(l => !l.includes('node_modules') && l.includes('/app/'))
.slice(1, 4)
console.count('findByUserAndNetworkId: ' + stack.join(' -> '))
};
<?php
namespace app\Chart;
use app\Chart\Http\SomeMiddleware;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
class ChartServiceProvider extends ServiceProvider
{
<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>
@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);
@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%;
# Redirecting
# From www to without www
RewriteCond %{HTTP_HOST} ^www\.domain.rs$
RewriteRule (.*) http://domain.rs/$1 [R=301,L]
<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';
#!/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