Skip to content

Instantly share code, notes, and snippets.

<?php
$f3 = require 'lib/base.php';
?>
@slifin
slifin / gist:8390888
Last active January 3, 2016 01:39
CoffeeScript 1 second of request frames (doesn't end gracefully)
class Game
loop:0
started: Date.now();
start: ->
window.requestAnimationFrame(this.step())
step:->
console.log 'test'
this.loop += 1
if (this.started+1000<Date.now())
console.log this.loop
public $parents = array();
function loadParent($post=NULL){
if ($post === NULL) $post = $this;
$post->parents[] = $post;
if (!$post->d_rootId){
return $post;
}else{
$return=$post->findone(['d_id = ?',$post->d_rootId]);
return $this->loadParent($return);
}
public $parents = array();
function loadParent($rootID=NULL){
$rootID = $rootID ?: $this->d_rootId;
$parent = $this->findone(['d_id = ?', $rootID]);
$this->parents[] = $parent;
if (!$parent->d_rootId)
return 'test';
else
$this->loadParent($parent->d_rootId);
}
@slifin
slifin / shortcode.php
Created January 27, 2015 09:21
button shortcode
/*===========================================================*/
/* Button
/*===========================================================*/
if ( !function_exists('sdesigns_button') ) {
function sdesigns_button( $atts, $content = null ) {
$defaults = array(
'to' => '#',
'type' => 'normal'
);
@slifin
slifin / page.js
Created January 27, 2015 09:24
JavaScript button on click handler for showing data
/**
* Read Book button.
*/
$('.read-book-button').on('click', function(event){
event.preventDefault();
if ( !sameIds ) {
var id = $(this).data('id');
$.ajax({
@slifin
slifin / functions.php
Created January 27, 2015 09:42
get chapters for relevant book
function sdesigns_ajax_bookblock_function(){
$download_id = $_POST['id'];
$output = '';
if ( $_POST['sameIds'] ) {
$args = array(
'post_type' => 'book',
'posts_per_page' => -1,
'order' => 'ASC'
);
@slifin
slifin / ad.html
Last active August 29, 2015 14:17
Dynamic ad container resizing
<img id="ad" src="http://aka-cdn-ns.adtechus.com/images/5205_gamezone_source_728x90_r1.jpg" alt="Adtech Ad" border="0"/>
<script type="text/javascript">
(function(){
'use strict';
var container = window.parent.document.getElementById('focus-enclose'),
ad = document.getElementById('ad');
if (ad&&container)
container.style.height = ad.offsetHeight+'px';
})();
</script>
@slifin
slifin / test.html
Last active August 29, 2015 14:18
observer pattern example
<!DOCTYPE html>
<html>
<head>
<title>Observer Pattern</title>
</head>
<body>
<div id="game-names"></div>
<script type="text/javascript">
function Observable(){
var that = {},
@slifin
slifin / test.html
Created April 3, 2015 23:31
mediator pattern example using jquery
<!DOCTYPE html>
<html>
<head>
<title>Observer Pattern</title>
</head>
<body>
<div id="game-names"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script type="text/javascript">