Skip to content

Instantly share code, notes, and snippets.

@mosson
mosson / UndefinedArguments.as
Last active December 16, 2015 16:49
Trouble with arguments.callee in Flash Builder 4.7. below code raises "arguments" is undefined.
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
public class UndefinedArguments extends Sprite
{
public function inline_test()
@mosson
mosson / Gruntfile.js
Created May 15, 2013 03:50
grunt-contrib-livereload example
'use strict';
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-connect");
@mosson
mosson / app_router.js
Last active December 17, 2015 08:49
Backbone.Router Deferred Pattern. fetching data in initialize is async, then app_view would be undefined in either action for fetching. $.Deferred resolve this problem.
var AppRouter = Backbone.Router.extend({
app_view: null,
routes: {
"": "index",
"/": "index",
"/new": "new",
"new": "new",
":id": "show",
"/:id": "show",
@mosson
mosson / .gitignore
Created May 16, 2013 02:52
npm + bower + rails gitignore example
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
@mosson
mosson / Gruntfile.js
Created May 17, 2013 07:20
understand grunt-contrib-connect:middleware
module.exports = function(grunt){
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.initConfig({
connect: {
htdocs: {
options: {
port: 9001,
base: "htdocs",
@mosson
mosson / license.txt
Created May 20, 2013 07:04
MIT License
Copyright 2013 mososn
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@mosson
mosson / index.css
Created May 20, 2013 07:17
Pure CSS: Auto expand height like width of block el. overflow is mistery.
.modal {
position: absolute;
overflow: hidden;
height: auto;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
margin-top: 0px;
.image-replacement {
display:block;
/* This property makes el's dimension strict */
/* and, would push out html content */
box-sizing: border-box;
-moz-box-sizing: border-box;
background: url([/path/to/image]) no-repeat;
width: [image_width];
@mosson
mosson / sum.rb
Last active December 17, 2015 14:49
use injection
[1, 2, 3].inject(:+)
@mosson
mosson / error_extract.js
Created May 28, 2013 05:53
extract errors from Rails logs
#!/usr/bin/env node
var fs = require('fs');
var _ = require('underscore');
var ascii_data = fs.readFileSync(process.argv[2], 'ascii');
var errors = _.compact( _.map( ascii_data.match(/^Started[\s\S]+?(?=^Started)/mg).slice(1), function(matched){
if( /Completed\s[45]/.test(matched) ){