Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
barneycarroll / ordinal-suffix.html
Created March 19, 2014 13:35
Append ordinals via CSS rather than in markup. Requires even more HTML bytes though.
<span
class="ordinal"
data-number="22">
22
</span>
<span
class="ordinal"
data-number="0">
0
</span>
@ajaxray
ajaxray / ToArrayExtension.php
Last active May 2, 2024 05:51
A simple twig extension that adds a to_array filter. It will convert an object to array so that you can iterate over it's properties
<?php
// src/YourApp/Bundle/YourBundle/Twig/ToArrayExtension.php
namespace Appcito\Bundle\CoreBundle\Twig;
/**
* A simple twig extension that adds a to_array filter
* It will convert an object to array so that you can iterate over it's properties
*/
class ToArrayExtension extends \Twig_Extension
@ajaxray
ajaxray / backbone_tide_sync.js
Last active May 2, 2024 05:51
Overridden Backbone.sync to use SQLite (in tidesdk) instead of REST. So far "read" is completed.
Backbone.sync = function(method, model, options) {
// App.db is my database connection
if(_.isNull(App.db)) console.error('No Database connection!');
var query = BackboneDb.createQuery(method, model, options);
if (method === "read") {
var data = App.db.execute(query);
var resultJSON = BackboneDb.resultToJSON(data);
console.log(resultJSON);
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@ajaxray
ajaxray / gist:3127894
Created July 17, 2012 08:02
Facebook style rounded thumb image with CSS3
<style type="text/css">
a.user-image {
background: transparent no-repeat top left;
display: block;
text-indent: -999em;
width: 50px;
height: 50px;
border-radius: 5px;
box-shadow: 0px 0px 3px #666;
}
@m14t
m14t / day-1.md
Last active May 2, 2024 05:50
GraphQL Summit 2018 - Links worth sharing

GraphQL Summit 2018 - Links worth sharing

Day 1

@m14t
m14t / index.test.js
Created October 23, 2018 01:51
Assert that your GraphQL schema can execute the introspectionQuery
const { execute, introspectionQuery, parse } = require('graphql');
const { schema } = require('../index');
describe('graphql', () => {
describe('index', () => {
describe('schema', () => {
it('should be a an object', () => {
expect(typeof schema).toBe('object');
});
@dergachev
dergachev / upgrade-git-precise64.sh
Created July 3, 2013 14:28
Installs git 1.7.10 on Ubuntu 12.04 (Precise) using packages from the upcoming 12.10 (Quantal) release. Should work for i386 and amd64.
#
# Installs git 1.7.10 on Ubuntu 12.04 (Precise) using packages from
# the upcoming 12.10 (Quantal) release. Should work for i386 and amd64.
#
# Adapted from http://pastebin.com/TXeMw1CY
#
HOST_ARCH=`dpkg-architecture -qDEB_HOST_ARCH_CPU`
wget http://mirrors.us.kernel.org/ubuntu/pool/main/g/git/git_1.7.10.4-1ubuntu1_${HOST_ARCH}.deb \
@arnaud-lb
arnaud-lb / UseIndexWalker.php
Created May 15, 2012 19:27
USE INDEX / FORCE INDEX in a Doctrine2 DQL query
<?php
use Doctrine\ORM\Query\SqlWalker;
/**
* Quick hack to allow adding a USE INDEX on the query
*/
class UseIndexWalker extends SqlWalker
{
const HINT_USE_INDEX = 'UseIndexWalker.UseIndex';
@fatihacet
fatihacet / pubsub-simple.js
Created October 15, 2011 22:02
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,