Skip to content

Instantly share code, notes, and snippets.

View kyohei8's full-sized avatar
💭
🕵️‍♂️

kyohei tsukuda kyohei8

💭
🕵️‍♂️
View GitHub Profile
@fredoliveira
fredoliveira / fbsignedrequest.rb
Created November 17, 2010 19:50
Parses Facebook OAuth2.0 Signed requests. Ported to Ruby from Facebook's PHP SDK.
# ported to ruby by fred@webreakstuff.com
require 'rubygems'
require 'base64'
gem 'json'
require 'json'
require 'openssl'
def parse_facebook_request(str, app_secret)
string = str.split(".") # splits our signed request
@basdenooijer
basdenooijer / demo.php
Created May 4, 2011 06:26
Solarium example with facet filtering and pagination
<?php
require('../library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
$client = new Solarium_Client();
$client->setHost('192.168.1.2');
$client->setCore('geonames');
$query = new Solarium_Query_Select;
@andyfowler
andyfowler / .vimrc
Created September 5, 2011 18:08
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
@terkel
terkel / jquery.placeholder.js
Created September 23, 2011 00:56
HTML5 Placeholder Polyfill using jQuery
(function ($) {
$(function () {
if (!supportsInputAttribute('placeholder')) {
$('[placeholder]').each(function () {
var $this = $(this),
$form = $this.closest('form'),
placeholderText = $this.attr('placeholder'),
placeholderColor = 'GrayText',
defaultColor = $this.css('color');
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

class Enum < Hash
def initialize(*members)
super()
@rev = {}
members.each_with_index {|m,i| self[i] = m }
end
def [](k)
super || @rev[k] # || raise ArgumentError, "#{k} is not a member of this enum"
end
def []=(k,v)
@revolunet
revolunet / demo.html
Last active May 21, 2020 11:13
AngularJS ngLoading directive. show a loader based on an attribute and restore content when ready.
<!DOCTYPE html>
<html ng-app >
<head lang="en">
<meta charset="utf-8">
<title>ngLoading demo</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<link rel="stylesheet" href="style.css">
<script src="ngLoading.js"></script>
</head>
@impressiver
impressiver / raven-config.html
Last active June 28, 2024 05:30
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@talltyler
talltyler / gist:5345894
Created April 9, 2013 14:01
This code gives the HTML canvas element JavaScript support for letter spacing. Don't confuse letter spacing with kerning http://en.wikipedia.org/wiki/Kerning This code is basically from http://stackoverflow.com/a/15509006
(function(){
var _fillText,
__slice = [].slice;
_fillText = CanvasRenderingContext2D.prototype.fillText;
CanvasRenderingContext2D.prototype.fillText = function() {
var args, offset, previousLetter, str, x, y,
_this = this;