Skip to content

Instantly share code, notes, and snippets.

View jefferson's full-sized avatar
:octocat:
just coding

Jefferson jefferson

:octocat:
just coding
  • Belo Horizonte
View GitHub Profile
@jefferson
jefferson / Util.cs
Created March 21, 2019 20:01
Iterar em arquivos .resx e buscar por uma chave e retornar seu respectivo valor
public static string GetResourceValue(string text)
{
var prefix = text.Split('-')[0].Trim();
if (String.IsNullOrEmpty(prefix))
return estrategia;
var resource = ResourceFileName.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
var dictionaryEnumerator = resource.GetEnumerator();
@jefferson
jefferson / selenium-webdriver-commands.js
Last active December 3, 2018 01:10
Comandos mais utilizados no selenium-webdriver com nodejs
//Para utilizar os comandos abaixo não esqueça de utilizar os seguintes imports
const { driver } = require('../support/web_driver');
const { By } = require('selenium-webdriver');
//Acessar um URL
driver.get("https://localhost:5001/");
//Pesquisar por um elemento utilizando o xpath e clica no mesmo
await driver.findElement(By.xpath('//*[@id="cookieConsent"]/div/div[2]/div/button')).click();
@jefferson
jefferson / gist:4ee62212102fc10c39059ae489ade03b
Created August 25, 2018 19:11
fix jshint in visual code
npm install -g eslint eslint-plugin-react babel-eslint eslint-config-defaults
@jefferson
jefferson / generate-pushid.js
Created March 25, 2017 05:49 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@jefferson
jefferson / connect_heroku_to_amazon_rds
Created February 17, 2017 18:32 — forked from jonyt/connect_heroku_to_amazon_rds
How to connect a Heroku application to an Amazon RDS Postgresql instance
Download the certificate with:
`wget -O config/rds-combined-ca-bundle.pem http://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem`
Then connect with:
`postgres://user:password@amazon-host/db_name?sslmode=require&sslrootcert=config/rds-combined-ca-bundle.pem`
References:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL
https://github.com/jeremyevans/sequel/issues/897
http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
http://dba.stackexchange.com/questions/77811/how-to-connect-to-an-amazon-postgresql-database-using-ssl
@jefferson
jefferson / Profile.java
Created September 2, 2016 02:27
A simple profile class for android using shared preferences.
public class Profile {
public static final String USER_NAME = "_username";
public static final String TOKEN_ENVITED = "_token_envited";
public static void write(final Context context, final String key, final String value){
Thread t = new Thread(new Runnable() {
@Override
public void run() {
@jefferson
jefferson / ui-grid-directive-actions.js
Last active February 18, 2016 21:12
A little custom crud for ui-grid with angular.js
angular.module('App').directive("actionButton", ['$compile', function ($compile) {
function addButton(scope, element, attrs) {
var id = element.attr('id');
var button = '<div class="ui-grid-footer-action">' +
'<button type="button" class="btn btn-danger btn-sm" ng-click="{scope}.Crud.deleteBatch()">' +
'<span class="glyphicon glyphicon-trash"></span> Remover</button>' +
'<button type="button" class="btn btn-success btn-sm" ng-click="{scope}.Crud.insert()">' +
@jefferson
jefferson / Vagrantfile
Created November 23, 2015 00:59
MyVagrantConfig
# -*- mode: ruby -*-
# vi: set ft=ruby :
#resolve o erro ao ativar rsync no windows
ENV["VAGRANT_DETECTED_OS"] = ENV["VAGRANT_DETECTED_OS"].to_s + " cygwin"
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
@jefferson
jefferson / scroll_detect_position.js
Created November 11, 2015 14:10
The scroll movement is smooth and animated as expected, I just wish there was a better way to track it; without making a million events at every pixel. How can I prevent this?
// show hide subnav depending on scroll direction
//original post: https://jsfiddle.net/ZzaichikK/MUvsG/
var position = $(window).scrollTop();
$(window).scroll(function () {
var scroll = $(window).scrollTop();
if (scroll > position) {
//only piece that matters
@jefferson
jefferson / Util.java
Created September 30, 2015 13:25
Android ListView - Calc the current height from ListView.
package Util;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
/**
* Created by JeffersonAlves on 28/09/2015.
*/