Skip to content

Instantly share code, notes, and snippets.

@felixprojekt
felixprojekt / install-redis-cli.sh
Created October 22, 2021 11:30
Install redis-cli on linux
sudo yum install -y gcc wget
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
sudo cp src/redis-cli /usr/bin/
@felixprojekt
felixprojekt / flatc-cheatsheet.txt
Last active June 21, 2021 13:35
flatc-cheatsheet
// Generate C# classes from schemas
flatc -n *.fbs
// JSON to binary
flatc --binary schema.fbs source.json
// binary to JSON
flatc --raw-binary -t schema.fbs -- source.bin
@felixprojekt
felixprojekt / custom_types.html.twig
Last active July 18, 2020 07:43
Add form field ID to form-group element in Symfony 4 bootstrap theme
{% use "bootstrap_4_layout.html.twig" %}
{% block form_row -%}
{%- if compound is defined and compound -%}
{%- set element = 'fieldset' -%}
{%- endif -%}
{%- set widget_attr = {} -%}
{%- if help is not empty -%}
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
{%- endif -%}
@felixprojekt
felixprojekt / lightbox-options.js
Created February 24, 2020 22:21
Handy Lightbox options
if (typeof lightbox !== 'undefined') {
lightbox.option({
'resizeDuration': 200,
'albumLabel': '%1 / %2',
'fadeDuration': 200,
'imageFadeDuration': 0,
})
}
@felixprojekt
felixprojekt / AnimatorClipsLength.cs
Last active January 22, 2020 15:56
Get Animator clips lengths of current gameObject in Unity
public class ClipsLength : MonoBehaviour
void Start()
{
AnimationClip[] clips = gameObject.GetComponent<Animator>().runtimeAnimatorController.animationClips;
foreach(AnimationClip clip in clips)
{
Debug.Log(clip.name);
Debug.Log(clip.length);
}
}
@felixprojekt
felixprojekt / index.html
Created January 8, 2020 01:12
hide-website-in-landscape
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.rotate-device {
display: none;
}
@media (orientation: landscape) and (max-height: 500px) {
html, body {
@felixprojekt
felixprojekt / create-url-friendly-string.php
Created November 17, 2019 21:29
Create URL friendly string from Czech text in PHP
<?php
public function createUrl($string)
{
$output = preg_replace('~[^\\pL0-9_]+~u', '-', $string);
$output = trim($output, '-');
$output = iconv('UTF-8', 'us-ascii//TRANSLIT', $output);
$output = strtolower($output);
$output = preg_replace('~[^-a-z0-9_]+~', '', $output);
return $output;