Skip to content

Instantly share code, notes, and snippets.

@youmad
youmad / templar.js
Created January 11, 2016 19:34
Micro template engine in JS.
var tplNgn = function(qs, opts) {
var html = document.querySelector(qs).innerHTML;
var re = /<%([^%>]+)?%>/g;
var reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g;
var code = 'var r=[];\n';
var cursor = 0;
var match;
var add = function(line, js) {
if (js) {
code += (line.match(reExp))
@youmad
youmad / binary-send.js
Created January 11, 2016 19:28
Send form with file as binary
"use strict";
var Utf8Encode = function (string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
@youmad
youmad / 1-Explanations.md
Created October 6, 2015 19:56 — forked from danvbe/1-Explanations.md
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.
@youmad
youmad / nginx.conf
Last active August 29, 2015 14:27 — forked from leon/nginx.conf
Nginx PHP-FPM Symfony 2 minimal config
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {