Skip to content

Instantly share code, notes, and snippets.

@maratori
maratori / .golangci.yml
Last active May 9, 2025 07:44
Golden config for golangci-lint
# This file is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021-2025 Marat Reymers
## Golden config for golangci-lint v2.1.6
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adapt it to suit your needs.
# If this config helps you, please consider keeping a link to this file (see the next comment).
@lologhi
lologhi / 1.How to easily implement a REST API with oAuth2 presentation.md
Last active April 4, 2024 22:13
Symfony2 : How to easily implement a REST API with oAuth2 (for normal guys)

It's still a work in progress...

Intro

As William Durand was recently explaining in his SOS, he "didn't see any other interesting blog post about REST with Symfony recently unfortunately". After spending some long hours to implement an API strongly secured with oAuth, I thought it was time for me to purpose my simple explanation of how to do it.

Ok, you know the bundles

You might have already seen some good explanation of how to easily create a REST API with Symfony2. There are famous really good bundles a.k.a. :

@krishnanraman
krishnanraman / gist:5224937
Last active December 15, 2015 07:39
Pail Example
Pail example:
Writejob: Partition numbers [1..100] into two directories - belowfifty & abovefifty.
Further, create 7 subdirectories under each, based on number mod 7.
So a number like 62 would end up in the location "abovefifty/6".
Readjob: Read the subdirectories "belowfifty/3" & "abovefifty/0"
RESULTS:
$ tree pailtest
@krishnanraman
krishnanraman / gist:5209602
Last active December 15, 2015 05:29
Pail example : writejob - a job to create Pails, readjob - a job to read Pails that have been created.
import com.backtype.hadoop.pail.PailStructure
import java.util.{ List => JList }
import scala.collection.JavaConverters._
import com.twitter.scalding._
import com.twitter.scalding.commons.source.{PailSource,CodecPailStructure}
import com.twitter.bijection.{NumericInjections, Injection}
class PailTest2Write(args : Args) extends Job(args) {
args("io") match {
case "read" => readjob
@krishnanraman
krishnanraman / gist:5207976
Last active December 15, 2015 05:19
Test Pail using Ints - given numbers 1 to 100, create a nested directory structure, where numbers below 50 go into one tree & those above into another. Further, in each tree, we create subdirectories based on number mod 7. So you should see 2+14 = 16 directories after you run this piece of code. They should partition the input space {1..100} exa…
import com.backtype.hadoop.pail.PailStructure
import java.util.{ List => JList }
import scala.collection.JavaConverters._
import com.twitter.scalding._
import com.twitter.scalding.commons.source.{PailSource,CodecPailStructure}
import com.twitter.bijection.{NumericInjections, Injection}
class PailTest2(args : Args) extends Job(args) {
val pipe = IterableSource((1 to 100), "src").read
@danvbe
danvbe / 1-Explanations.md
Last active February 20, 2025 12:31
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.
@domenkozar
domenkozar / autovpn.py
Created January 1, 2012 16:00 — forked from anonymous/autovpn.py
AutoVPN for NetworkManager
#!/usr/bin/env python
"""
Copyright 2011 Domen Kozar. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.