Skip to content

Instantly share code, notes, and snippets.

View octavian-nita's full-sized avatar
:octocat:

Octavian Nita octavian-nita

:octocat:
View GitHub Profile
@octavian-nita
octavian-nita / GameStateError.js
Last active April 12, 2016 13:02
Custom Errors in JavaScript. Since we're subtyping builtins, we try to stay as close as the supertype implementation...
define(function () {
'use strict';
/**
* @author Octavian Theodor NITA (http://github.com/octavian-nita)
* @version 1.0, August 24, 2015
*
* @constructor
* @augments Error
* @param {string} [message]
@octavian-nita
octavian-nita / gitignore++.flt
Last active July 21, 2025 08:10
WinMerge directory/file filter to ignore .git and IDE-specific files and directories
## This is a directory/file filter for WinMerge
name: gitignore++
desc: Ignore .git and IDE-specific files and directories
## Select if filter is inclusive or exclusive
## Inclusive (loose) filter lets through all items not matching rules
## Exclusive filter lets through only items that match to rule
## include or exclude
def: include
<?php
class ThonResizer extends KokenPlugin
{
function __construct()
{
// Get information about the available graphics processing library:
list($version, $lib) = Darkroom::processing_library_version();
// Only install the hook if Imagick is available (no GD support for the moment):
@octavian-nita
octavian-nita / Console.java
Created November 17, 2014 14:09
Simple Java / Swing console
package net.codarium.util;
import static java.awt.Font.BOLD;
import static java.lang.Boolean.TRUE;
import static java.lang.System.getProperty;
import static javax.swing.JEditorPane.HONOR_DISPLAY_PROPERTIES;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import static javax.swing.SwingUtilities.invokeLater;
import static javax.swing.UIManager.getSystemLookAndFeelClassName;
import static javax.swing.UIManager.setLookAndFeel;
@octavian-nita
octavian-nita / cache.js
Last active August 29, 2015 14:09
Simple cache for Node.js
'use strict';
var
EventEmitter = require('events').EventEmitter,
util = require('util'),
log = require('./log'),
DEFAULT_OPTIONS = { capacity: 200, evictionCount: 10 };
function Cache(options) {
@octavian-nita
octavian-nita / gallery.js
Created November 17, 2014 14:03
Simple gallery entity for Node.js
@octavian-nita
octavian-nita / log.js
Created November 17, 2014 14:02
Simple logging for Node.js
'use strict';
var config = require('./config');
/**
* @param {string} [level=INFO] by default, 'expected' (from a formatting point of view) values are: ERROR, WARN,
* WARNING, INFO and DEBUG.
*/
function log(level, messageOrError /* messagePart1, messagePart2, ... */) {
var
@octavian-nita
octavian-nita / mime.js
Last active August 29, 2015 14:09
Simple MIME types for Node.js
'use strict';
/**
* Ideas compiled from multiple sources (but trying to keep things simple):
* - https://github.com/h5bp/server-configs-apache/
* - https://github.com/jhermsmeier/node-mime (normally, I would use this one!)
* - https://github.com/broofa/node-mime
* - https://github.com/andris9/mimelib
*
* See also:
@octavian-nita
octavian-nita / xutil.js
Created November 17, 2014 11:33
Node.js / JavaScript useful code snippets
'use strict';
var log = require('./log');
exports.slug = function(name) {
return name || name.
replace(/^[-\s_]*[\[\(]*[\s\d]+[\]\)]*[-\s_]*/g, ''). // remove eventual leading index / number in name
replace(/^[-\s_]+|[-\s_]+$/g, ''). // remove leading and trailing spaces, dashes, underscores
replace(/[-\s_]+/g, config.slugSeparator); // join by defined slug separator
};
#!/bin/sh
sudo /etc/init.d/mysql stop
# OR
sudo /etc/init.d/mysqld stop
sudo mysqld_safe --skip-grant-tables
sudo mysql -u root << EOF