Skip to content

Instantly share code, notes, and snippets.

@endel
endel / authentication.js
Last active March 24, 2016 08:55
ng-admin authentication with hook https://github.com/doubleleft/hook
var app = angular.module('admin', ['ng-admin']),
hook = new Hook.Client({...});
var headerNav, pageWrapper, restangular;
if (hook.auth.currentUser && hook.auth.currentUser.role != 'admin') {
hook.auth.logout();
}
function hideMenu() {
@mattiaerre
mattiaerre / open-component-renderer.js
Last active August 20, 2017 22:45
how to client side render an OpenComponents component using the Console (Developer Tools)
((oc, $) => {
// see: https://github.com/opentable/oc/wiki/Browser-client#ocbuild-options
const html = oc.build({
baseUrl: 'http://localhost:3030',
name: 'pi-baltimore-special-offers-promo-banners',
version: '1.X.X',
parameters: {
banner: 'purple-pasta'
}
});
@docteurklein
docteurklein / CompilerPass.php
Last active October 17, 2017 11:39
Service Repository Factory
<?php
public function process(ContainerBuilder $container)
{
$factory = $container->findDefinition('app.doctrine.repository.factory');
$repositories = [];
foreach ($container->findTaggedServiceIds('app.repository') as $id => $params) {
foreach ($params as $param) {
$repositories[$param['class']] = $id;
@arnaud-lb
arnaud-lb / flush.php
Created September 15, 2012 10:14
flush email queue from symfony command
<?php
protected function flushQueue()
{
$container = $this->getContainer();
$transport = $container->get('mailer')->getTransport();
$spool = $transport->getSpool();
$spool->flushQueue($container->get('swiftmailer.transport.real'));
@twilson63
twilson63 / README.md
Last active February 28, 2019 17:24
Offline First Native Web Applications with couchdb or pouchdb

Building Offline First Native Web Applications

Creating Offline First Native Web Applications using PouchDB and CouchDB and replication is a nice approach to remove the challenges keeping the client database insync with the server database.

One thing that always comes up is security, and security is very important and should not be taken lightly. Using implementations like JWT or JsonWebToken and external authentication services like Auth0 and StormPath can create a solid pattern to keep your secrets off of your client.

Using JWT, when the user authenticates with the JWT Server, they receive a token, this token can be used to access

@K-Phoen
K-Phoen / AppKernel.php
Created January 9, 2013 15:38
Functional tests for standalone Symfony2 bundles
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
return array(
@Kydoh
Kydoh / new_gist_file
Created November 8, 2013 14:51
Generate random password (require FOSUserBundle)
<?php
$tokenGenerator = $this->getContainer()->get('fos_user.util.token_generator');
$password = substr($tokenGenerator->generateToken(), 0, 8); // 8 chars
@saboyutaka
saboyutaka / controller_macros.rb
Created August 24, 2013 04:25
Rspec spec/support files.
module ControllerMacros
def login_user
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:user]
user = FactoryGirl.create(:user)
user.confirm!
sign_in user
end
end
end
@mackato
mackato / rails_guides_to_epub.rb
Created June 4, 2010 03:24
Ruby on Rails Guides ePub convert ruby script
require 'rubygems'
require 'nokogiri'
require 'eeepub'
DOC_TITLE = 'Ruby on Rails Guides'
def get_pages(src_dir)
index_file = File.join(src_dir, 'index.html')
section = nil
pages = [{ :section => section, :title => DOC_TITLE, :path => index_file }]
@TastyToast
TastyToast / handlebars-truncate-helper.js
Last active April 21, 2021 09:08
Truncate helper for Handlebars.js
Handlebars.registerHelper ('truncate', function (str, len) {
if (str.length > len) {
var new_str = str.substr (0, len+1);
while (new_str.length) {
var ch = new_str.substr ( -1 );
new_str = new_str.substr ( 0, -1 );
if (ch == ' ') {
break;