Skip to content

Instantly share code, notes, and snippets.

@andershaig
andershaig / example-2.css
Last active December 21, 2015 07:39
If the following CSS was applied, which lines would be affected?
footer li {
background: red;
}
@andershaig
andershaig / example-1.css
Created August 19, 2013 18:45
If the following HTML and CSS were applied to the page, what color would the text be displayed as?
.foo span { color: purple; }
#bar { color: orange; }
.foo { color: green; }
@andershaig
andershaig / app.txt
Created August 5, 2013 17:29
Creating an Application access token
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
@andershaig
andershaig / log.js
Created July 25, 2013 18:13
Inject jQuery into a page (e.g. via console)
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js');
var head = document.getElementsByTagName('head')[0];
if (head) {
head.appendChild(s);
} else {
document.body.appendChild(s);
}
@andershaig
andershaig / hash-checker.js
Created July 16, 2013 20:09
Use window.location.hash to create an extra page
$(document).ready( function () {
if (window.location.hash === '#mySampleHash') {
$('#section-1').fadeIn();
// Change active nav item (optional)
$('#main_tab_my-sample-item').addClass('active');
// Change the page title to make it appear more like a different page
document.title = "My Sample Title";
} else {
@andershaig
andershaig / sample.js
Last active December 19, 2015 20:18
Remap jQuery to $
(function ($, SampleNamespace, undefined) {
SampleNamespace.publicMethod = function () {
// Do something public
};
var privateMethod = function () {
// Do something private
};
@andershaig
andershaig / default.liquid
Created June 12, 2013 16:00
Single category at a time
<!-- Current Code on lines 30-32 -->
{% for category in gallery_settings.categories %}
<a href="#" data-cat="{{ category.title | handelize }}"><li>{{ category.title }}</li></a>
{% endfor %}
<!-- First category only -->
{% for category in gallery_settings.categories limit:1 %}
<a href="#" data-cat="{{ category.title | handelize }}"><li>{{ category.title }}</li></a>
{% endfor %}
@andershaig
andershaig / fbcanvas.liquid
Last active December 18, 2015 05:29
Simple Redirect - This doesn't worry about social referral tracking, providing a different URL for mobile etc. It's just meant to be easier to understand and implement.
{% plugin rawtext desktop_redirect_url %}
<script type="text/javascript">
if (!document.body.className.match('page_preview')) {
// Redirects as soon as possible
setInterval( function () {
top.location.replace({{ desktop_redirect_url | json }});
},250);
}
</script>
@andershaig
andershaig / fbcanvas.liquid
Last active December 18, 2015 05:29
Redirect users with support for referral tracking
{% plugin rawtext fanpage_url %}
<script type="text/javascript">
if (!document.body.className.match('page_preview')) {
var redir;
if (window.location.search) {
// Triggered if there's already a social referrer being tracked
var ref_search = window.location.search;
var ref = ref_search.split('=');
var ref_id = ref[1];
@andershaig
andershaig / include.liquid
Last active December 16, 2015 01:59
In-template Notification
<style>
#tmp-notify {
position:absolute;
margin:20px;
left:0;
top:0;
right:0;
z-index:9999;
}