Skip to content

Instantly share code, notes, and snippets.

@artygrand
artygrand / 1Repository.php
Last active May 29, 2017 10:51
Repo - entity - fields
<?php
namespace Module\Entity\Models;
use Sydes\Database;
use Sydes\PDO;
class Repository
{
/** @var PDO */
protected $db;
@artygrand
artygrand / script.js
Created September 14, 2017 05:40
action on hovered text
var getSelectedText = function() {
var text = '';
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection) {
text = document.selection.createRange().text;
}
return text;
};
SELECT entry.id as entry_id,
v_brand.value as brand,
v_year.value as year
FROM entity
JOIN entry
ON entity.id = entry.entity_id
JOIN value v_brand
ON v_brand.parameter_id = 1
AND v_brand.entry_id = entry.id
JOIN value v_year
@media (min-width:1200px){
.auto-clear .col-lg-1:nth-child(12n+1){clear:left;}
.auto-clear .col-lg-2:nth-child(6n+1){clear:left;}
.auto-clear .col-lg-3:nth-child(4n+1){clear:left;}
.auto-clear .col-lg-4:nth-child(3n+1){clear:left;}
.auto-clear .col-lg-6:nth-child(odd){clear:left;}
}
@media (min-width:992px) and (max-width:1199px){
.auto-clear .col-md-1:nth-child(12n+1){clear:left;}
.auto-clear .col-md-2:nth-child(6n+1){clear:left;}
@artygrand
artygrand / Dungeon.cs
Created September 18, 2019 08:43
Wrong dungeon generator
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Dungeon : MonoBehaviour
{
public static float[] MapSize;
[Header("World Generation Values")]
@artygrand
artygrand / react.js
Created October 6, 2021 05:30
Wrap react's setState with callback or mutator
const wrappedSetInvoice = useCallback((value: ((i: InvoiceModel) => InvoiceModel) | InvoiceModel) => {
setInvoice(old => {
const updated = value instanceof Function ? value(old) : value;
return {...updated, dirty: true};
});
}, [setInvoice]);