Skip to content

Instantly share code, notes, and snippets.

@PsyGik
PsyGik / onesingal.service.ts
Created November 24, 2018 06:49
OneSignal Angular TypeScript
import {Injectable} from '@angular/core';
import {Cache} from '../utils/storage.provider'; // Decorator to access local storage
let OneSignal;
const url = '';
@Injectable()
export class OneSignalService {
@Cache({pool: 'OneSignal'}) oneSignalInit; // to check if OneSignal is already initialized.
@joseluisq
joseluisq / stash_dropped.md
Last active October 3, 2025 09:40
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@fesor
fesor / ARTICLE.md
Created August 19, 2017 08:45
Возвращаясь к основам: почему юнит тесты это сложно

https://simpleprogrammer.com/2010/12/12/back-to-basics-why-unit-testing-is-hard/

Back to Basics: Why Unit Testing is Hard

перевод адаптирован под 2017-ый, где у нас нет проблем с mock фреймворками, и нам не обязательно создавать интерфейс дабы сделать мок.

Возвращаясь к основам: почему юнит тесты это сложно

@vluzrmos
vluzrmos / paginate.php
Created July 20, 2016 14:31
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@geerteltink
geerteltink / SymfonyCustomFormTypeWithValidation.php
Last active February 13, 2022 21:25
Symfony 3 forms validation constraints without an entity
<?php
// ...
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
@btroncone
btroncone / rxjs_operators_by_example.md
Last active May 3, 2026 02:38
RxJS 5 Operators By Example
@ostashevdv
ostashevdv / offer.md
Created February 13, 2016 12:54 — forked from greabock/offer.md
офферы

#"Немного о магазинах" или "Нам нужен еще один слой абстракции"

Дисклеймер :
-- А давай забацаем e-commerce! Нету же e-commerce на Ларе! Ну давай забацаем!
-- Уговорил - давай забацаем! А ты не сдуешься на пол-пути?
-- Да ну! Я же могу то и это - я вообще крутой. Будет самое крутое решение в истории php!
-- Ну ок, давай начнем...

И так... начнем с самого "ничего". Как обычно происходит сделка покупки, в самом обчном супермаркете? Покупатель заходит в торовый зал, выбирает товар, проходит на кассу и оплачивает его. Он отдает деньги, получает чек, после чего он имеет право вынести товар из торгового зала. Что тут необходимо, для полного цикла? Нужно некоторое множество товаров-сущностей, оплата-сделка(процесс), и чек(сделка-сущность). Для простоты, будем считать, что корзина реализована куками на стороне клиента. То есть: >

@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@danvbe
danvbe / 1-Explanations.md
Last active July 23, 2025 05:55
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.