Skip to content

Instantly share code, notes, and snippets.

@finalfantasia
finalfantasia / clean_and_stop_creation_of_wdmc_directories_on_wd_my_cloud_ex2.md
Last active September 14, 2015 07:55
Clean and Stop Creation of .wdmc Directories on WD My Cloud EX2
  1. Stop the daemons:
    /etc/init.d/wdmcserverd stop
    /etc/init.d/wdphotodbmergerd stop
  1. Disable the daemons:
    update-rc.d wdphotodbmergerd disable
    update-rc.d wdmcserverd disable
@finalfantasia
finalfantasia / automatic_semicolon_insertion_in_javascript_everything_you_need_to_know.md
Last active November 4, 2016 17:31
Automatic Semicolon Insertion in JavaScript—Everything You Need to Know

#Automatic Semicolon Insertion in JavaScript—Everything You Need to Know Friday, May 28, 2010

Automatic semicolon insertion is one of JavaScript's most controversial syntactic features. There are also many misconceptions surrounding it.

Some JavaScript programmers use semicolons at the end of every statement and some use them only where strictly required. Most do something in between and a few even intentionally add extra semicolons as a matter of style.

Even if you use semicolons at the end of every statement, some constructs parse in non-obvious ways. Regardless of your preferences in semicolon usage, you must know the rules to write JavaScript professionally. If you remember a few simple rules, all of which are explained here, you will be able to understand how any program you might encounter will be parsed and will be an expert on JavaScript automatic semicolon insertion or ASI.

##Where Semicolons are Allowed

@finalfantasia
finalfantasia / spaces.md
Last active August 29, 2015 14:12
Spaces

White space contributes as much to the effect produced by software text as silence to the effect of a musical piece.

The general rule, for simplicity and ease of remembering, is to follow as closely as possible the practice of a standard written language. By default, we will assume this language to be English, although it may be appropriate to adapt the conventions to the slightly different rules of other languages.

Here are some of the consequences. You will use a space:

  • Before an opening parenthesis, but not after: f (x) (not f(x), the C style, or f( x)).
  • After a closing parenthesis unless the next character is a punctuation sign such as a period or semicolon; but not before. Hence: proc1 (x); x := f1 (x) + f2 (y).
  • After a comma but not before: g (x, y, z).
  • After the two dash signs that start a comment: -- A comment.
@finalfantasia
finalfantasia / the_right_ways_of_writing_css.md
Last active September 13, 2019 14:41
The "Right Ways" of Writing CSS

Separate Structure and Skin

This means to define repeating visual features as separate “skins” that you can mix-and-match with your various objects to achieve a large amount of visual variety without much code. This also means using classes to name your objects and their components, rather than relying solely on the semantics of HTML.

Separate Container and Content

Essentially, this means “rarely use location-dependent styles”.

Core Goals

@finalfantasia
finalfantasia / using_base16_256_color_themes_in_vim_in_gnome_terminal.md
Last active August 29, 2015 14:10
Using Base16 256-color themes in Vim in GNOME Terminal
@finalfantasia
finalfantasia / improving_text_antialiasing_and_gui_performance_in_intellij_idea_on_openjdk_8.md
Last active January 3, 2025 13:21
Improving Text Anti-aliasing and GUI Performance in IntelliJ IDEA on OpenJDK 8

This is a list of tweaks to make IntelliJ IDEA work better with OpenJDK 8. Refer to System Properties for Java 2D Technology for the details of the options used below.

Note that the performance boost achieved via the OpenGL-based hardware acceleration pipeline is made possible by using the open-source Radeon driver (for AMD graphics cards) included in the latest stable version (10.3.3 as of now) of the Mesa 3D Graphics Library available in the official Fedora 21 stable repository. Therefore, the gained performance boost might vary based on the types of graphics cards and the versions of the drivers used in your system.

  1. Fixing Text Anti-aliasing in Fedora (Ubuntu users may skip this step.)
  2. Fixing text anti-aliasing in IntelliJ IDEA

In $IDEA_HOME/bin/idea64.vmoptions (or $IDEA_HOME/bin/idea.vmoptions on a x86 architecture), change

@finalfantasia
finalfantasia / test_double.md
Last active August 29, 2015 14:08
Test Double

Meszaros uses the term Test Double as the generic term for any kind of pretend object used in place of a real object for testing purposes. The name comes from the notion of a Stunt Double in movies. (One of his aims was to avoid using any name that was already widely used.) Meszaros then defined four particular kinds of double:

  • Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
  • Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example).
  • Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'.
  • Mocks are what we are talking about here: objects pre-programmed with expectations whi
@finalfantasia
finalfantasia / calculating_the_specificity_of_a_css_selector.md
Last active August 29, 2015 14:08
Calculating a CSS Selector's Specificity

A selector's specificity is represented by concatenating three numbers: a-b-c (in a number system with a large base), which are calculated as follows:

a = the count of ID selectors in the selector
b = the count of class selectors, attributes selectors, and pseudo-classes in the selector
c = the count of type selectors and pseudo-elements in the selector
ignore the universal selector 

Selectors inside the negation pseudo-class are counted like any other, but the negation itself does not count as a pseudo-class.

Examples:

@finalfantasia
finalfantasia / fun_with_javascript_prototypes.js
Last active August 29, 2015 14:06
Fun with JavaScript Prototypes
// Fun
Object instanceof Function // true
Function instanceof Object // true
// Types of various prototype objects:
typeof Object.prototype === 'object' // true
typeof Boolean.prototype === 'object' // true
typeof Number.prototype === 'object' // true
@finalfantasia
finalfantasia / pseudo_classical_inheritance_in_javascript.js
Last active September 12, 2022 21:38
Pseudo-classical Inheritance in JavaScript
// Phone
var Phone = function (phoneNumber) {
this._phoneNumber = phoneNumber;
};
Phone.prototype.getPhoneNumber = function () {
return this._phoneNumber;
};