Skip to content

Instantly share code, notes, and snippets.

View pushandplay's full-sized avatar
:octocat:
💻💰

Master of life pushandplay

:octocat:
💻💰
View GitHub Profile
@darky
darky / virtual_class.coffee
Last active January 9, 2023 21:37
Multiple inheritance in Coffeescript. This little helper make proper prototype chain and call `super`. Existing classes in chain not violated, uses theirs "projections". Мультинаследование в Coffeescript. Этот маленький хелпер создаёт корректную цепочку прототипов с правильным вызовом `super`. Существующие классы не портятся, используются их "пр…
virtual_class = (classes...)->
classes.reduceRight (Parent, Child)->
class Child_Projection extends Parent
constructor: ->
# Temporary replace Child.__super__ and call original `constructor`
child_super = Child.__super__
Child.__super__ = Child_Projection.__super__
Child.apply @, arguments
Child.__super__ = child_super
@staltz
staltz / introrx.md
Last active July 27, 2024 04:59
The introduction to Reactive Programming you've been missing
@nnarhinen
nnarhinen / Gruntfile.js
Last active February 11, 2020 09:39
Support html5 pushState (or angular.js html5mode) in a yeoman (grunt-contrib-connect) application.
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
//MODIFIED: add require for connect-modewrite
var modRewrite = require('connect-modrewrite');
grunt.initConfig({
@shazron
shazron / ios7.phonegap.cordova.js
Last active December 23, 2015 07:39
PhoneGap / Apache Cordova - top margin for iOS 7
// Pre-requisites:
// 1. Device core plugin
// 2. Splashscreen core plugin (3.1.0)
// 3. config.xml: <preference name="AutoHideSplashScreen" value="false" />
// 4. config.xml: <preference name="DisallowOverscroll" value="true" />
function onDeviceReady() {
if (parseFloat(window.device.version) >= 7.0) {
document.body.style.marginTop = "20px";
// OR do whatever layout you need here, to expand a navigation bar etc
ProcessDocument = app.trustedFunction(function () {
app.beginPriv();
var newDoc = app.newDoc();
var p = app.response("Start with page(default 0 - process all pages)?", "Query", "0");
var startFrom = parseInt(p) || 0;
var i = 0;
while (i < this.numPages) {
newDoc.insertPages({
nPage: newDoc.numPages - 1,
@gadamiak
gadamiak / LangRouter.php
Created October 1, 2012 16:31
Language context router for use with Babel extra for MODX Revolution
<?php
/* LangRouter
* ==========
*
* This plugin is meant to be used with Babel extra for MODX Revolution. It
* takes care of switching contexts, which hold translations, depending on URL
* requested by client. LangRouter works with so called subfolder based setup,
* in which many languages are served under a single domain but are
* differentiated by a virtual subfolder indicating the language, eg.
* mydomain.com/pl/.
@liammclennan
liammclennan / blog_backbone_style.md
Created June 7, 2012 06:33
Backbone.js Style / Patterns

Naming Rules

Use PascalCase for constructors, namespaces and modules:

var m = new Backbone.Model(); 

Prefix private properties with _

This is a convention to compensate for JavaScript's lack of private properties on objects. Being able to identify private methods is important because it tells us that we don't need to test those methods and that they will not be coupled to anything outside of the object.

@cecilemuller
cecilemuller / simulator.command
Created May 29, 2012 00:23
Build and start in XCode Simulator an Adobe AIR 3.3 beta 3 application for iOS 5.1 using shell commandline
#!/bin/bash
#
# This is a Mac OSX shell script, you can simply double-click to start it.
#
# This is where you downloaded the AIR SDK from http://labs.adobe.com/downloads/air3-3.html
AIR_SDK="/Applications/Adobe/AIR SDK/AIR SDK 3.3b3"
# iOS 5.0
@splittingred
splittingred / .htaccess
Created April 9, 2012 21:48
Example of how to use new REST server class in MODX 2.3+
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]
</IfModule>
@arrix
arrix / html_entity_innerHTML_test.js
Created November 12, 2010 09:26
Tests whether an html entity is allowed in .innerHTML assignment
// Tests whether an html entity is allowed in .innerHTML assignment for xhtml documents.
// entities scraped from http://www.webstandards.org/learn/reference/charts/entities/
// stack overflow question on this issue http://stackoverflow.com/questions/4162270/why-does-this-simple-innerhtml-assignment-throw-an-exception/
// In my testing, in Webkit and Mozilla, only &quot;, &amp;, &lt; and &gt; work.
var markupEntities = ["&quot;", "&amp;", "&lt;", "&gt;", "&OElig;", "&oelig;", "&Scaron;", "&scaron;", "&Yuml;", "&circ;", "&tilde;", "&ensp;", "&emsp;", "&thinsp;", "&zwnj;", "&zwj;", "&lrm;", "&rlm;", "&ndash;", "&mdash;", "&lsquo;", "&rsquo;", "&sbquo;", "&ldquo;", "&rdquo;", "&bdquo;", "&dagger;", "&Dagger;", "&permil;", "&lsaquo;", "&rsaquo;", "&euro;"];
var iso8859_1Entities = ["&nbsp;", "&cent;", "&pound;", "&curren;", "&yen;", "&brvbar;", "&sect;", "&uml;", "&copy;", "&ordf;", "&laquo;", "&not;", "&shy;", "&reg;", "&macr;", "&deg;", "&plusmn;", "&sup2;", "&sup3;", "&acute;", "&micro;", "&para;", "&middot;"