Skip to content

Instantly share code, notes, and snippets.

@amarnus
amarnus / example.html
Created April 19, 2013 11:36
API Example
<!DOCTYPE html>
<html>
<head>
<title>My Bad</title>
<script type="text/javascript" src="/misc/jquery.js?v=1.4.2"></script>
<script type="text/javascript" src="/sites/all/modules/custom/t_samsungssa/js/teamie.js?v=1.0"></script>
<script type="text/javascript">
// Initialize the client
var teamie = Teamie.getClient();
@amarnus
amarnus / simple.html
Created April 2, 2013 17:38
Illustrates a bug in Google Chrome because of which the height of a div with no fixed width varies when a browser tab is duplicated.
<!DOCTYPE html>
<html>
<head>
<title>Simple HTML</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<style type="text/css">
#navbar {
display: block;
}
#navbar ul {
@amarnus
amarnus / gist:5244090
Last active December 15, 2015 10:09
Using array_merge and the + operator in PHP for adding two associative arrays is not the same. When array_merge() is used, the key-value association is lost as the indices are re-numbered.
<?php
// Source associative array 1
$source1 = array(
2 => 'Hello',
3 => 'World'
);
// Source associative array 2
$source2 = array(
@amarnus
amarnus / circular_primes.php
Created February 18, 2012 17:37 — forked from anonymous/circular_primes.php
List of all the circular primes under a million
<?php
ini_set('memory_limit', '256M');
$maximum = 1000000; // a million if you were wondering..
global $values;
function check_if_circular($prime) {
global $values;
$back2back = $prime . $prime; // 7373
$count = strlen($prime);
for($i = 0; $i <= $count - 1; ++$i) {
@amarnus
amarnus / infinite_scroll.js
Created June 7, 2011 01:55
Add Infinite Scroll to Tumblr's Stationary theme
(function($) {
function bindScroll() {
$(window).scroll(function(){
var threshold = 0.8 * ($(document).height() - $(window).height());
if ($(window).scrollTop() >= threshold){
$(window).unbind('scroll');
getNextPage();
}
});
@amarnus
amarnus / AbstractVirtual.java
Created March 18, 2011 14:11
Understanding Abstract classes and Virtual Functions in Java
/**
* Understanding Virtual Functions and Abstract Classes
*
* @author Amarnath R
*/
/**
* Output:
* Time is 1300458436333 from SimpleDerivedClass
* DerivedConcreteClass is smelly