Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@tijn
tijn / git-lines-per-author.sh
Last active January 31, 2019 19:18
Produce a histogram with lines of code per author.
#!/bin/sh
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \
while read filename; do file "$filename"; done | \
grep -E ': .*text' | sed -E -e 's/: .*//' | \
while read filename; do git blame --line-porcelain "$filename"; done | \
sed -n 's/^author //p' | \
sort | uniq -c | sort -rn
@tanbro
tanbro / attrdict.py
Last active January 17, 2024 14:51
A class with both dictionary and attribute style access to it's data member.
from __future__ import annotations
from typing import Any, Dict, Iterable, Mapping, MutableMapping, MutableSequence, Union
class AttrDict:
"""
A class with both dictionary and attribute style access to it's data member.
It can be used in `RestrictedPython <http://restrictedpython.readthedocs.io/>`_
// the location we want to GeoCode
var location = 'London';
// we are using MapQuest's Nominatim service
var geocode = 'http://open.mapquestapi.com/search?format=json&q=' + location;
// use jQuery to call the API and get the JSON results
$.getJSON(geocode, function(data) {
// get lat + lon from first match
var latlng = [data[0].lat, data[0].lon]
@agarny
agarny / github-import-issues
Last active June 7, 2023 22:44
Import GitHub issues from one repository to another (incl. milestones, labels and comments).
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This script came about after I removed several big files from a GitHub
# repository (see https://gist.github.com/agarny/5541082) and force pushed
# everything back to GitHub. However, cloning the 'new' GitHub repository still
# results in those big files being present in the git history. This is, among
# other things, due to some pull requests I have in that repository and which
# reference those big files. I contacted GitHub about this, but there seems to
# be nothing that they can do about it. So, I was left with no other choice but
@thedamon
thedamon / backbutton close bootstrap modal
Created February 28, 2014 17:59
Cause back button to close Bootstrap modal windows
$('div.modal').on('show', function() {
var modal = this;
var hash = modal.id;
window.location.hash = hash;
window.onhashchange = function() {
if (!location.hash){
$(modal).modal('hide');
}
}
});
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@sawapi
sawapi / AppDelegate.swift
Last active October 25, 2023 09:26
[Swift] Push Notification
//
// AppDelegate.swift
// pushtest
//
// Created by sawapi on 2014/06/08.
// Copyright (c) 2014年 sawapi. All rights reserved.
//
// iOS8用
import UIKit