Skip to content

Instantly share code, notes, and snippets.

View vjnrv's full-sized avatar

Pedro Junior vjnrv

  • São Paulo - Brasil
View GitHub Profile
@vjnrv
vjnrv / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vjnrv
vjnrv / error.html.twig
Last active October 2, 2015 09:07
Symfony2 simple custom error page
{# app/Resources/TwigBundle/views/Exception/error.html.twig #}
{% extends '::layout.html.twig' %}
{% block title %}
Erro {{ status_code }}
{% endblock %}
{% block content %}
{% if status_code == '404' %}
<h1>Página não encontrada</h1>
{% else %}
<h1>Erro inesperado</h1>
<!DOCTYPE html>
<html>
<head>
<title>Workers: Compatibility</title>
<script>
// This script is executed in the main window
/*
we'll use a worker to filter a huge data set
@vjnrv
vjnrv / gist:443017
Created June 18, 2010 00:26 — forked from remy/gist:350433
if (!window.localStorage || !window.sessionStorage) (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
if (!navigator.geolocation) {
navigator.geolocation = (function (window, document) {
function getCurrentPosition(callback) {
var geourl = 'http://www.google.com/jsapi?' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
iframe.style.display = 'none';
window.document.body.appendChild(iframe);
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
<?php
## Parse query string.
$sb_league = $_GET['league'] ? strtolower( $_GET['league'] ) : 'all';
## Nav data, as a JSON heredoc. Much less verbose than PHP arrays!
$navs = json_decode(<<<JSON
{
"mlb": {
"title_link": "http://stats.boston.com/mlb/scoreboard.asp",
<script type="text/javascript">
function doLogin(doneUrl) {
/* Tell XAuth.org that a user has just signed into Google on this browser. */
XAuth.extend({
// reveals "someone is logged into Google"
token: "1",
// Expires after 24 hours or if the user explicitly logs out
expire: new Date().getTime() + 60*60*24*1000,
// Allow any domain to read this info (could also be a whitelist of partners)
extend: ["*"],
<html>
<head>
<title>Google XAuth Demo</title>
<script type="text/javascript" src="http://xauth.org/xauth.js"></script>
<script type="text/javascript">
function doLogin(doneUrl) {
/* Tell XAuth.org that a user has just signed into Google on this browser. */
XAuth.extend({
// Just reveals "someone is logged into Google" but no personally identifiable info.
<?php
/**
* Get the TwitterOAuth source code:
* http://github.com/abraham/twitteroauth
* git clone git@github.com:abraham/twitteroauth.git
*
* Get your OAuth credentials:
* http://dev.twitter.com/pages/oauth_single_token
*/