Skip to content

Instantly share code, notes, and snippets.

View rodush's full-sized avatar
👷‍♂️
building web applications

Roman Dushko rodush

👷‍♂️
building web applications
View GitHub Profile
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
prev, next, res := 0, 0, 0
return func() int {
res = prev + next
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
var r = make(map[string]int)
for _, w := range strings.Fields(s) {
@rodush
rodush / gist:4790ebe5547219b79e7052e18de079c7
Created June 7, 2016 15:15
Go Tutor - Sqrt implementatin
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z, prev := x/2, x
for math.Abs(prev - z) >= 1e-14 {
@rodush
rodush / gist:0b3d61c0343965b9bf5c
Created December 18, 2015 13:30 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@rodush
rodush / Go lang tutor - Slices Excercise
Created November 21, 2015 05:43
experimenting with different math in drawing
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
var pxy = make([][]uint8, dy)
// allocation
for yi := range pxy {
pxy[yi] = make([]uint8, dx)
@rodush
rodush / vtgier_search
Created October 7, 2015 14:05
Need to speedup the query
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • ➕ when adding feature
  • ➖ when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug
mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'

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.