Skip to content

Instantly share code, notes, and snippets.

function FBshares(url) {
var jsondata = UrlFetchApp.fetch("http://graph.facebook.com/"+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.shares;
}
function Tweets(url) {
var jsondata = UrlFetchApp.fetch("http://urls.api.twitter.com/1/urls/count.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.count;
@bricemaurin
bricemaurin / gist:f193ed64ba67b2d0ef68
Created October 28, 2014 15:59
AR-02-Validations
class Post < ActiveRecord::Base
default_scope order('votes DESC')
belongs_to :user
validates :name, :url, :user, presence: true
validates :name, length: { minimum: 5 }
validates :name.downcase, uniqueness: { case_sensitive: false }
validates :url, format: { with: /\Ahttps?\:\/\/(?:www\.|)?\w+\.\w{2,3}(?:\/\w+)?/, message: "invalid url" }
end
class User < ActiveRecord::Base
// Copiez votre API key depuis https://platform.openai.com/account/api-keys
const SECRET_KEY = ENTER YOUR SECRET KEY HERE;
// utile pour éviter de cramer trop de crédits par query.
const MAX_TOKENS = 200;
// Forké & mis à jour pour supporter GPT3.5 depuis le code de Abi. Suivez Abi sur Twitter: https://twitter.com/_abi_
/**
* Completes your prompt with GPT-3