Skip to content

Instantly share code, notes, and snippets.

View stephanelpaul's full-sized avatar
🌍

Stephane Leandre Paul stephanelpaul

🌍
View GitHub Profile
@thgbarros
thgbarros / models.js
Last active April 23, 2019 07:24
OAuth 2.0 server implementation to Alexa Skill Account linking
const pgp = require('pg-promise')({});
const db = pgp(process.env.DATABASE_URL);
/*
* Get access token.
*/
module.exports.getAccessToken = function(bearerToken) {
return db.query('SELECT otk_token_acesso, otk_token_expira_em, otk_ocl_id, otk_refresh_token, otk_refresh_token_expira_em, otk_usr_id FROM otk_oauth_tokens WHERE otk_token_acesso = $1', [bearerToken])
.then(function(result) {
@lantins
lantins / main.go
Last active August 29, 2015 14:12
Golang - HTTP Server - Contexts
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
"os"
"strconv"
)
@brly
brly / gist:37c44f51a7908730c161
Created June 22, 2014 17:46
martini json response sample
package main
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"net/http"
)
package signatures
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/binding"
"github.com/martini-contrib/render"
"labix.org/v2/mgo"
)
type Server *martini.ClassicMartini
@keithio
keithio / post.js
Last active August 29, 2015 14:00
Parse.Object.previous() workaround for Parse.Cloud.beforeSave()
Parse.Cloud.beforeSave('Post', function (request, respond) {
var post = request.object;
var prevCatId = post.get('prevCat').id;
var catId = post.get('cat').id;
if (post.dirty('cat')) {
var prev = new Parse.Query('Category');
prev.get(prevCatId, {
success: function (category) {
// Decrement old category post count.
@vastbinderj
vastbinderj / ottemo.go
Created April 9, 2014 15:14
ottemo-create-user-func
package main
import (
"fmt"
"github.com/codegangsta/martini"
"github.com/martini-contrib/binding"
"github.com/martini-contrib/render"
"github.com/martini-contrib/secure"
"github.com/martini-contrib/sessions"
"github.com/ottemo/ottemo-go/auth"
@altyus
altyus / gist:10223831
Created April 9, 2014 03:35
Parse Cloud code to get Post objects for in network friends with passed in facebook IDs
Parse.Cloud.define("friends", function(request, response){
var query = new Parse.Query("User");
query.containedIn("facebook_id", request.params.facebook_ids_array);
query.find({
success: function(results){
var friendIDs = new Array();
for (var i = 0; i < results.length; i++)
{
friendIDs.push(results[i].get('facebook_id'));
}
[PFCloud callFunctionInBackground:@"capability"
withParameters:nil
block:^(NSString *token, NSError *error) {
TCDevice *device = [TCDevice initWithTokenOrWhateverIForget:token];
}];
package main
import (
"flag"
"fmt"
"github.com/globocom/tsuru/db/storage"
"github.com/gorilla/feeds"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"net/http"
@rgarcia
rgarcia / db_stats.go
Last active August 30, 2016 09:42
mongo db stats
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"log"
"os"
"strings"
"text/tabwriter"