Skip to content

Instantly share code, notes, and snippets.

View renanregis's full-sized avatar
:octocat:

Renan renanregis

:octocat:
View GitHub Profile
package main
import (
"encoding/json"
"io/ioutil"
"log"
"strconv"
"strings"
"github.com/PuerkitoBio/goquery"
const { gql, ApolloServer } = require('apollo-server');
const typeDefs = gql`
type Query {
greeting: String
}
`;
const resolvers = {
Query: {
@renanregis
renanregis / docker-compose-jupyter.txt
Created April 13, 2020 13:02
Docker Compose - Jupyter Notebook
version: '3.7'
services:
datascience-notebook:
image: jupyter/datascience-notebook
volumes:
- ./data:/home/jovyan/work
ports:
- 8888:8888
container_name: ds-notebook
@renanregis
renanregis / github_respositories_by_start.go
Created September 11, 2018 16:34
listing top 10 go repositories by stars
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Item struct {
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
@renanregis
renanregis / get_cookies_javax.java
Created July 24, 2018 15:03
Getting Cookies with Javax Servlet
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
public String recuperaCookie(HttpServletRequest request){
String cookie = null;
Cookie[] cookieArray = request.getCookies();
for(Cookie c : cookieArray){
if(c.getName().equals("name_cookie")){
JSONObject json = new JSONObject(URLDecoder.decode(c.getValue()));
@renanregis
renanregis / httpurlconnection_post_example.java
Last active July 25, 2018 00:28
POST Method example using HttpsURLConnection
package com.company;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
require 'net/ldap'
class LdapService
def con
@base = "dc=example, dc=com"
@ldap = Net::LDAP.new
@ldap.host = host
require 'net/ldap'
class LdapService
def con
@ldap = Net::LDAP.new
@ldap.host = '172.22.0.10'
@ldap.port = 389
@ldap.auth "CN=SSO,OU=SISTEMAS,OU=Users,OU=Desenvolvimento,OU=GEINF,OU=CRE,OU=SEFIN,DC=sefin,DC=ro,DC=gov,DC=br", "password"
@renanregis
renanregis / authenticate_token_rails.rb
Last active June 20, 2018 17:03
Authentication HTTP Token with Rails 5.x
#Add this line in controller
include ActionController::HttpAuthentication::Token::ControllerMethods
before_action :authenticate
#Method to get the token via Header
#You can create some custom pattern, in this case I use Bearer.
private
def authenticate