Skip to content

Instantly share code, notes, and snippets.

View xxzefgh's full-sized avatar

Mirza Brunjadze xxzefgh

  • Tbilisi, Georgia
View GitHub Profile
@xxzefgh
xxzefgh / LaravelBridge.php
Last active May 5, 2016 09:34
Call Laravel routes and get response from pure php. Useful when you have existing project and want to use Laravel to achieve some tasks.
<?php
class LaravelBridge
{
private static $app = null;
private static $kernel = null;
private static function init()
{
if (!self::$app || !self::$kernel) {
#!/bin/bash
app_path="/path/to/target/folder"
if [ ! -d $app_path ]; then
mkdir -p $app_path;
fi
while read oldrev newrev ref
do
@xxzefgh
xxzefgh / random-non-overlapping-position.js
Created March 21, 2017 04:46 — forked from magicznyleszek/random-non-overlapping-position.js
JavaScript -- get random non-overlapping position
// declarations
var positions = [];
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
// generate random positions
@xxzefgh
xxzefgh / nginx_reverse_proxy.conf
Created April 30, 2017 09:50
Nginx reverse proxy example configuration
upstream example {
server localhost:8080;
}
server {
listen 80;
server_name example.com;
server_tokens off;
location / {
export function snakeToCamel(str) {
return str.toLowerCase().replace(/_(.)/g, (match, $1) => $1.toUpperCase())
}
const vp9CodecType = 'video/webm; codecs="vp9"'
function checkMediaSourceWay() {
return 'MediaSource' in window && MediaSource.isTypeSupported(vp9CodecType)
}
function checkHTMLMediaElementWay() {
return document.createElement('video').canPlayType(vp9CodecType) === 'probably'
}

Keybase proof

I hereby claim:

  • I am xxzefgh on github.
  • I am xxzefgh (https://keybase.io/xxzefgh) on keybase.
  • I have a public key ASCP4gS21C15pcLXjdoq6908QlL0X_OOProk4k2DY6o-_wo

To claim this, I am signing this object:

import {Directive, Input, HostListener} from '@angular/core';
@Directive({
selector: 'img[fallback]'
})
export class ImageFallbackDirective {
private _fallback = 'assets/images/404_image.png';
@Input() set fallback(value: string) {
if (value && value.length > 0) {
function formatMoney(value: any, thousandSeparator: string | false = false, fractionDigits = 2): string {
let number = Number(value);
if (isNaN(number)) {
number = 0;
}
// Number#toFixed will throw runtime exception if fractionDigits isn't within 0-100 range
if (fractionDigits < 0 || fractionDigits > 100) {
fractionDigits = 0;
}
export function exponentialRandomBackoff(
initialIntervalMillis: number,
multiplier: number,
randomizationFactor: number
) {
checkInterval(initialIntervalMillis);
checkMultiplier(multiplier);
checkRandomizationFactor(randomizationFactor);
return (attemptsMade: number) => {
const interval = Math.round(Math.pow(multiplier, attemptsMade) * initialIntervalMillis);