Skip to content

Instantly share code, notes, and snippets.

@adityawarmanfw
adityawarmanfw / duckdb__dim_date.sql
Last active April 23, 2024 09:17
Generate Date Dimension table in DuckDB
WITH generate_date AS (
SELECT CAST(RANGE AS DATE) AS date_key
FROM RANGE(DATE '2009-01-01', DATE '2013-12-31', INTERVAL 1 DAY)
)
SELECT date_key AS date_key,
DAYOFYEAR(date_key) AS day_of_year,
YEARWEEK(date_key) AS week_key,
WEEKOFYEAR(date_key) AS week_of_year,
DAYOFWEEK(date_key) AS day_of_week,
ISODOW(date_key) AS iso_day_of_week,
parameters:
file_upload_mime_types:
- application/pdf
- application/x-pdf
- text/plain
- application/rtf
- image/*
- application/msword
- application/vnd.openxmlformats-officedocument.wordprocessingml.document
@colemanw
colemanw / font-awesome-mime-type-icons.php
Last active March 11, 2024 04:21 — forked from guedressel/font-awesome-mime-type-icons.php
Font Awesome File Icons: Mapping MIME Types to correct icon classes
<?php
/**
* Get font awesome file icon class for specific MIME Type
* @see https://gist.github.com/guedressel/0daa170c0fde65ce5551
*
*/
function ($mime_type) {
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = array(
@mickaelandrieu
mickaelandrieu / upgrade_to_symfony3-lts.md
Last active May 21, 2024 03:39
Migration guide to Symfony 3 LTS

Let's migrate a Symfony 2.8 LTS application to Symfony 3 LTS

Handle deprecations

First of all, ensure you don't have any deprecated!

The Symfony documentation explains it well, but let's sum up:

  • install the phpunit bridge ($ composer require --dev symfony/phpunit-bridge)
  • also check all your pages using web profiler and be ensure there is no deprecation error handled
  • found errors and need help about how to fix it ? I did a sort of guide.
@dzuelke
dzuelke / cmfdeploy.sh
Last active February 1, 2016 09:39
Deploying Symfony CMF to Heroku
git clone https://github.com/symfony-cmf/cmf-sandbox.git
cd cmf-sandbox
composer install
# declare optional extensions as required
php -dmemory_limit=4G $(which composer) require "ext-gd:*" "ext-exif:*"
git add composer.json composer.lock
git commit -m "require gd and exif extensions"
# add DATABASE_URL mapping to composer.json and update DB config (see database.diff)
php -dmemory_limit=4G $(which composer) update --lock
git add composer.json composer.lock app/config/config.yml app/config/config_prod.yml
class MoneyType extends AbstractType implements DataMapperInterface
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('amount', 'integer')
->add('currency', 'string')
->setDataMapper($this)
;
}
@CMCDragonkai
CMCDragonkai / parallel_curl.sh
Last active April 22, 2024 16:03
Bash: GNU Parallel with Curl
# do it once
seq 1 | parallel -n0 "curl -H 'Content-Type: application/json' http://httpbin.org/post -X POST -d '{\"url\":\"http://google.com/\"}'"
# do it twice
seq 2 | parallel -n0 "curl -H 'Content-Type: application/json' http://httpbin.org/post -X POST -d '{\"url\":\"http://google.com/\"}'"
# do it 4 times, but at 2 a time
seq 4 | parallel -n0 -j2 "curl -H 'Content-Type: application/json' http://httpbin.org/post -X POST -d '{\"url\":\"http://google.com/\"}'"
# you can also put all your commands into a file
<?php
namespace Acme\AwesomeApp\Infrastructure\UserBundle\Features\Context;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Acme\AwesomeApp\Domain\User\Entity\User;
use Acme\AwesomeApp\Domain\User\Security\PasswordEncoder;
@tbarbugli
tbarbugli / How to build a notification feed.md
Last active October 17, 2021 20:13 — forked from tschellenbach/notify_tut.md
How to build a notification feed using Stream

How to build a notification feed using Stream

Introduction

In this tutorial we are going to show how easy it is to build a notification feed using GetStream.io. First of all, let's quickly introduce you to our fictional example app. It's called bug-your-friends.com and allows you interact with your friends, ping them, follow them or poke them. Here's a quick list of example interactions:

  • poke another user (eg. Thierry pokes Alessandra)
  • follow a user (eg. Tommaso follows Iris)
  • ping a user (eg. Josie pings Carolina)

Whenever a user is part of one of these interactions, we want to update his notification feed, update the number of unseen and unread