Skip to content

Instantly share code, notes, and snippets.

@mchamplain
mchamplain / GameController.cs
Created May 26, 2017 03:46 — forked from FNGgames/GameController.cs
store ids for every entity in a component then look up the entities by their ID using a PrimaryEntityIndex
void Start()
{
// ...
_contexts.game.OnEntityCreated += AddId;
_contexts.input.OnEntityCreated += AddId;
// ...
}
private void AddId(IContext context, IEntity entity)
{
@mchamplain
mchamplain / TimerSystem.cs
Created May 25, 2017 02:40 — forked from FNGgames/TimerSystem.cs
Entitas Timer System
using Entitas;
using UnityEngine;
public class TimerSystem : IExecuteSystem, ICleanupSystem
{
readonly IGroup<GameEntity> _timers;
readonly IGroup<GameEntity> _timerCompletes;
readonly GameContext _context;
public TimerSystem(Contexts contexts)
@mchamplain
mchamplain / hyphenate-long-word.css
Created September 23, 2015 14:43
CSS to hypenate long word when supported and word break on other
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@mchamplain
mchamplain / gist:fb14af60d8dbdba31527
Created February 17, 2015 15:59
Show a modal only once.
$(function() {
if( document.cookie.indexOf( "facebookModalPromoShowOnce" ) < 0 ) {
$( "#dialog-facebook-message" ).dialog({
modal: true,
resizable: false,
show: 'slide',
buttons: {
Ok: function() {
$( this ).dialog( "close" );
document.cookie = "facebookModalPromoShowOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";
@mchamplain
mchamplain / gist:9114814
Created February 20, 2014 14:27
mysqldump ignoring table & gzip
mysqldump -u root --password=xx -F --opt --databases thedbname --ignore-table=thedbname.firsttablename --ignore-table=thedbname.secondtablename | gzip > "thecompresseddump.bak.sql.gz" &
@mchamplain
mchamplain / gist:9105581
Created February 20, 2014 01:56
Regex to parse a youtube URL and extract the video id
<?php
public static function getYoutubeVideoIdFromUrl($url)
{
// Check for a valid youtube url
$rx = '~ # Using ~ to avoid LTS (http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome)
^http(?:s)?:// # Mandatory protocol (optional ssl)
(?:www\.)? # Optional subdomain
(?:youtube\.com/watch(?:/)?\?v=|youtu\.be/) # mandatory domain & path for youtube or shortlink for youtu.be
([^?&]+) # video id as capture group 1
~x';
@mchamplain
mchamplain / dev.local
Created March 26, 2012 11:26
Dynamic apache configuration for dev
<VirtualHost *:80>
ServerName dev.local
ServerAlias *.dev.local
DocumentRoot /var/www/vhosts/
# get the server name from the Host: header
UseCanonicalName Off
LogLevel warn
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
aspect.before(win.body(), (!has("mozilla") ? "onmousewheel" : "DOMMouseScroll"), function () {
// scrolling
});